Skip to content

Not sure sorting by transaction_id works with family sharing #90

Description

@ricsantos

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions