question

Anubhav B avatar image
Anubhav B asked

Creating ItemPurchaseRequest on JavaScript for request

Hi everyone,

I'm trying to create an API request for StartPurchase - https://learn.microsoft.com/en-us/rest/api/playfab/client/player-item-management/start-purchase?view=playfab-rest#itempurchaserequest. However, I am unsure as to how to create a constructor for ItemPurchaseRequest on JavaScript that I can then pass into my HTTP request. How would I approach this?

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

·
Neils Shi avatar image
Neils Shi answered

According to your description, you can refer to the following codes to complete the ItemPurchaseRequest,

function DoExampleStartPurchase(){
    var startPurchaseRequest = {
      CatalogVersion: "Main",
      StoreId: "MainStore",
      Items: [
              {
                  ItemId: "something0",
                  Quantity: 1,
                  Annotation: "totally buying something"
              },
              {
                  ItemId: "something1",
                  Quantity: 2,
                  Annotation: "totally buying something"
              }
               ]
    };
    PlayFabClientSDK.StartPurchase(startPurchaseRequest, PurchaseCallback);
}
<br>

If you want to use PlayFab via JavaScript, you can refer to the QuickStart: PlayFab client library for JavaScript.

10 |1200

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

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.