Product Identifier Wrong

We have implemented in-app purchases for buying a set of consumables from both the Apple and Google stores. Basically we set up product identifiers x, y and z on both the Apple and Google stores and then pass whatever the user is buying to Store.purchase.

The entire thing works fine for the Apple store.

For the Google store, the first app purchase works fine, but subsequent purchases always return the product identifier for whatever was purchased first. To Google, the product identifier is what we passed to Store.purchase, but what we get back in the Store’s listener as a product identifier is not correct.

Also, in the receipt, all of the user’s purchases are listed (correctly). My shot-in-the-dark guess is that because they’re all listed, something somewhere is just taking the first bought thing from the receipt and using that as the product identifier.

To reiterate:

  1. We initialize the store with store.init(“google”, purchaseHandler) - where purchaseHandler is our listener.
  2. We pass the product identifier (call it x) to Store.purchase.
  3. purchaseHandler is called with event.transaction.productIdentifier == x, everything works peachy.
  4. For the same user, we pass a different product identifier (call it y) to store.purchase.
  5. This time purchaseHandler is still called with event.transaction.productIdentifier == x, not y as it should be.
  6. event.transaction.receipt shows both purchases with seemingly correct information.

Now, as with anything like this, we could always be doing something wrong, but we’re handing off the right value and getting back a different value with none of our code in between, so that seems sketchy. And, as I said, it works fine with the Apple store.

Has anyone else experienced this, is this a bug, or are we doing some sort of crazy bad config that’s causing this?

For now I’m going to work around it by just using the product identifier I passed locally without accepting that the one passed back is accurate, but that seems like an unnecessary workaround if we were being passed the right thing.

Thanks! 

I haven’t experienced anything like this.

In your purchaseHandler function, do you call store.finishTransaction() appropriately?  If not, that could explain why you’re seeing the first product come through again.

  • Andrew

Finish transaction is being called appropriately. It’s not that it’s coming through again later or anything like that. The first transaction works fine. Everything about the second transaction is correct except that the product identifier is wrong.

What I mean by everything being correct is that if I look at all the information about the purchase…how much the user was charged, what Google thinks they bought, the receipt sent back to the handler…are all correct except (1) the product identifier is wrong and (2) the receipt has multiple purchases in it (which I’m assuming is just an artifact of the Google store, but could be something else).

Interesting, that’s very strange.  I don’t think I’ve seen that myself, but I’ll give it a try again, as that’s something I’d be concerned about.

Out of curiosity, are your products managed or unmanaged?  If you have both kinds, does this issue happen no matter which one you purchase first, or is it only in a particular order?

Also, when you say you’re looking at the information about the second purchase, and it looks right, do you mean in your purchaseHandler function or in your Google Merchant Account?

  • Andrew

All of our products are unmanaged (no managed products). Because of this, we can’t test with managed products…at least not without going through a bunch of extra setup that we wouldn’t end up using.

To the Google Wallet transaction everything looked perfect, there was nothing there that indicated anything strange happened. It had the right product and the right amount of money was charged.

The information I was checking in the purchase handler was specifically the receipt. The transaction id seems to be the same across multiple purchases and each purchase is listed separately in the receipt with a unique order id. I just chalked this up to Google combining things on their end. This seemed okay because in the receipt each separate purchase has a unique order id. I’m not crazy familiar with their purchase system so have no idea of this is normal or not.

Hmm, that may just be Google’s behavior.  I hadn’t noticed it before, but I’ll take a look.  Although in my current project, all my products are managed, which may turn out to be a source of difference.

  • Andrew

Yeah, I’d totally be fine with the transaction id and receipt being the way they are, but it seems completely wrong for me to say “the user is purchasing a shovel” and the handler saying “the user purchased an elephant!”.

So I just tried it myself with two managed products, and everything seemed fine.  I purchased one, then immediately afterwards I purchased the second.  My transaction handler received the right productIdentifier in both cases.  Also, for each purchase, the receipt only contained info for that purchase.  I didn’t see the behavior you’re seeing where multiple orders were shown in the same receipt.

  • Andrew

It’s entirely possible that it’s either just unmanaged products or that our setup is wonky.

I haven’t experienced anything like this.

In your purchaseHandler function, do you call store.finishTransaction() appropriately?  If not, that could explain why you’re seeing the first product come through again.

  • Andrew

Finish transaction is being called appropriately. It’s not that it’s coming through again later or anything like that. The first transaction works fine. Everything about the second transaction is correct except that the product identifier is wrong.

What I mean by everything being correct is that if I look at all the information about the purchase…how much the user was charged, what Google thinks they bought, the receipt sent back to the handler…are all correct except (1) the product identifier is wrong and (2) the receipt has multiple purchases in it (which I’m assuming is just an artifact of the Google store, but could be something else).

Interesting, that’s very strange.  I don’t think I’ve seen that myself, but I’ll give it a try again, as that’s something I’d be concerned about.

Out of curiosity, are your products managed or unmanaged?  If you have both kinds, does this issue happen no matter which one you purchase first, or is it only in a particular order?

Also, when you say you’re looking at the information about the second purchase, and it looks right, do you mean in your purchaseHandler function or in your Google Merchant Account?

  • Andrew

All of our products are unmanaged (no managed products). Because of this, we can’t test with managed products…at least not without going through a bunch of extra setup that we wouldn’t end up using.

To the Google Wallet transaction everything looked perfect, there was nothing there that indicated anything strange happened. It had the right product and the right amount of money was charged.

The information I was checking in the purchase handler was specifically the receipt. The transaction id seems to be the same across multiple purchases and each purchase is listed separately in the receipt with a unique order id. I just chalked this up to Google combining things on their end. This seemed okay because in the receipt each separate purchase has a unique order id. I’m not crazy familiar with their purchase system so have no idea of this is normal or not.

Hmm, that may just be Google’s behavior.  I hadn’t noticed it before, but I’ll take a look.  Although in my current project, all my products are managed, which may turn out to be a source of difference.

  • Andrew

Yeah, I’d totally be fine with the transaction id and receipt being the way they are, but it seems completely wrong for me to say “the user is purchasing a shovel” and the handler saying “the user purchased an elephant!”.

So I just tried it myself with two managed products, and everything seemed fine.  I purchased one, then immediately afterwards I purchased the second.  My transaction handler received the right productIdentifier in both cases.  Also, for each purchase, the receipt only contained info for that purchase.  I didn’t see the behavior you’re seeing where multiple orders were shown in the same receipt.

  • Andrew

It’s entirely possible that it’s either just unmanaged products or that our setup is wonky.