- Home /
How can i get the iOS base64 encoded receipt data from Unity IAP
From this quesiont http://forum.unity3d.com/threads/iap-receipt-is-not-base64-encoded.376756/
I'm using Unity 5.3 built-in IAP service, and testing it on iOS. When purchasing success, I can get receipt from UnityEngine.Purchasing.Product.receipt .
It looks like this: {"Store":"AppleAppStore","TransactionID":"1000000186798000","Payload":"MIIT4AYJKoZIhvcNAQcCoIIT0TCC..."}
From doc: http://docs.unity3d.com/Manual/UnityIAPPurchaseReceipts.html "Payload" should be base64 encoded on iOS > 7.0, but it's not, I tried to decode it, it's ASN.1 encoded.
Why it's not base64 encoded, where am I wrong?
I have the same question now!
I'm using the https://github.com/nomad/venice to verify the order, the plugin need the Base64 encoded receipt data.
how can i get the Base64 encoded data from payload?
Answer by ShawnFeatherly · Jan 06, 2018 at 11:10 AM
I haven't tried this, but according to https://docs.unity3d.com/Manual/UnityIAPValidatingReceipts.html it should work.
#if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX
var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
// Get a reference to IAppleConfiguration during IAP initialization.
var appleConfig = builder.Configure<IAppleConfiguration>();
var receiptData = System.Convert.FromBase64String(appleConfig.appReceipt);
AppleReceipt receipt = new AppleValidator(AppleTangle.Data()).Validate(receiptData);
Debug.Log(receipt.bundleID);
Debug.Log(receipt.receiptCreationDate);
foreach (AppleInAppPurchaseReceipt productReceipt in receipt.inAppPurchaseReceipts) {
Debug.Log(productReceipt.transactionIdentifier);
Debug.Log(productReceipt.productIdentifier);
}
#endif
Your answer
Follow this Question
Related Questions
[Help!] Fighting with Receipt Validation (iOS) 0 Answers
What's the best way to confirm a consumable iOS purchase? 0 Answers
Unity IAP - Works in Editor; Fails in XCode, Fails in Testflight (iOS) 1 Answer
Trying to work out how to store non-consumables with Unitys new IAP plugin (Android, iOS) 0 Answers
IAP in Steam Development using Unity 1 Answer