Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Is there a way to include custom data that will be include in the receipt?

Discussion in 'Unity IAP' started by Morphus74, Sep 13, 2022.

  1. Morphus74

    Morphus74

    Joined:
    Jun 12, 2018
    Posts:
    174
    When doing a purchase, is there a way to include (maybe using payload) custom data, that will then be shown on the receipt.

    I would need that because in my game, a player can play with multiple account on the same device, so if he buy in store, then application close while transaction is in pending state, I need a way to identify to which player account I should assign the transaction.

    Anyone have a way or a suggestion?
     
  2. John_Corbett

    John_Corbett

    Unity Technologies

    Joined:
    May 17, 2019
    Posts:
    151
    Hi @Morphus74

    What platform and store is your App running on? The answer may depend on whether it's Apple, Google Play, etc.
     
  3. Morphus74

    Morphus74

    Joined:
    Jun 12, 2018
    Posts:
    174
    Need it ideally for Windows, Apple and Android
     
  4. John_Corbett

    John_Corbett

    Unity Technologies

    Joined:
    May 17, 2019
    Posts:
    151
    Hi @Morphus74,

    Unfortunately There's no way to just modify the receipts because, for one, this could prevent them from being validated if their format changed. The receipts are being provided directly from the native stores themselves. We can't change any data therein between app sessions. ("Native Store" being the Google Play Store itself, for example, not our intermediary API)

    Normally when your app launched, the IAP SDK will request purchase receipts from the native store in question. Normally, only the account currently logged into the store will be checked and therefore only receipts associated to that account will be polled.

    The IAP SDK doesn't cache receipts on the device, per se, all it retains are transactionIDs via an internal TransactionLog. The SDK compares these transactionIDs to those of receipts pulled from the store and see if they've previously been processed. TransactionIDs should be unique enough to not have them in common between accounts.

    Can you please elaborate on the problem you're encountering? Are you caching the whole receipts in your app's file system? Are you allowing account changes in the same app session?

    The IAP SDK doesn't integrate any user account APIs, so we don't even know the GooglePlay accountID, AppleID, etc of the account in question. You'd have to implement that part, but I assume you may have already done so.
     
  5. Morphus74

    Morphus74

    Joined:
    Jun 12, 2018
    Posts:
    174