Verify IAP Receive for iOS

I am working on a client / server application that uses Apples IAP and StoreKit to purchase a subscription.

We would like the client (iPhone or iPad) to make an initial purchase of an apple subscription through their iTunes account using the StoreKit infrastructure, and then transfer the receipt to our server, which will check it and then update users Account status. We would also like the server to be responsible for managing the status of the subscription (check for automatic renewal, cancellation, etc.). All of this is used in the appleReceipts style in the iOS 7 style, and not in transaction transactions such as iOS 6, which are currently deprecated.

Apple docs reports POST at the following URL to check the receipt in the sandbox along with the receipt and secret code

https://sandbox.itunes.apple.com/verifyReceipt

Up to this point, everything works as it should.

Where they confuse me, in response. Apple reports that the response should contain up to 4 fields. If you are checking for receipt of an iOS 7 style app receipt, you should expect only the first. 2. If this will be getting an iOS 6 subscription, then you should expect to see all 4.

1) status (0 for valid, otherwise error code)

2) receipt (representation of the JSON receipt that was sent)

3) last_receipt (returned only for transaction receipts such as iOS 6 for subscribers with automatic renewable subscription. Transaction receipt with base-64 for the latest update.)

4) last_receipt_info ( JSON)

1: 4, , iOS 7. , .

https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW1

2: , , API , . latest_receipt_info, -, , receipt - .

: , , , - latest_receipt_info latest_receipt, .

​​ Apple? , AppReceipts, SKPayementTransactionObserver?

EDIT - .

1) autoRenewSubscription SKPaymentQueue:

 SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product];
    payment.applicationUsername = [self hashedValueForAccountName:[UserAccount sharedInstance].subscriberKey];
    [[SKPaymentQueue defaultQueue] addPayment:payment];

2) , SKPaymentTransactionObserver URL-:

NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];

.

3) python

import itunesiap
import base64

file = "/path/to/receipt/sandboxReceipt"
f = open(file)
encoded = base64.b64encode(f.read())

with itunesiap.env.current().clone(use_sandbox=True):  # additional change for current environment.
    response = itunesiap.verify(encoded,"mysecretkey")

.

"latest_receipt" = base64 encoded receipt here
"latest_receipt_info" = a JSON representation of the latest receipt
"receipt" = a JSON representation fo the receipt I sent for verification

, 2

" iOS 6 ".

  • , iOS 7 ?
  • ,    ?
+2
2

Apple . iOS 6 . , iOS 7 appStoreReceiptURL, , . iOS 6, .

+3

All Articles