We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
GuidesIn-App PurchasesOrder and Subscription ServicesSandbox Testing

Sandbox Testing

Sandbox testing allows you to complete end-to-end testing without real payments when you connect to HUAWEI IAP for joint debugging. You can configure test accounts in AppGallery Connect and allow these testers to perform sandbox testing.

NOTE

Currently, the sandbox testing supports the app integrated with HMS Core SDK 3.0 or later, and the to-be-tested device must be installed with HMS Core (APK) 3.0 or later. If the payment API of HMS Core SDK 2.0 is used for testing, real payments will be made.

Preparing for Sandbox Testing

  • Configure test accounts.

    Add test accounts, which are real HUAWEI IDs, under Users and permissions in AppGallery Connect. For details, please refer to Sandbox Testing.

    NOTE

    The account for sandbox testing takes effect 30 minutes to 1 hour after being added. Check whether the current account can be used in the sandbox testing.

  • Configure a sandbox testing version.

    If the app package you want to test has never been released in AppGallery Connect, make sure that its versionCode is greater than 0. For an app package once released in AppGallery Connect, the versionCode of the package to be tested must be greater than that of the released one.

Troubleshooting Sandbox Access Issues

If you fail to access the sandbox, please refer to Preparing for Sandbox Testing to check whether:

  • Your test account has been added in AppGallery Connect
  • The app version meets the requirement

Besides, you can also use the IapClient.isSandboxActivated or HMSIAP.isSandboxActivated API in your app for troubleshooting.

Testing Non-subscription Payments

You can sign in using a configured test account, and install the app to be tested. When a request is initiated to purchase a one-time product, HUAWEI IAP detects that the user is a test user, skips the payment step, and displays a message indicating that the payment is successful.

  • The purchase process in the sandbox testing environment is the same as that in the official environment.
  • The receipt information generated in HUAWEI IAP contains the purchaseType field which has a value 0, indicating that the purchase is a sandbox testing record.
  • When the HMS Core (APK) version is earlier than 4.0.2.300, 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 the sandbox testing environment, to facilitate testing, you can purchase a non-consumable product, consume it, and then purchase another.
  • When the checkout screen is opened in the sandbox testing scenario, a dialog box with a sandbox icon is displayed. A sandbox icon is displayed on both the checkout screen and the successful purchase screen.
    NOTE

    If no screen shown in the preceding figure is displayed, the transaction is not involved in the sandbox testing. If you continue the test, real payments will be made. Check whether the two conditions of the sandbox testing are met. You can also use the IapClient.isSandboxActivated or HMSIAP.isSandboxActivated API to check whether the sandbox environment is available.

    Sandbox testing for non-subscription on a phone:

    Sandbox testing for non-subscription on a HUAWEI Vision:

Testing Subscription Renewal

The purchase process of subscriptions is similar to that of one-time products. The only difference is that subscriptions have more details to consider, such as the subscription renewal result (successful or failed) and subscription period. Test subscriptions renew much faster than actual subscriptions. For example, the actual subscription period is 1 week, while the test subscription will renew every 3 minutes.

Expand

Real Time

Test Time

1 week

3 minutes

30 days/31 days

3 minutes

1 month

5 minutes

2 months

10 minutes

3 months

15 minutes

6 months

30 minutes

1 year

1 hour

  • To purchase a subscription, you need to sign a contract and add a bank card, but you will not be charged.
  • In the sandbox testing environment, the payType parameter has a fixed value of 0.
  • No real payments will happen during auto-renewal processing. Instead, HUAWEI IAP directly returns a billing success.
  • In the sandbox testing environment, a subscription, after purchased, will automatically renew five times later and then is canceled. The user needs to manually resume the subscription, if necessary. Note, however, that this resume operation only makes one subscription period work, and no recurring will happen. Simply, after five times, the user will get only one subscription period by each resume operation.
  • When the checkout screen is opened in the sandbox testing scenario, a dialog box with a sandbox icon is displayed. A sandbox icon is displayed on both the checkout screen and the successful purchase screen.
    NOTE

    If no screen shown in the preceding figure is displayed, the transaction is not involved in the sandbox testing. If you continue the test, real payments will be made. Check whether the two conditions of the sandbox testing are met. You can also use the IapClient.isSandboxActivated or HMSIAP.isSandboxActivated API to check whether the sandbox environment is available.

    Sandbox testing for subscription on a phone:

    Sandbox testing for subscription on a HUAWEI Vision:

Search in Guides
Enter a keyword.