0

I'm trying to find the reason, why in app purchase get in .fail state when app is in review, while everything works while testing on my devices, both with my account and sandbox accounts. Here is what I get from apple:

Specifically, your app failed to complete an in-app purchase and displayed an error alert. Please refer to the attached screenshot. Next Steps When validating receipts on your server, your server needs to be able to handle a production-signed app getting its receipts from Apple’s test environment. The recommended approach is for your production server to always validate receipts against the production App Store first. If validation fails with the error code “Sandbox receipt used in production,” you should validate against the test environment instead.

Why they may ask about some receipts validating, there is no such things in most of the tutorials. In apple documentation there is some article about receipts but it is referred to renewable subscriptions. The sentence about "your server" is also not clear, since I don't have own servers as far as I know. Did I miss something ?

here is the code, which leads to alert from their screenshot

 func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
    for transaction:AnyObject in transactions {
        if let trans = transaction as? SKPaymentTransaction {
            switch trans.transactionState {

            case .purchased:
                complete(transaction: transaction as! SKPaymentTransaction)
                break

            case .failed:
                print("failed")
                fail(transaction: transaction as! SKPaymentTransaction) //alert from screenshot fires
                break
            case .restored:
                restore(transaction: transaction as! SKPaymentTransaction)
                break

            default:
                break
            }}}
}
Anton
  • 155
  • 13
  • They are offering you some advice as to why your app may have failed based on what they commonly see; since you are not performing receipt validation this doesn't seem to apply to you. You need to look at the code that leads to the alert that they have shown in the screenshot and post relevant code in your question – Paulw11 Apr 09 '18 at 20:51
  • This is the alert, which I set by myself, which fires when transaction is in .failed state. – Anton Apr 09 '18 at 20:55
  • 1
    Have you used a TestFlight build to try and reproduce the issue? You should check the `error` property of the transaction in the `failed` state for more information on what went wrong. Do you ultimately call `completeTransaction` in both the complete and restore cases? – Paulw11 Apr 09 '18 at 21:36
  • 1
    Also, you shouldn't use the forced downcast of `transaction` as you have already conditionally unwrapped to `trans`. This isn't your problem but it is better style – Paulw11 Apr 09 '18 at 21:38
  • Just FYI, receipt validations can be done locally as well.. Check this answer https://stackoverflow.com/q/19943183/3359906 Also there may be some case where, while debugging your app's build configuration is "Debug", but while sending it to apple it is "Release". You can check with the Release build configuration. – AjinkyaSharma Apr 10 '18 at 01:38
  • I have tried testflight version , again for both accounts: my own and one sandbox tester, again, everything works for me, both through cellular and wifi (apple stressed in their new letter, that it should work on IPv6-only network) – Anton Apr 10 '18 at 06:42
  • Any luck? How did you resolve the issue? I am facing same problem! – aadi53 Apr 28 '20 at 15:16

0 Answers0