We have an app in production at the moment that offers recurring in-app purchases. Things are working well, except for a handful of users...
After the initial payment for a subscription is successful, we send the value of SKPaymentTransaction.transaction_id and the contents of Bundle.main.appStoreReceiptURL to our server for validation. We pass the receiptBlob to Apple's https://buy.itunes.apple.com/verifyReceipt API and in 99% of our cases, we get back a matching transaction_id, however, there are a bunch of cases where it returns a different identifier.
The values of the identifiers are always pretty close numerically (for example, 220000325892796 vs 220000325892855 - a diff of 59), but at the moment, we're using these values as part of our server-side receipt verification logic which brings us unstuck.
I can't reproduce using the sandbox environment at all. The closest I've come is (but not really):
- User successfully purchases subscription
- Network goes down so they can't notify/validate with our server
- User attempts to purchase subscription again. This time they get a message from Apple saying they're already subscribed, however they do get allocated a new transaction identifier
- Network comes back up and they send the *new* transaction id into our server.
The big difference between the above scenario and the one we're experiencing in production is that in the above case, the transaction_id is different to the original_transaction_id (which I can rationalise to myself), whereas in our production cases the transaction_id and original_transaction_id values are the same which imply that it is the original transaction.
I just don't understand how I can go from being given a transaction id on the device and then when retrieving the receipt detail from Apple's server I end up with different transaction identifiers.
Very puzzling... any thoughts would be much appreciated.
Cheers,
Craig