Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS in-app purchase receipt not returning an original_purchase_date for a redownload

I am trying to use the iOS store receipt to tell the difference between a purchase and a redownload, based on the original_purchase_date and/or original_transaction_id . Regardless of whether a transaction is a new purchase or a redownload, the store receipt always returns a new original_purchase_date which is equal to the purchase_date value.

Here is a real store receipt I got back (which is a redownload of an existing in app purchase - as I am currently having to rely on UDID tracking to tell them apart)

{
  "product_id": "com.myproduct.id",
  "original_purchase_date_ms": "1329825956382",
  "purchase_date_ms": "1329825956382",
  "original_purchase_date": "2012-02-21 12:05:56 Etc/GMT",
  "purchase_date":          "2012-02-21 12:05:56 Etc/GMT",
  "bvrs": "1.0",
  "original_purchase_date_pst": "2012-02-21 04:05:56 America/Los_Angeles",
  "purchase_date_pst":          "2012-02-21 04:05:56 America/Los_Angeles",
  "original_transaction_id": "1000000028387131",
  "transaction_id":          "1000000028387131",
  "item_id": "452671574",
  "quantity": "1",
  "bid": "com.mybundle.id"
}

Regardless of whether I'm using the sandbox URL and testing with a test itunes connect account, or whether its a live purchase using the live URL for receipt verification, these values are always identical:

original_purchase_date_ms  ==  purchase_date_ms
original_purchase_date == purchase_date
original_purchase_date_pst == purchase_date_pst
original_transaction_id == transaction_id

Am I wrong in thinking that these are what you should use to tell the difference between a new purchase and a redownload of the same purchase? Obviously tracking the UDID of the device / making a app GUID and tracking that, is one way to do it but its not accurate enough (e.g. users who have multiple devices)

Does anyone else have this problem where these values are ALWAYS identical?

Any help on this is much appreciated! I've exhausted all other routes and hoping someone on here knows the answer.

like image 501
user1225584 Avatar asked Feb 22 '12 15:02

user1225584


People also ask

What is an app store receipt and how does it work?

When a user makes an in-app purchase, the AppStore creates a receipt. What is App Store Receipt? In-App Purchases provide you a convenient way to monetize in-app content and features within your app. To provide access to your content, you need to pass a receipt through the receipt validation ( verifyReceipt) endpoint.

How do in-app purchases work?

In-App Purchases provide you a convenient way to monetize in-app content and features within your app. To provide access to your content, you need to pass a receipt through the receipt validation ( verifyReceipt) endpoint. Receipt is an encrypted file signed with an Apple certificate.

How do I find a receipt for a purchase?

To find your receipts, tap then choose Receipts to see a list of your receipts. If you're on a Mac or PC, click Receipts. A receipt might not be available if you made the purchase recently. Get help with an item purchased from the iTunes Store, App Store, Mac App Store, or iBooks Store Thank you for using Apple Support Communities.

How do I retrieve the receipt data from the app?

To retrieve the receipt data ( appStoreReceiptURL) from the app on the device, use the appStoreReceiptURL = Bundle.main.appStoreReceiptURL Is it necessary to validate receipts?


1 Answers

It depends on what you mean by "redownload".

The original_purchase_date should differ from purchase_date only when you are restoring your purchase, so the SKPaymentTransaction returns you SKPaymentTransactionStateRestored. If it's the case, there's something wrong.

Otherwise, for example, if you are repurchasing a consumable purchase, theese dates will be the same all the time, and everything's ok.

like image 109
Nikita Pestrov Avatar answered Sep 28 '22 08:09

Nikita Pestrov