I have had to update my in app purchase functionality, due to google billing forced updates, and am such using v13 of cordova-plugin-purchase.
I simply cannot get this to work or even return anything.
My current code:
import 'cordova-plugin-purchase';
const { store, ProductType, Platform } = CdvPurchase;
const iaptic = new CdvPurchase.Iaptic({
appName: "com.app",
apiKey: "XXX-XXX-XXX",
});
store.validator = iaptic.validator;
document.addEventListener("deviceready", function(){
store.register([
{
id: "monthly",
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.GOOGLE_PLAY,
}, {
id: "annual",
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.GOOGLE_PLAY,
}, {
id: "quarterly",
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.GOOGLE_PLAY,
}
])
store.initialize();
}, false);
const purchaseProduct = () => {
const product = store.get('monthly', Platform.GOOGLE_PLAY);
console.log("PRODUCT: ", product)
}
Button onclick is purchaseProduct ... in the console for Android, all I get is
Msg: PRODUCT: undefined
As I am running 3 subscription products, I am trying to call the purchase when the click is made on the appropriate button - but again it is not doing anything.
Clearly I am missing something - can anyone assist?
I've run into the same issue, so I'm not certain how much this will help but it appears that a Google Play Service account maybe needed for the iaptic API. Per iaptic, the service account is needed for their servers to communicate with Google. Although, Google states that "The API access page has gone away", here are a couple links that may help:
https://developers.google.com/android-publisher/getting_started#service-account https://www.iaptic.com/documentation/setup/connect-with-google-publisher-api
I'm currently trying the above and waiting 24 hours, per iaptic to see if it will work.
HTH