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