Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In App Purchase user cancels tx while app in background: tx state stays on purchasing

I have some odd behavior with User canceling in App Purchase (Sandbox Environment) while the app is in background and the user is not yet logged in to the store:

The process is as follows:

  • User is not logged in/App Id is not set in Settings > Store
  • User clicks buy button. This calls [[SKPaymentQueue defaultQueue] addPayment:payment];
  • User immediatly preses home button (app goes to background)
  • Storekit popup appears asking to confirm purchase. User cancels
  • App is activated again and would expect to recieve - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions, but does not. The TX is still in state purchasing.

This process is different, if the testuser is logged in to the store already. In that case the above process works as expected.

Another remark: After the above steps, I actually buy another in-App item (inlcuding logging in to the appstore). After this I sent the app to backgrounding and reactivate it and it will process the fomerly missing cancel transaction.

Conclusion: A user canceling a payment tx while the app is in background and not being logged in to the store results in late delivery of the storekit callback. Delivery is done after the user actually logged in to the appstore and the PaymentQueue process gets triggered by reactivating the app.

This behavior seems to be wrong and if it is actually like that in real environment, I might consider this a Storekit bug. Has someone experienced the same behavior or can indicate something to prevent a tx "hanging" in purchasing state?

Thanks, Marcus

like image 580
marcus Avatar asked Jun 10 '11 19:06

marcus


People also ask

What does it mean when an app say in-app purchases?

With some apps, you can buy additional content or services within the app. We call these "in-app purchases." Here are some examples of in-app purchases: A sword that gives you more power in a game.

Does in-app purchases mean free?

An in-app purchase is any fee an app may ask for. Many in-app purchases are optional or give users additional features. Others serve as subscriptions and require users to sign up and pay a fee to use the app – often after an initial free trial.


1 Answers

I don't believe you can count on ANYTHING when it comes to Store Kit. Rather than "waiting expectantly" for the transaction to be queued after the "Buy" button is pressed, just go on about your business. When you are notified that there are transactions (which could be tomorrow) process them. I believe there's a comment to this effect in the documentation -- that your app should register for SK notifications when it's launched and it should expect to get them at any time. So don't build any awareness of "state" into your app when it comes to Store Kit. Just process the transactions as they arrive.

like image 55
Craig Avatar answered Oct 05 '22 04:10

Craig