In-App purchase , Cancel the purchase because of long processing time - iphone

I was implementing In-App purchase to my game and its working fine. No problem with the purchases and other stuffs. But today i was stuck at a weird point.
When the user tries to purchase , sometimes it takes more than a minute to get respond from Apple. (Sandbox environment).
What i want to do is just to put a cancel button in an UIAlertView , which will help the user to cancel the whole purchase. So the user can cancel the purchase, if there is a delay in Sandbox respond. How can i do this ?
I already have a UIAlertView which starts with the purchase button click and ends with the SKPaymentTransactionStatePurchased method. I want to add that cancel button to that alertview.
Confused and here is my question in short again ,
But what is the method should be called to cancel the whole In-App processes while it is on the SKPaymentTransactionStatePurchasing state ?

You cant interrupt the request once it sent. You should wait until Apple responds.

Related

Dismiss Google payment sheet

I have unique business logic requirement where I need to cancel or stop user from proceeding with Google pay if timer that is running in the background runs out.
Suppose user clicked Google pay button, then we use
AutoResolveHelper.resolveTask<PaymentData>(futurePayTask, this, LOAD_PAYMENT_DATA_REQUEST_CODE)
This should return onactivityresult if user performs cancel or success but I want to forcefully cancel if timer runs out.
Google sheet open as shown here:
I will post my answer after discussion with official google pay team, they told its not possible, so I myself just put one alert dialog before showing payment sheet informing user to finish transaction within stipulated time

How to gracefully handle "verification required" in in-app purchases

Once in a while I see that the alert appears saying that verification is required to make a purchase.
When user taps "Continue" the AppStore opens the payment information view and after filling in the CVV it redirects user back to the app.
However at this point SKPaymentQueue reports an error saying "Cannot connect to iTunes store". The purchase automatically handles in background then.
This is a production environment and it's really hard to catch and test this kind of event and I am not able to reproduce this kind of scenario in sandbox.
Does anyone know how to gracefully handle this scenario so we don't show an error to the user?

Change Alert Title In In-app-purchase

I am integrating my iPhone app with PayPal. Now I am taking fixed amount of charge for doing this transection. If user clicks on Pay by PayPal i am asking user to first make an In-app purchase. When user is doing transection for the first there won't be any problem.
But when user has already did transection before, it will display message "You have purchased this. Tap OK to download it again for free" with "Cancel" and "OK" buttons.
I think this type of message doesn't make any sense as its not for downloading app, Can i change it to something like "You have done this transection before. Tap Ok to perform next transection" with "Cancel" and "OK" buttons.
Is there any way i can give custom title or do they have any other pre-define messages for this type of transections?
Thanks In advance.
No, there is no way (nor is there a reason for there to be). Furthermore Apple will reject your app if you attempt to use PayPal to purchase an In-App download.

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
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.

In App Purchase finished outside of an iPhone app

I am implementing an in app purchase subscription model.
Let's say I have an iPhone 3 user which starts the whole purchase process from my application and then exits the application only to continue and fill his app store credentials outside of my app until he is done with the purchase.
How can my app know that the transaction was made upon launch?
Also in case I do get this info how can I tell it is not an old purchase for an old subscription period which has already expired?
And last but not least in case the device supports multitasking and the purchase was finished while my app was in the background how will I get notified upon returning to the foreground?
Thanks
Roi
Have you read Apple's Documentation - In App Purchase Programming Guide? I believe it answers all your questions.
The - (void)recordTransaction:(SKPaymentTransaction *)transaction method takes care of most of your pains.
Once you properly implement this method,you would just have to check whether the inApp purchase is done.Rest is taken care of by the payment methods.
Thanks