Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

ID on Purchased Product that is in the PENDING state

Discussion in 'Unity IAP' started by jmakar, Jul 10, 2018.

  1. jmakar

    jmakar

    Joined:
    Jun 27, 2018
    Posts:
    18
    Hi - I'm designing our app's purchase flow and focusing on edge cases. The following two cases are what I'm looking at right now:
    1. Product purchased > ProcessPurchase() called with PENDING returned > App crashes > App is launched again > ProcessPurchase() is called
    2. (Same steps as bold above) > App is launched on *another* device (same user logged into the store)
    For #1, when ProcessPurchase() is called for that subsequent session, is my original IAP product id retained? (I wasn't sure if Unity IAP caches this.) Or will I have to have re-initialized the store with that ID on this session? I won't get into why this matters to me unless needed.

    For #2, I would think that the other device would also be given a chance to fulfill the purchase and complete it. Yes? And if yes, I have the same product ID question. Which ID would I expect on that.

    Hopefully I've asked these in a non-confusing way. I appreciate your help.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    For #1, ProcessPurchase will be called again with the same product information as the original purchase. For #2, the other device should behave the same way as the original device.
     
  3. jmakar

    jmakar

    Joined:
    Jun 27, 2018
    Posts:
    18
    OK great, thanks! So the Unity IAP API must be remotely persisting the ID I give it in order to retain that cross-device. Glad to hear!
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @jmakar No, actually Google (and Apple) remember the user and their purchases across devices.
     
  5. jmakar

    jmakar

    Joined:
    Jun 27, 2018
    Posts:
    18
    Right, but they don't remember the custom ID that I ascribed to the product when registering it with the Unity IAP API. That very specific detail is what I'm asking about. I may have a product with a global ID of XX_YY_ZZ with a store-specific ID of coin_package_001_google.

    If ProcessPurchase() is called in the same session as the purchase, I see that XX_YY_ZZ will be the ID provided on the Product passed into ProcessPurchase(). Which is easily understandable because it is still in memory from the products I registered at app startup.

    However, what global ID will I see (not store-specific id) when ProcessPurchase() is called in a subsequent session *or* is called in the same app for the same user but on another device? This global ID will not have been made available to those other sessions or other devices. (I'll give a little more context in the 'ps' below in case you want to read it.)

    Please advise. Thanks!

    ps. Our popular casino product (which is currently on another client tech) has a one-to-many relationship with store-specific product ids. For example, coin_package_001_google is used to take $1.99 from the user, but it may map to N number of unique ids within our own store. Because of that, we need to be able to correlate a receipt with the unique ID of what they tried to purchase. With Google Play this is easier because we can supply a developer payload which will contain the original unique ID. With Apple there is no such payload feature. Based on what you said in your previous reply it sounds like this unique id will likely *not* be returned as a property in Product in ProcessPurchase() in subsequent sessions or for the same user on another device. If that is the case, I just need to know what instead would be there (maybe the store-specific id bubbles up to that spot?). So that I can figure out the best way to fulfill the order. I have some ideas, but need information first. Sorry for the long exposition but I wanted to make sure I provided context if you chose to read it.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  7. jmakar

    jmakar

    Joined:
    Jun 27, 2018
    Posts:
    18
    Thanks Jeff, I will. Seems like an article might be useful once I'm complete. Does Unity have a way to publish something like that?

    BTW - I am using FetchAdditionalProducts since products may be generated by the server at any time. But I need at least a single product to initialize the store to begin with. So I'm using a single hard coded id for that purpose.