cordova-plugin-purchase
cordova-plugin-purchase copied to clipboard
[iOS] Interrupted payments are not completed causing "UNKNOWN ERROR"
system info
Capacitor 2.4.7
Device: iPhone XS Max, iOS 14.8
Plugin Version: 10.6.1
Expected behavior
Once in a while, the payment flow is interrupted by something from the App Store such as:
- Credit card details must be updated
- Terms & Conditions of the App Store changed
- User's address must be updated
This payment flow was untestable for a long time in the Sandbox environment. It could only be observed in rare cases in production. Apple Sandbox now offers a flag for sandbox users, which simulates the interrupted payment flow: https://developer.apple.com/documentation/storekit/original_api_for_in-app_purchase/testing_in-app_purchases_with_sandbox/testing_an_interrupted_purchase
Expected behavior: If the payment flow is interrupted by additional steps (like accepting the Terms & Conditions of the App Store), the payment should still complete after the additional steps are completed. It should not end in UNKNOWN_ERROR.
The docs linked above explain in detail how the process can be tested and which events need to be checked. It seems that it is actually correct that the current transactions fails at first, but is then updated. This update step is not caught by cordova-plugin-purchase.
I tested this with consumable IAPs on iOS. I'm not sure if subscriptions or non-consumables trigger the same error.
Observed behavior
What actually happens is that the payment stops with an unknown error after accepting the changed Terms & Conditions
<SKPaymentQueue: 0x283e5d4f0>: Payment completed with error: Error Domain=ASDServerErrorDomain Code=3038 "Die allgemeinen Geschäftsbedingungen der Apple-Mediendienste haben sich geändert." UserInfo={NSLocalizedDescription=Die allgemeinen Geschäftsbedingungen der Apple-Mediendienste haben sich geändert.}
Steps to reproduce
- Create a Sandbox user via App Store Connect.
- Assign flag "Interrupted Purchase" (note: you have to re-asign the flag after the user agreed to the fake new Terms of Service)
- Buy an item, complete the purchase flow.
Additional note
This error is affecting the older cordova-plugin-inapppurchase as well. If I recall correctly, cordova-plugin-purchase used the old RMStore library, too. I think the bug has been around forever and was never fixed. The only difference is that this plugin has a queue of unprocessed payments, which loads whenever the store reloads. However, the optimal behavior would be if the payment was processed instantly, because it confuses users and causes double payments.