In this post, you will learn how to test your cordova application with using cordova InAppPurchase. You can test the purchasing with both android and iOS platforms. You need to have android and iOS devices to test it.
Testing on Android:
To test inAppPurchase on android, you need to follow these steps:
Go to Google Play console and add the products which you want to buy in your application and also put them on active mode.
After adding products, you should publish your apk file. It must be a signed apk file and you can publish it on alpha or beta testing. It will take few hours to publish the app.
You need to add email address to test the purchasing. You have to add the email address by going into "Settings > Account Details > License Testing”. Make sure this email account is open on your android device while testing the application. You can choose open beta testing or closed beta testing to test purchasing.
In open beta testing, you have to visit an opt-in-link to test the app. In closed beta testing, you have to create a google group in which you can add testers.
One thing you have to do in your code: add a manifest.json file in your www folder and put android billing key inside it. You can get it from Google play store after uploading app.
Now you can test for purchasing products without being charges in your application. You will also get email for each purchase you do from google with the receipt of your order.
Testing on iOS:
In iOS, to test inAppPurchase, you need to have sandbox tester account and you can use it to test for purchases in your application. You have to follow these steps:
First, you have to add all the products you want to sale on iTunes connect.
For testing the purchase of products you need to create sandbox tester account. You can see the guidelines to create this account here.
After creating sandbox tester account, then if you are logged in iTunes on your device, you have to logout. When you will make a purchase from app it will ask for email address and password, enter the credentials, the transaction will be done without any charges.