question

hipposoft3 avatar image
hipposoft3 asked

Is it right that IAP with playfab receipt validation return "complete"?

Im making Unity IAP with the playfab receipt validation. In ProcessPurchase() in below script, It returns PurchaseProcessingResult.Complete; at the bottom of my script. But There is the playfab receipt validation API call. So i think, should it be return PurchaseProcessingResult.Pending first, and playfab validation API return success callback, and return or change that result to Complete, isn't it?

In other word, It's ok to return PurchaseProcessingResult.Complete first when It is not sure the purchase would pass through the receipt validation?

 public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
 {

     var googleReceipt = GooglePurchase.FromJson(args.purchasedProduct.receipt);
     PlayFabClientAPI.ValidateGooglePlayPurchase(new ValidateGooglePlayPurchaseRequest()
     {
         CurrencyCode = args.purchasedProduct.metadata.isoCurrencyCode,
         PurchasePrice = (uint)(args.purchasedProduct.metadata.localizedPrice * 100),
         ReceiptJson = googleReceipt.PayloadData.json,
         Signature = googleReceipt.PayloadData.signature
     }, result =>
     {
         Debug.Log("Validation successful!");
    
     }, error =>
     {
         Debug.Log("Validation failed");
     }
     );
     return PurchaseProcessingResult.Complete; // This parts should be PurchaseProcessingResult.pending?
 }
apisunity3d
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

In other word, It's ok to return PurchaseProcessingResult.Complete first when It is not sure the purchase would pass through the receipt validation?

Yes, it's OK. When the purchase process begins, the player interacts with the IAP interface and - if the purchase is successful - player will obtain a receipt. PlayFab is then able to validate the receipt and register the purchase, granting the PlayFab player the items that they just bought. And according to the API ValidateGooglePlayPurchase's Document, if the purchase would not pass through the receipt validation, you may get an Error Code like “InvalidReceipt”, “ReceiptAlreadyUsed” or “ReceiptCancelled”. In the successful/error callback, instead of Debug.Log, you can also assign the result to a global value.

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.