11

I am following the steps for testing interrupted in-app purchases, as outline in the Apple docs here under the header Test an Interrupted Purchase. My problem starts on step 6., which states:

"In your code, observe that the payment fails. The payment queue receives an updated transaction in the state SKPaymentTransactionState.failed."

This works for me, but the failed state triggers my UI to show an error alert saying that the payment failed, even though it's just gearing up to show the Terms & Conditions page.

Is there a way to detect when a transaction has actually failed, versus when it's just being put on pause to let some other action take place? I would have expected that the SKPaymentTransactionState state here be deferred instead of failed, as that would make it much easier to handle appropriately.

Grambo
  • 887
  • 8
  • 25
  • Would love an answer to this. We have decided to ignore `SKError.unknown` in our app since this seems to be the error for interrupted purchases. The `SKError.unknown` error also has an `NSUnderlyingError`. Typically this gives more information about the cause. Unfortunately, I haven't found a list underlying errors that relate to interrupted purchases. Without this information it's difficult to ignore only interrupted purchase errors. – Gary Kerr Jan 21 '21 at 13:46
  • @GaryKerr Be careful with ignoring `SKError.unknown`. If a user accepts the agreement you will receive this transaction again with `.purchased` status, but if they tap cancel - there won't be any more updates on this transaction. – Alexander Vasenin Mar 06 '21 at 05:49
  • 3
    This gives a clue _why_ this `.failed` state happens, but not a solution https://developer.apple.com/forums/thread/653144?answerId=620952022#620952022 – Alexander Vasenin Mar 06 '21 at 06:02
  • @Alexander have you figured out a solution for this? – ZN123 May 24 '21 at 16:50
  • @ZN123 Not really – Alexander Vasenin May 25 '21 at 02:38
  • @Alexander How do you handle UI for the user? Ignore failed if error code is 3038, keep the loader, and wait for successful transaction (if user doesn't accept, loader stays forever), or show failed, then success if user agrees to T&C. My only idea here is showing loader, and putting timeout on it, but that's very hacky. – ZN123 May 25 '21 at 12:29
  • @ZN123 It seems like there is no way to know if it would be called second time, but if it will be - it will be very soon, so the spinner isn't really needed there. – Alexander Vasenin May 26 '21 at 10:50
  • @AlexanderVasenin the ```.purchase``` status, does it come automatically once the user taps ```agree``` on the T&C? I tried and it doesn't (see this SO https://stackoverflow.com/q/70436152/14414215). item #10 on Apple's list doesn't come up UNTIL user either closes the app and restart or press Home and Relaunches the app, then it will work. – app4g Dec 22 '21 at 00:40
  • 1
    @app4g Unfortunately this issue was related to an old iteration of the project which is now defunct, so I have no idea how to help you, sorry – Alexander Vasenin Dec 22 '21 at 21:04

0 Answers0