How to use one appStoreReceiptURL to check multiple StoreKit transactions?

We use server-side validation to check our iTunes in app purchases. When the transaction is sent to the SKPaymentTransactionObserver server, we take the receipt from appStoreReceiptURL to check it.

if let receiptPath = NSBundle.mainBundle().appStoreReceiptURL?.path where NSFileManager.defaultManager().fileExistsAtPath(receiptPath), let receiptData = NSData(contentsOfURL:NSBundle.mainBundle().appStoreReceiptURL!) { return receiptData } 

But in some cases, for example, when we restore purchases, we get several transactions to the method:

 public func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) 

It seems rather strange to use the same receipt data to verify each transaction. Does one receipt have data about each transaction?

+5
source share
1 answer

Does one receipt have data about each transaction?

Yes. The receipt received from appStoreReceiptURL is a single receipt for all ongoing transactions for the user and the application.

Documents on receipt of purchase in the application

A receipt for a consumer product is added to the receipt when making a purchase. It is stored on the receipt until your application completes this transaction. After this moment, it will be deleted from the receipt at the next update of the receipt, for example, when the user makes another purchase or if your application explicitly updates the receipt.

An in-app purchase receipt for a non-consumable product, an auto-renewal subscription, a non-renewable subscription, or a free subscription remain on the receipt for an indefinite period.

those. All in-app purchases, including renewal and refunded purchases and excluding purchased purchases, create a new transaction and are stored in the receipt.

Documents for working with subscriptions :

After a successful subscription upgrade, the Store Kit adds the upgrade transaction to the transaction queue. Your application checks the transaction queue at startup and processes the update in the same way as any other transaction.

Documents for the restoration of purchased products :

Restoring completed transactions creates a new transaction for each completed transaction made by the user.

Please note that the original transaction ID will be the same for restored purchases and renewal.

A receipt is essentially a file stored on the device that the application updates when a new transaction is added.

+10
source

Source: https://habr.com/ru/post/1239934/


All Articles