Home > Blockchain >  Verifying In-App Purchase with AppStore using data from In-App Plugin for Xamarin
Verifying In-App Purchase with AppStore using data from In-App Plugin for Xamarin

Time:04-22

In my Xamarin Forms 5 app, I'm using the in-app purchase enter image description here

The enter image description here

I'm trying to figure out what I need to send as receipt-data which is supposed to be of type byte.

So far, I tried sending the PurchaseToken property I receive in the response object -- using the In-App Plugin -- see first image above. That failed. I then converted the PurchaseToken value to a byte array using the following conversion and that failed too.

var byteValue = Encoding.ASCII.GetBytes(purchaseTokenValue);

I keep getting { "status": 21002 } from AppStore API which apparently means malformed according to enter image description here

CodePudding user response:

The final solution is as follows. First, I upgraded to the latest (pre-release) Beta version of the plugin. In my case that ended up being 6.3.2-beta.

In the case of iOS, the receipt data does NOT come in the transaction object we get for the purchase. I'm providing the code including the purchase call and platform specific steps so that it's clear for everyone:

// First, make the purchase call and get transaction data
var purchase = await billing.PurchaseAsync(productId, ItemType.Subscription);

// We then handle platform specific steps
if (Device.RuntimePlatform == Device.Android)
{
   // Must call AcknowledgePurchaseAsync else the purchase will be refunded
   await billing.AcknowledgePurchaseAsync(purchase.PurchaseToken);
}
else if(Device.RuntimePlatform == Device.iOS)
{
   // Grab receipt data
   var receiptData = CrossInAppBilling.Current.ReceiptData;
}
  • Related