Amazon IAP v2: transactionCallback being called twice after purchase

Hello, 

Question 1: I’m currently testing Amazon IAP for one of my products using the Amazon App Tester. I’ve noticed that when I purchase a product my transactionCallback gets called twice. I was just curious as to if this is normal behavior or not. I can’t figure out why it’s not being called just once.

Question 2: Any idea what else might be triggering a second call to the transactionCallback?

Question 3: What’s the range of things that trigger the transactionCallback other than a store.init, store.purchase, and store.restore?

Thank you!

When I hear “getting called twice” is I first think that a button is being used with multiple events but the function that handles the button press is actually not setup to be called twice.

Can you post your button creation code and the function that triggers when the button is pressed?

Are your transactions the same? What are the two transactions you’re getting?

Those are the only things that can cause it with the exception of a refund condition, though I through I saw that Amazon got rid of the revoked transaction. But regardless I think a restore is required to get those.

When I hear “getting called twice” is I first think that a button is being used with multiple events but the function that handles the button press is actually not setup to be called twice.

I thought that might be the case, too. But I double-checked my code and checked the log and we are not calling it twice within our code. In fact, I rolled back to Amazon IAP v1 (by only changing the build.settings requirements) and checked the log and the transactionCallback is only called once. Therefore, this is happening specifically with Amazon IAP v2.

Are your transactions the same? What are the two transactions you’re getting?

In both transactions, I am getting transactions that return a “purchased” state.

Those are the only things that can cause it with the exception of a refund condition, though I through I saw that Amazon got rid of the revoked transaction.

Thanks for the answer.

What are your thoughts on this only happening when using Amazon IAP v2? Is this something that can be looked at on Corona’s end?

I’m checking with an Engineer.

Thanks @Rob Miracle

@jhow, hi. There are two things in the plugin that can trigger the storeTransaction event.
One of them is the actual purchase response and the other one is updates receiver that is used for store.restore().
Also I know that App Tester can misbehave. Can you please try two things:

  1. Do you call store.restore() before seeing this behaviour? If so, what happens if you don’t?
  2. Check the purchases using Live App Testing instead of App Tester.

 https://developer.amazon.com/public/resources/development-tools/live-app-testing

Thanks,

Sergey

@Lerg,

  1. Do you call store.restore() before seeing this behaviour? If so, what happens if you don’t?

No, I am not calling _ store.restore _. Only _ store.init _ upon app start and _ store.purchase _ upon user purchase.

Currently looking into Live App Testing.

Jeff

Hi @Lerg,

  1. Check the purchases using Live App Testing instead of App Tester.

Tried is using the Live App Tester. It appears as though it’s only being called once now. Should I assume that this is the expected behavior and that the App Tester has the incorrect behavior?

Is this something that should be brought up with Amazon?

Thank you!

Jeff

Hi Jeff,

App Tester is not 100% accurate, Live App Testing is much closer to reality, so yes, you can assume it as the correct behavior. But always be prepared for unexpected transactions, for the case if the transaction was interrupted or just Amazon decides to send it again for some reason.

Thanks,

Sergey

When I hear “getting called twice” is I first think that a button is being used with multiple events but the function that handles the button press is actually not setup to be called twice.

Can you post your button creation code and the function that triggers when the button is pressed?

Are your transactions the same? What are the two transactions you’re getting?

Those are the only things that can cause it with the exception of a refund condition, though I through I saw that Amazon got rid of the revoked transaction. But regardless I think a restore is required to get those.

When I hear “getting called twice” is I first think that a button is being used with multiple events but the function that handles the button press is actually not setup to be called twice.

I thought that might be the case, too. But I double-checked my code and checked the log and we are not calling it twice within our code. In fact, I rolled back to Amazon IAP v1 (by only changing the build.settings requirements) and checked the log and the transactionCallback is only called once. Therefore, this is happening specifically with Amazon IAP v2.

Are your transactions the same? What are the two transactions you’re getting?

In both transactions, I am getting transactions that return a “purchased” state.

Those are the only things that can cause it with the exception of a refund condition, though I through I saw that Amazon got rid of the revoked transaction.

Thanks for the answer.

What are your thoughts on this only happening when using Amazon IAP v2? Is this something that can be looked at on Corona’s end?

I’m checking with an Engineer.

Thanks @Rob Miracle

@jhow, hi. There are two things in the plugin that can trigger the storeTransaction event.
One of them is the actual purchase response and the other one is updates receiver that is used for store.restore().
Also I know that App Tester can misbehave. Can you please try two things:

  1. Do you call store.restore() before seeing this behaviour? If so, what happens if you don’t?
  2. Check the purchases using Live App Testing instead of App Tester.

 https://developer.amazon.com/public/resources/development-tools/live-app-testing

Thanks,

Sergey

@Lerg,

  1. Do you call store.restore() before seeing this behaviour? If so, what happens if you don’t?

No, I am not calling _ store.restore _. Only _ store.init _ upon app start and _ store.purchase _ upon user purchase.

Currently looking into Live App Testing.

Jeff

Hi @Lerg,

  1. Check the purchases using Live App Testing instead of App Tester.

Tried is using the Live App Tester. It appears as though it’s only being called once now. Should I assume that this is the expected behavior and that the App Tester has the incorrect behavior?

Is this something that should be brought up with Amazon?

Thank you!

Jeff

Hi Jeff,

App Tester is not 100% accurate, Live App Testing is much closer to reality, so yes, you can assume it as the correct behavior. But always be prepared for unexpected transactions, for the case if the transaction was interrupted or just Amazon decides to send it again for some reason.

Thanks,

Sergey