Cross-platform In App Billing Plugin for .NET
Each platform handles security of In-App Purchases a bit different. To handle this whenever you make a purchase you should use the date from the purchase to validate on your backend.
Based on the platform this data is a bit different and is returned as part of the InAppBillingPurchase:
PurchaseToken is the transaction signed by the App Store as a JWS. StoreKit 2 has already verified it on the device, and transactions that fail are not returned as purchases. Verify it on your server for stronger protection.OriginalJson is the JSON representation of the transaction.CrossInAppBilling.Current.ReceiptData still returns the Base 64 app receipt, but Apple has deprecated receipts.The Microsoft Store has no client-side receipt. ReceiptData is empty, and Signature is not set. Instead:
OriginalJson contains the Store’s collection data for the purchase, including transactionId and orderId.GetStoreContext().GetCustomerCollectionsIdAsync(serviceTicket, publisherUserId) from InAppBillingImplementation.I recommend reading the Google Play services Security and Design that will walk you through your options on storing your public key.
Not only should your receipt be verified in the app, but ideally it should be verified on a server. I leave this in your hands to add the server side validation by reading Apple and Google’s documentation. I provide everything you need in the VerifyPurchase method to handle verification.
For examples of implementation I would recommend reading a great blog series by Jonathan Peppers:
<= Back to Table of Contents