I've been trying to implement in app purchase into an Ionic app. I'm able to make a purchase using my sanbox user for Android but iOS 11 isn't working. The weird thing is that iOS 11 initially worked but stopped all of a sudden. iOS 8 works fine.
Here is the code but none of the console.logs are appearing in the xCode terminal:
purchase(product: IAPProduct) {
console.log('purchase', product);
this.inAppPurchase.order(product)
.then((p: IAPProduct) => {
console.log('purchase order', JSON.stringify(p));
this.registerHandlersForPurchase(product);
}, e => {
console.log('failed purchase', JSON.stringify(e));
});
}
registerHandlersForPurchase(product: IAPProduct) {
console.log('registered', JSON.stringify(product));
this.inAppPurchase.when(product)
.approved((p: IAPProduct) => {
console.log('approved', JSON.stringify(p));
return p.verify();
}).verified((p: IAPProduct) => p.finish())
.error((error) => {
console.log('approved error', JSON.stringify(error));
});
}
I'm not getting any of the console.logs in the terminal output except for the very first one in the purchase method console.log('purchase', product);. After it hits that line in the code I don't see where it's calling the registerHandlersForPurchase() method. Afterwards I'm only getting the output from the inApp debug logs.
2021-03-09 17:43:39.658915-0500 Test App[4035:851787] purchase [object Object]
2021-03-09 17:43:39.667059-0500 Test App[4035:851787] before error
2021-03-09 17:43:39.669607-0500 Test App[4035:851787] [store.js] DEBUG: state: con.ionic.test.app.ios -> requested
2021-03-09 17:43:39.669832-0500 Test App[4035:851787] [store.js] DEBUG: state: con.ionic.test.app.ios -> requested
2021-03-09 17:43:39.671006-0500 Test App[4035:851787] InAppPurchase[objc]: purchase: About to do IAP
2021-03-09 17:43:39.671069-0500 Test App[4035:851787] InAppPurchase[objc]: purchase with discount ((null), (null), (null), (null), (null)).
2021-03-09 17:43:39.671087-0500 Test App[4035:851787] InAppPurchase[objc]: + discounts API available
2021-03-09 17:43:39.671544-0500 Test App[4035:851787] Found nil parameter when creating SKPaymentDiscount
2021-03-09 17:43:39.671705-0500 Test App[4035:851787] InAppPurchase[objc]: paymentQueue:updatedTransactions: con.ionic.test.app.ios
2021-03-09 17:43:39.671747-0500 Test App[4035:851787] InAppPurchase[objc]: paymentQueue:updatedTransactions: State: PaymentTransactionStatePurchased
2021-03-09 17:43:39.671765-0500 Test App[4035:851787] InAppPurchase[objc]: processTransactionUpdate:withArgs: transactionIdentifier=1000000784140766
2021-03-09 17:43:39.671886-0500 Test App[4035:851787] InAppPurchase[objc]: purchase: About to do IAP
2021-03-09 17:43:39.671905-0500 Test App[4035:851787] InAppPurchase[objc]: purchase with discount ((null), (null), (null), (null), (null)).
2021-03-09 17:43:39.671918-0500 Test App[4035:851787] InAppPurchase[objc]: + discounts API available
2021-03-09 17:43:39.671933-0500 Test App[4035:851787] Found nil parameter when creating SKPaymentDiscount
2021-03-09 17:43:39.672226-0500 Test App[4035:851787] InAppPurchase[objc]: paymentQueue:updatedTransactions: con.ionic.test.app.ios
2021-03-09 17:43:39.672457-0500 Test App[4035:851787] InAppPurchase[objc]: paymentQueue:updatedTransactions: State: PaymentTransactionStatePurchased
2021-03-09 17:43:39.672536-0500 Test App[4035:851787] InAppPurchase[objc]: processTransactionUpdate:withArgs: transactionIdentifier=1000000784140766
2021-03-09 17:43:39.672998-0500 Test App[4035:851787] InAppPurchase[js]: product con.ionic.test.app.ios has a transaction in progress: 1000000784140766
2021-03-09 17:43:39.673123-0500 Test App[4035:851787] InAppPurchase[js]: product con.ionic.test.app.ios has a transaction in progress: 1000000784140766
2021-03-09 17:43:39.674182-0500 Test App[4035:851787] InAppPurchase[js]: loading appStoreReceipt
2021-03-09 17:43:39.674304-0500 Test App[4035:851787] InAppPurchase[objc]: appStoreReceipt:
2021-03-09 17:43:39.679173-0500 Test App[4035:851787] InAppPurchase[js]: loading appStoreReceipt
2021-03-09 17:43:39.679294-0500 Test App[4035:851787] InAppPurchase[objc]: appStoreReceipt:
2021-03-09 17:43:39.680388-0500 Test App[4035:851787] InAppPurchase[js]: infoPlist: con.ionic.test.app,1.0.21,0,????
2021-03-09 17:43:39.680562-0500 Test App[4035:851787] InAppPurchase[js]: infoPlist: con.ionic.test.app,1.0.21,0,????
Again, this is working on Android. It was working on iOS last week then stopped suddenly. I was initially getting a popup in iOS with the completed transaction now I don't know why it isn't working. I haven't found much help looking online because I'm not even getting an error so it's hard to diagnose.
When I click the purchase button nothing happens, I just get the debug logs listed below. I'm not getting any errors at all. Initially I was getting the pop up displaying a successful purchase but now nothing.
I'm testing on a real device...iOS 11
I've been stuck on this for a while now, any help would be greatly appreciated.
plugin I'm using: "cc.fovea.cordova.purchase": "^10.1.1",
Upon further investigation I think this is related to the sandbox user. I tested on a different iOS11 and it worked. So there must be an issue with using the sandbox user multiple times on one device.