From iOS7 Apple deprecated transactionReceipt property of SKPaymentTransaction instance, and now we have one big receipt contained everything. In my app I have several consumable purchases. My code:
#pragma mark -
#pragma mark SKPaymentTransactionObserver
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray<SKPaymentTransaction *> *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
...
}
}
- (void)completeTransaction:(SKPaymentTransaction *)transaction {
// [self sendRecieptToServer:transaction.transactionReceipt]; // deprecated
[self testMainReceipt];
[self deliverPurchaseNotificationFirIdentifier:transaction.payment.productIdentifier];
[SKPaymentQueue.defaultQueue finishTransaction:transaction];
}
- (void)testMainReceipt {
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
[self sendRecieptToServer:receipt]; //look at the 'status' field and determine whether a good purchase or not
}
From Apple response I see 'in_app' filed with an array, containing always 1 item - my most recent purchase, no matter how many times I made purchases before. Am I right that this how consumable purchases work? And I'll always get array with 1 item and 'status' field for this most recent purchase? Or there its better way?
Use the production URL https://buy.itunes.apple.com/verifyReceipt when your app is live in the App Store. For more information on these endpoints, see verifyReceipt. Verify your receipt first with the production URL; then verify with the sandbox URL if you receive a 21007 status code.
Receipt validation is a way to protect against fraudulent in-app purchases made in the iOS and Android app stores, and is used to ensure transactions occurred as reported.
You'll need to buy these items every time you want them, and you can't download them again for free. If you remove and reinstall an app, or install an app on a new device, you might lose your consumable purchases. For example, if you install a game on your iPod touch that you started playing on your iPhone, the game levels sync, but extra health or experience points you bought on your iPhone don't sync.
Consumable Products can be Game Currency,Extra Health,Extra experience points.
Consumable Products can't be restored,& also appear once in receipt.
You can find more details link. you can also check this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With