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: Unity - Manual: Purchase Receipts “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 GitHub - nomad-cli/venice: Ruby Gem for In-App Purchase Receipt Verification to verify the order, the plugin need the Base64 encoded receipt data.

how can i get the Base64 encoded data from payload?

I haven’t tried this, but according to Unity - Manual: Receipt validation 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