StoreKit 2 and its receipt verification

Hey folks! One of my customers has problem when purchasing the in-app subscription:

The operation couldn't be completed (StoreKit.VerificationResult<StoreKit.Transaction>.VerificationError error 2.)

Any idea why this happens? I'm using the standard purchase verification

private func checkVerified<T>(_ result: VerificationResult<T>) throws -> T {

    //Check if the transaction passes StoreKit verification.

    switch result {

    case let .unverified(_, error):

        //StoreKit has parsed the JWS but failed verification. Don't deliver content to the user.

        throw error

    case .verified(let safe):

        //If the transaction is verified, unwrap and return it.

        return safe

    }

}

This error is invalidDeviceVerification. This error can be thrown when the deviceVerification on the transaction doesn't match what is on the device. You can see how to perform this verification yourself here: https://developer.apple.com/documentation/storekit/transaction/3749690-deviceverification and perhaps you can log if that is causing the issue.

The other way this can be thrown is if part of the above verification fails or returns nil. For example, if AppStore.deviceVerificationID returns nil, this error can be thrown, because StoreKit can't use it to verify. This can be nil sometimes, e.g. after the device has been restarted but before the user has unlocked the device (although that doesn't seem to be the case here).

I'd recommend logging those details for more information. If the customer is willing to get a sysdiagnose from their device, you can also file a Feedback and attach the sysdiagnose and the StoreKit team can try to assess what is going on. Instructions for sysdiagnoses are here, under App Store: https://developer.apple.com/bug-reporting/profiles-and-logs/

StoreKit 2 and its receipt verification
 
 
Q