0

Regarding the receipt of IAP consumable products, in the Apple documentation I read: "Information about consumable products is added to the receipt when they’re paid for and remains in the receipt until you finish the transaction. After you finish the transaction, this information is removed the next time the receipt is updated—e.g., the next time the user makes a purchase".

In a server to server receipt validation scenario, suppose the user buys the consumable product "A" and, due to a server outage, the purchase can't be immediately verified and the corresponding transaction is not finished. Then, suppose the user buys again another "A" product while the server is still not working. From what I understand the IAP receipt is unique for all purchases and can be retrieved in this way:

let appStoreReceiptURL = Bundle.main.appStoreReceiptURL,
let receiptData = try Data(contentsOf: appStoreReceiptURL, options: .alwaysMapped);
let receiptString = receiptData.base64EncodedString(options: []);

Now, since the receipt is unique and the first transaction is not finished, is the second purchase appended to the first one in the receipt? When it comes the moment to validate the purchases should I send the same receipt to my server for both validation?

Thank you in advance

Andrea Gorrieri
  • 1,704
  • 2
  • 22
  • 36
  • There is only one receipt, so I am not sure what you mean by the "global" receipt. In reality it is unlikely that the user will complete another purchase before you have validated the first, since the first thing your app should do when it starts is register the transaction queue observer. When it does this, the previous incomplete transaction will be presented. At this point you should validate the purchase with your server. This will more than likely complete well before the user has time to access your purchase screen and initiate another purchase. – Paulw11 Sep 20 '18 at 12:43
  • Thank you @Paulw11. My doubt is related to the case in which the first purchase can't be verified (e.g. temporary network outages) and another purchase is triggered without leaving the application. In this way the second purchase is to be verified and I haven't verified the first one since, from what I'm understanding, a previous incomplete transaction is presented when the application is launched again (transaction queue observer is registered in the didFinishLaunchingWithOptions method). In this case are both purchases added to the receipt? Can I use this receipt in order to validate both? – Andrea Gorrieri Sep 21 '18 at 06:55

0 Answers0