Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle SKPaymentTransactionStateDeferred?

I'm adding In-App purchase to my app. I have some doubts in this.

How to handle SKPaymentTransactionStateDeferred? Do we need to implement ourselves at this state or Apple will handle this?

If we should implement means how to handle here? How to test with sandbox tester account? Anybody tell me clearly. Thanks in advance.

like image 677
Uday Kumar Eega Avatar asked Feb 10 '17 06:02

Uday Kumar Eega


1 Answers

According to Apple StoreKit document, deferred state is:

The transaction is in the queue, but its final status is pending external action such as Ask to Buy. Update your UI to show the deferred state, and wait for another callback that indicates the final status.

We get transaction deferred state, if user is part of Apple family sharing & family admin enabled ASK TO BUY.

As child user try to purchase in-app product, a request is sent to parent user for approval. Parent user has 24 hours to approve or cancel their child's purchase after the Ask to Buy process has begun. If the parent fails to respond within the 24 hours, the Ask to Buy request is deleted from iTunes Store servers and your app's observer does not receive any notifications.

You should update your UI to reflect this deferred state. Avoid blocking your UI or gameplay while waiting for the transaction to be updated.

In Sandbox environment, we can test deferred state by using SKMutablePayment like:-

let product = SKMutablePayment(product: productDetails)
product.simulatesAskToBuyInSandbox = true //Enable to test deferred state.
SKPaymentQueue.defaultQueue().addPayment(product)

For Information:

iOS 8 introduces Ask to Buy, which lets parents approve any purchases initiated by children, including apps or in-app purchases on the App Store. When a child requests to make a purchase, Ask to Buy will indicate that the app is awaiting the parent’s approval for this purchase by sending the Deferred state.

like image 173
Sagar Thummar Avatar answered Nov 12 '22 08:11

Sagar Thummar