Laxman Rajpurohit
Laxman Rajpurohit

Reputation: 11

Guideline 2.1 - Performance - App Completeness "The purchase identifier was invalid"

All are working fine in TestFlight build but once Apple team is review the application then they are facing issue. and reject the application. could you please help me

We found that your in-app purchase products exhibited one or more bugs which create a poor user experience. Specifically, the app displayed an error when we tapped on $1.99/ Month. Please review the details and resources below and complete the 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.

App Screenshot

App review snapshot

Subscription product is "Waiting for Review", that's why this error coming?

Here is the code

    func purchaseProduct(productName: String,success: @escaping([String: Any]) -> Void,failure: @escaping(String) -> Void) {
        
        
        SwiftyStoreKit.purchaseProduct(productName, atomically: true) { [weak self] result in
            
            switch result {
                
            case .success(let purchase):
                
                let downloads = purchase.transaction.downloads
                
                if !downloads.isEmpty {
                    SwiftyStoreKit.start(downloads)
                }
                
                // fetch content from your server, then:
                if purchase.needsFinishTransaction {
                    SwiftyStoreKit.finishTransaction(purchase.transaction)
                }
                
                print("Purchase Success: \(purchase.productId)")
                self?.verifyPurchaseReceipt(productId: purchase.productId) { (receiptData) in
                    success(receiptData)
                } failure: { (error) in
                    failure(error)
                }
            case .error(let error):
                switch error.code {
                case .unknown:
                    // print("Unknown error. Please contact support")
                    failure("Unknown error. Please contact support")
                case .clientInvalid:
                    // print("Not allowed to make the payment")
                    failure("Not allowed to make the payment")
                case .paymentCancelled:
//                    Utility.hideIndicator()
                    failure("Cancel payment")
                    break
                case .paymentInvalid:
                    // print("The purchase identifier was invalid")
                    failure("The purchase identifier was invalid")
                case .paymentNotAllowed:
                    // print("The device is not allowed to make the payment")
                    failure("The device is not allowed to make the payment")
                case .storeProductNotAvailable:
                    // print("The product is not available in the current storefront")
                    failure("The product is not available in the current storefront")
                case .cloudServicePermissionDenied:
                    // print("Access to cloud service information is not allowed")
                    failure("Access to cloud service information is not allowed")
                case .cloudServiceNetworkConnectionFailed:
                    // print("Could not connect to the network")
                    failure("Could not connect to the network")
                case .cloudServiceRevoked:
                    // print("User has revoked permission to use this cloud service")
                    failure("User has revoked permission to use this cloud service")
                default:
                    // print((error as NSError).localizedDescription)
                    failure((error as NSError).localizedDescription)
                }
            }
        }
    }

Upvotes: 0

Views: 73

Answers (0)

Related Questions