question

Daniel Keele avatar image
Daniel Keele asked

Purchase multiple items with virtual currency

I would like to purchase many distinct products from my catalog in a single client API call.

I am thinking of PurchaseItem, but rather than passing the request a single `ItemId`, passing in an array of `ItemId`s.

I have seen this thread, but it is quite old. I'm wondering if there's a newer, streamlined way of doing this.

Thanks!

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

There are no updates of the API PurchaseItem. If you use the PurchaseItem, you can purchase one item, container, or bundle in one API call. So, if the multiple items are in a fixed item package, you can add them in a bundle, then let players purchase this bundle using PurchaseItem.

If these items will be selected by players randomly, we will still suggest you use the API StartPurchase, PayForPurchase, and ConfirmPurchase to purchase multiple items. Otherwise, you can implement a Cloud Script Azure Function that needs a list of items as the parameter for purchase. You can call the Server API SubtractUserVirtualCurrency and GrantItemsToUser on cloud to implement the purchase feature.

If you need to use the Client API PurchseItem to purchase multiple items in one call, you can try to add a feature request for it.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Daniel Keele avatar image Daniel Keele commented ·

Thanks Sarah!

I went with Sarah's second suggestion. You can see my implementation here.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.