In my application I have 3 consumable in-app purchases. I have tested them in sandbox environment and they work as expected. I use the SwiftyStoreKit framework for in-app purchases.
The following code is used to perform the purchase.
func purchase(_ purchase: String, quantity: Int = 1, completion: @escaping ((_ result: PurchaseDetails?)->Void)) {
ProgressIndicatorManager.shared.show()
SwiftyStoreKit.purchaseProduct(purchase) { (result) in
ProgressIndicatorManager.shared.dismiss()
if case .success(let purchase) = result {
// Deliver content from server, then:
if purchase.needsFinishTransaction {
SwiftyStoreKit.finishTransaction(purchase.transaction)
}
completion(purchase)
} else {
completion(nil)
}
if let alert = self.alertForPurchaseResult(result) {
self.showAlert(alert)
}
}
}
Once the purchase is completed I verify the receipt.
/// This function is use for verify receipt
/// - Parameters:
/// - purchase: purchase identifier
func verifyPurchase(_ purchase: String, completion: @escaping (VerifyPurchaseResult) -> Void) {
ProgressIndicatorManager.shared.show()
verifyReceipt { result in
ProgressIndicatorManager.shared.dismiss()
switch result {
case .success(let receipt):
let purchaseResult = SwiftyStoreKit.verifyPurchase(
productId: purchase,
inReceipt: receipt)
self.showAlert(self.alertForVerifyPurchase(purchaseResult, productId: purchase))
completion(purchaseResult)
case .error:
self.showAlert(self.alertForVerifyReceipt(result))
}
}
}
In sandbox everything works fine. However, the Apple review team reported that they are getting the error shown in the attached screenshot.
