j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.3k stars 537 forks source link

Purchase on iOS creates Transaction with NULL ID #1595

Closed selcukbeyhan closed 1 month ago

selcukbeyhan commented 1 month ago

Hello,

Observed behavior

Due to some reason, the purchase in iOS fails. This can be seen in the logs. However, the plugin still creates transaction with ID null. Here are the logs: ⚡️ [log] - AppComponent.appStateChange App is in background <SKPaymentQueue: 0x301700740>: Payment completed with error: Error Domain=ASDErrorDomain Code=825 "No transactions in response" UserInfo={NSDebugDescription=No transactions in response} [CdvPurchase.AppleAppStore.objc] paymentQueue:updatedTransactions: 1_MONTHLY_SUBSCRIPTION [CdvPurchase.AppleAppStore.objc] paymentQueue:updatedTransactions: Error ERR_UNKNOWN - An unknown error occurred [CdvPurchase.AppleAppStore.objc] paymentQueue:updatedTransactions: State: PaymentTransactionStateFailed [CdvPurchase.AppleAppStore.objc] processTransactionUpdate:withArgs: transactionIdentifier= [CdvPurchase.AppleAppStore.objc] transactionFinished: (null) ⚡️ [log] - [CdvPurchase.AppleAppStore.Bridge] DEBUG: transaction updated: state:PaymentTransactionStateFailed product: 1_MONTHLY_SUBSCRIPTION ⚡️ [log] - [CdvPurchase.AppleAppStore] INFO: purchaseFailed: 1_MONTHLY_SUBSCRIPTION - 6777010 - An unknown error occurred ⚡️ [log] - [CdvPurchase.AdapterListener] DEBUG: receiptsUpdated: [{"className":"Receipt","transactions":[],"platform":"ios-appstore"}] ⚡️ [log] - [CdvPurchase.AppleAppStore] INFO: order.paymentMonitor => failed
⚡️ [error] - [CdvPurchase.AppleAppStore] ERROR: ERROR: 6777010 - An unknown error occurred ⚡️ [error] - [CdvPurchase.AppleAppStore] ERROR: error@user-script:23:268:32 error@user-script:23:2786:43 protectCall@user-script:23:3313:35 transactionUpdated@user-script:23:3604:40 @capacitor://localhost/tabs/tab2/subscriptions:1:107 @user-script:19:1133:13 @user-script:19:1157:52 global code@capacitor://localhost/tabs/tab2/subscriptions:1:55 ⚡️ [log] - [CdvPurchase.AppleAppStore.Bridge] DEBUG: transaction updated:null state:PaymentTransactionStateFinished product: 1_MONTHLY_SUBSCRIPTION ⚡️ [log] - [CdvPurchase.AppleAppStore] INFO: finish: null - 1_MONTHLY_SUBSCRIPTION ⚡️ [log] - [CdvPurchase.AppleAppStore] DEBUG: initializeAppReceipt() => already initialized. ⚡️ [log] - [CdvPurchase] DEBUG: Calling callback: type=receiptUpdated() name=#1d53a9305f88953ecf8f2faa422be7ba reason=adapterListener_receiptsUpdated ⚡️ [log] - LOGPREFIX - Subscription: -store.when.receiptUpdated- Receipt is updated ⚡️ [log] - [CdvPurchase] INFO: verify(Receipt) ⚡️ [log] - [CdvPurchase.Validator] DEBUG: Schedule validation: {"className":"Receipt","transactions":[],"platform":"ios-appstore"} ⚡️ [log] - [CdvPurchase.Validator] DEBUG: Validation requests=4 responses=3 ⚡️ [log] - [CdvPurchase] DEBUG: Calling callback: type=error() name=#aec0d00b55218e72881719bcf4567a54 reason=triggerError ⚡️ [log] - LOGPREFIX - Subscription: -store.error- ERROR happened during processing: 6777010: {"isError":true,"code":6777010,"message":"An unknown error occurred","platform":"ios-appstore","productId":"1_MONTHLY_SUBSCRIPTION"} ⚡️ [log] - [CdvPurchase.Validator] DEBUG: Validation requests=4 responses=4 ⚡️ TO JS {"isActive":true} ⚡️ [log] - AppComponent.appStateChange App is in foreground ⚡️ To Native -> App getState 117748978 ⚡️ TO JS {"isActive":true} ⚡️ [log] - AppComponent.appStateChange AppState: {"isActive":true} ⚡️ [log] - AppComponent.appStateChange Nowhere to navigate ⚡️ [log] - [CdvPurchase.AppleAppStore] DEBUG: receipt updated and ready. ⚡️ [log] - [CdvPurchase.AdapterListener] DEBUG: receiptsUpdated: [{"className":"Receipt","transactions":[{"className":"Transaction","transactionId":"appstore.application","state":"approved","products":[{"id":"com.mycompany.id"}],"platform":"ios-appstore"},{"className":"Transaction","transactionId":null,"state":"finished","products":[{"id":"1_MONTHLY_SUBSCRIPTION"}],"platform":"ios-appstore"}],"platform":"ios-appstore","nativeData":{"appStoreReceipt":"MIItFwYJKoZIhvcNAQcCoIItCDCCLQQCAQExDzANBglghkgBZQMEAgEFADCCHE0GCSqGSIb3DQEHAaCCHD4Eghw6MYIcNj ......

Is this expected or a bug? What should we do?

Thank you.

j3k0 commented 1 month ago

There's probably an issue with your AppStore settings:

Also I notice that there is an exception thrown in one of your scripts. error@user-script:23:268:32 This call is nested in protectCall which is a function the plugin uses to wrap user-provided callbacks. You should check if your "error" function is throwing some errors (it could be good practice to have your own try/catch blocks in your callbacks)

selcukbeyhan commented 1 month ago

my settings look ok because this issue doesnt happen often. However, the stacktrace in the exception refers to the function "transactionUpdated". this is part of this plugin. (similarly order.payment Monitor as above)