Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not sure sorting by transaction_id works with family sharing #90

Open
ricsantos opened this issue Aug 22, 2022 · 5 comments
Open

Not sure sorting by transaction_id works with family sharing #90

ricsantos opened this issue Aug 22, 2022 · 5 comments

Comments

@ricsantos
Copy link

ricsantos commented Aug 22, 2022

Noticed that a iOS user who was having receipt validation issues had two items in the latest receipt info array:

  "latest_receipt_info": [
    {
      "quantity": "1",
      "product_id": "yearly",
      "transaction_id": "501136461303889853",
      "original_transaction_id": "501136461303889853",
      "purchase_date": "2022-02-10 17:59:20 Etc/GMT",
      "purchase_date_ms": "1644515960000",
      "purchase_date_pst": "2022-02-10 09:59:20 America/Los_Angeles",
      "original_purchase_date": "2022-02-10 17:59:21 Etc/GMT",
      "original_purchase_date_ms": "1644515961000",
      "original_purchase_date_pst": "2022-02-10 09:59:21 America/Los_Angeles",
      "expires_date": "2022-02-17 17:59:20 Etc/GMT",
      "expires_date_ms": "1645120760000",
      "expires_date_pst": "2022-02-17 09:59:20 America/Los_Angeles",
      "cancellation_date": "2022-03-10 20:57:06 Etc/GMT",
      "cancellation_date_ms": "1646945826586",
      "cancellation_date_pst": "2022-03-10 12:57:06 America/Los_Angeles",
      "is_trial_period": "true",
      "is_in_intro_offer_period": "false",
      "cancellation_reason": "0",
      "in_app_ownership_type": "FAMILY_SHARED"
    },
    {
      "quantity": "1",
      "product_id": "monthly",
      "transaction_id": "150001161180179",
      "original_transaction_id": "150001161180179",
      "purchase_date": "2022-08-12 19:06:35 Etc/GMT",
      "purchase_date_ms": "1660331195000",
      "purchase_date_pst": "2022-08-12 12:06:35 America/Los_Angeles",
      "original_purchase_date": "2022-08-12 19:06:35 Etc/GMT",
      "original_purchase_date_ms": "1660331195000",
      "original_purchase_date_pst": "2022-08-12 12:06:35 America/Los_Angeles",
      "expires_date": "2022-09-12 19:06:35 Etc/GMT",
      "expires_date_ms": "1663009595000",
      "expires_date_pst": "2022-09-12 12:06:35 America/Los_Angeles",
      "is_trial_period": "false",
      "is_in_intro_offer_period": "false",
      "in_app_ownership_type": "PURCHASED"
    }
  ]

Our tactic of grabbing the last item in the array failed, because iap sorts the items before returning them:

latestReceiptInfo = result.latest_receipt_info.sort(function (a, b) {

However the sorting is via transaction_id and in this case the first transaction has a much larger id than the second. Not sure if related to family sharing, or a red herring.

Perhaps don't sort the array when parsing?

@ayano-opendna
Copy link

I have same problem too.
In case of family sharing, transaction_id is larger than new one of purchase. So I cant get latest receipt.
How can I get latest receipt in anyway ?

@ronkorving
Copy link
Collaborator

Years ago, I maintained this project, but I've since moved on. I'm getting the impression this project is no longer maintained and you may be better off using an alternative.

@adamk22
Copy link

adamk22 commented Feb 5, 2024

@ronkorving do you have any recommendations? I'm currently in the process of refactoring a project where this is used for iap verification, but have yet to look for an alternative.

@ronkorving
Copy link
Collaborator

I'm sorry to say I do not. I hardly use Node.js these days.
But I do know there is more than one IAP related package on NPM.

@ayano-opendna
Copy link

@ronkorving
Thank you to reply! I will try other NPMs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants