Question 1
Let me clarify how this is normally handled.
The client app gets a list of the available items for purchase by calling GetSalesInventory(). That call take into account who the user is, what segments they are in, etc. to determine which Cash Products to return in that call.
So if you want to use segments to determine who can purchase an item, you would normally:
- Set the item as "Not for Sale" as it's default price
- Then in the segmented Promotions, you set the sale (in this case "Regular") price.
In that way - people normally cannot buy the product - but it the user is in the segment covered by the promotion - it WILL appear at what you call the "regular price" for that user when they call GetSalesInventory().
Do you get how this does what you are asking for?
Question 2 - How is promotionId to be passed.
The promotion is automatically taken into account when calling GetSalesInventory(). The trick is to still know a promotion is involved when we are processing the purchase receipt. That is accomplished by caching the new "payload" field.
So the client should:
- Call GetSalesInventory() to determine what products to show to the user
- Bring up their store UI so the user can view things. Probably involves calling the platform's store APIs to get localized prices of everything.
- When the user selects an item to purchase, the client app world:
- Call AppStore.CachePurchasePayloadContext() with the "payload" field that was associated with the item the user has chosen.
- then call the platform's appstore api to initiate the purchase.
Then when brainCloud is processing the purchase it will retrieve the cached "payload" information - which includes information about the promotionId that was involved (if there was one).
So note - in this flow you don't really NEED to call GetEligiblePromotions() - though that can be handy if you need to use that to show some banners in your store or something.
Regarding counting of sandbox purchases - I don't think we include those in the stats. We record the purchase so that you can verify that it is happening end-to-end, but we now keep those totals out of the stats.
I hope that helps!