Testing of In-app Purchases in Huawei can be achieved in the Sandbox environment and configuring test accounts in AppGallery Connect.
How to prepare for Sandbox testing
Sandbox testing involves the following procedure:
Creating Test accounts
Sign in to AppGallery Connect and click Users and permissions
Go to Sandbox > Test accounts and click Add
Enter your test account information and click OK
Please note that a test account must be a registered HUAWEI ID. And the account takes 30mins to 1 hr to be added.
2. Set up a sandbox testing version
If the app package was never released in AppGallery Connect, its versionCode should be greater than 0.
If the app package once released in AppGallery Connect, its versionCode of the package to be tested must be greater than that of the released one.
Testing non-subscription payments
Once you have initiated a request to purchase a one-time product using a test account and installed the app to be tested, HUAWEI IAP detects that the user is a test user, skips the payment step, and displays a message saying that the payment is successful.
Sandbox testing purchase process is similar to the production environment.
In case the HMS Core (APK) version is earlier than 22.214.171.1240, once a one-time purchase order is created in the sandbox environment, its payment has been completed. The purchase is successful even if you cancel the payment.
In order to test a non-consumable product in the sandbox testing environment, you can purchase them, consume them, and then purchase another.
When you checkout in the sandbox testing scenario, a dialog box with a sandbox icon is displayed. It appears on both the checkout screen and the successful purchase screen.
Testing Subscription Renewal
The subscription renewal process is similar to that of the one time purchase. The major difference between an auto-renewing subscription and one time purchase is that Subscription renewal have renewal result(success or failure) and period.
Test subscriptions renew much faster than actual subscriptions. For instance, for an actual subscription period of one week, the test subscription will renew every three minutes.
To test a subscription, you have to sign a contract and add a bank card. You will not be charged in the test environment.
During the auto-renewal process, no real-time payment will happen. However, HUAWEI IAP directly returns a billing success.
In the Sandbox testing environment, the subscription purchased will be renewed five times and then it will be canceled. If required, the user has to manually resume the subscription. After this, resume operation only one subscription period work, and no recurring will happen.
When you check out in the Sandbox testing scenario, a dialog box with a Sandbox icon is displayed. It appears on both the checkout screen and the successful purchase screen.
Please note if you didn't see a Sandbox test screen during your purchase process, the transaction is not involved in the sandbox testing. If you continue the test, real payments will be made.