I have written series of article on Quick App. If you are new to Quick App refer my previous articles.
Quick App set up
A Novice Journey Towards Quick App ( Part 2 )
A Novice Journey Towards Quick App ( Part 3 )
Introduction
In App Purchase makes user to make online payment. In order make online payment in quick app let’s see how to integrate the IAP in Quick App.
Follow the steps
Step 1: Sign in to AppGallery Connect and select My projects.
Step 2: Select the project which you need to enable the service.
Step 3: Click the Manage API tab, Enable In-App purchase.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Above screen will show when Merchant service is not enabled. If you don’t have Merchant account follow the Enable Merchant service.
Step 4: Sign in to HUAWEI Developer. Click Console.
Step 5: Click App Services in the navigation bar on the left and select HUAWEI IAP.
Step 6: From the product list, find the app for which the HUAWEI IAP service will be configured. Then, click Update.
Step 7: Configure HUAWEI IAP service information.
Callback Address: can be modified after configuration. Ensure that the app's callback address can be visited. The value can contain a maximum of 255 characters and cannot end with a backslash (\). The callback address can be a multi-level domain name, where special characters such as underscores(_) cannot be contained. Note that callback address is not required for apps without a server.
Signed Certificate: Navigate to Tools > Certificate
Make sure you copy the generated certificates to sign > debug folder from the release folder.
Step 8: After completing the configuration, click Next, and then Submit.
Enable Merchant service
We need to be a merchant to make use of In-App Purchase in Quick App.
Note: Once your account becomes merchant, it takes 2-3 business day for verification.
Follow steps to enable merchant service
Step 1: Sign in to HUAWEI Developer. Click Console.
Step 2: In Settings, you will find Merchant Service as shown below.
Step 3: Enter the details in Bank information, as shown below.
Step 4: Enter details in Tax information node, as shown below.
Step 5: Click Submit to save the record for verification.
Create test account
Need sandbox account to test the IAP in quick App. During application development and testing we can use the sandbox account to make payment. During the testing period, when a purchase is initiated by the test account, the Huawei IAP server will identify the test account and directly process a successful payment, without real payments made.
Follow the steps to enable the sandbox account
Step 1: Navigate to AGC and select users and permissions.
Step 2: Select Test account, as shown below.
Step 3: Click Add button to add Test account, as shown below.
Huawei In-App purchase information
1. Sign in to HUAWEI Developer. Click Console.
2. Click App Services in the navigation bar on the left and select HUAWEI IAP.
3. Click the quick app for which HUAWEI IAP Service has been configured.
4. Find HUAWEI IAP Service parameters in the Service Info section.
APP ID: unique ID assigned by HUAWEI Developer to an app. Please store it properly for future use.
Payment ID: Used to configure the merchantId parameter in the development process.
Private key: RSA private key, used to sign the requested parameters when a developer's app invokes HMS SDK payment method.
Public key: RSA public key, used to verify the signature when a developer's app receives payment results from HMS SDK.
Result
Coming soon in next article.
Conclusion
In this article, we have learnt how integrate IAP in Quick App. In upcoming article I will continue the IAP adding products and product details and making payment online.
Reference
In-App Purchase official document
Do we need to be enterprise developer in order to work with HMS IAP ?
Related
This article is originally from HUAWEI Developer Forum
Forum link: https://forums.developer.huawei.com/forumPortal/en/home
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Back in the 90’s, it was a revolutionary to have your own website and putting an advertisement in the website was the only source of revenue. But today as space matures, it’s essential for brands to have a clear strategy to monetize their mobile presence. Some companies charge their users before downloading their apps. Others depend on in-app advertising as their sole revenue stream. But, for a lot of brands, their mobile monetization strategy relies entirely (or some part) on In App Purchase. To summarise, when a customer spends money within a mobile app, that’s an in-app purchase.
To make easier for users to make payments and developers to focus solely on app innovation, Huawei provided us with an extraordinary kit i.e. HMS Core In App Purchase (IAP) Kit.
HMS In App Purchase helps developers in variety of situation to earn revenue such as paying for access to a dating app’s special features, subscribing to a streaming music app’s premium tier, buying more gold bars in games etc.
DEMO
Check out the demo created by me to make you understand, How HMS Core In App Purchase works.
Today, in this article we are going to see how to integrate HMS In App Purchase in a simple yet complex Quiz Game app. To be honest everything can’t be covered in a single article. So, I have prepared a sample project and will provided the code on Github soon. I also tried making it simple as much as possible so that every beginner can understand it.
Settings Needed
1) First we need to create an app or project in the Huawei app gallery connect.
2) Provide the SHA Key and App Package name of the android project in App Information Section.
3) Provide storage location in convention section under project setting.
4) Enable In-App Purchase setting in Manage APIs section.
5) After completing all the above points we need to download the agconnect-services.json from App Information Section. Copy and paste the json file in the app folder of the android project.
6) Copy and paste the below maven url inside the repositories of buildscript and allprojects respectively (project build.gradle file)
Code:
maven { url 'http://developer.huawei.com/repo/' }
7) Copy and paste the below class path inside the dependency section of project build.gradle file.
Code:
classpath 'com.huawei.agconnect:agcp:1.3.1.300'
8) Copy and paste the below plugin in the app build.gradle file
Code:
apply plugin: 'com.huawei.agconnect'
9) Copy and paste below library in the app build.gradle file dependencies section.implementation 'com.huawei.hms:iap:4.0.2.300'
10) Put the below permission in AndroidManifest file.
Code:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
11) Now Sync the gradle.
Essential Requirement
Become a Merchant
We need to be a merchant in order to use HMS IAP Kit. Also after making your account as merchant, it will take 1 or 2 business days for verification.
Steps:
a) Login to Huawei Developer website.
b) Go to console.
c) Under Settings you will find Merchant Service as shown below:
d) Provide our bank details information here as shown below:
e) Provide our tax related information here as shown below:
f) Finally click submit to save the record for verification.
Need Public Key
We need a public key which is used for subsequent payment signature verification and a parameter for configuring the subscription notification URL.
b) After the configuration is successful, we will be able to see a public key. This public key we will use later.
Steps:
a) On the Develop tab page, go to Earning > In-App Purchases from the navigation tree on the left and click Settings. If this is the first time we configure the IAP service, a dialog box is displayed for you to sign the agreement.
Need Sandbox Account
We need sandbox account in order to test HMS IAP. During app development and testing, we can test product payments with a test account in the sandbox environment. During the testing period, when a purchase is initiated by the test account, the Huawei IAP server will identify the test account and directly process a successful payment, without real payments made.
Steps:
a) Go to AGC and select users and permissions.
b) Select Test account as shown below:
c) Click Add button to add test account as shown below:
d) After this a testing account is added. Make sure to add account which is used in Huawei devices to login.
This is not the end. For full content, you can visit https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201255229704010231&fid=0101187876626530001
This app is a great example for how Huawei Ads Kit can be used to monetize your app.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Earlier in my articles, we learn how to integrate Huawei Ads Kit in our application using Test Slot ID provided to us for testing purpose. Today we will see how to create one and monetize our app.
Let’s make some money
There are two types of developer account we will see at the time we sign up in Huawei Developer Website:
1) Individual Developer Account
2) Enterprise Developer Account
In order to create Ads Slot Id we must need to have an Enterprise Developer Account. For Individual Developer Account, there is no rights to create Ads Slot Id.
Essential Requirement
Create Enterprise Account
a) First we need to sign up in Huawei Developer Website.
b) After creating Huawei Developer Id, we will be provided with two option i.e. Individual or Enterprise Developer Account.
c) Select Enterprise Developer Account.
d) Provide all the necessary information in the form as shown below:
e) We can use either the DUNS number or Business license for identity verification for enterprise developers. It will 1 to 3 business days for verification.
Become a Merchant
We need to be a merchant in order to use HMS Ads Kit. Also after making your account as merchant, it will take 1 or 2 business days for verification.
Steps:
a) Login to Huawei Developer website.
b) Go to console.
c) Under Settings you will find Merchant Service as shown below:
d) Provide our bank details information here as shown below:
e) Provide our tax related information here as shown below:
f) Finally click submit to save the record for verification.
Huawei Ads Publisher Service Agreement
After the preceding steps are complete, use one of the following entries to sign in to Huawei Ads Publisher Service for further operations.
Steps:
Go to HUAWEI Developers > Console, and click Publisher service in App services. If no Publisher service card is displayed upon the first sign-in, click DIY in the upper right corner to add the Publisher service card. Read the HUAWEI Ads Publisher Service Agreement that is then displayed. If you agree, select by checking this box I confirm that I have read and agree to be bound by HUAWEI Ads Publisher Service Agreement. The agreement takes effect immediately. If you have signed the service agreement, you can view the signing record in My account and Download the agreement.
Steps To Create Ads Slot Id
Add an App
In order to create Ads Slot Id, we need to create first an app. This app will help us to connect Huawei Ads.
Steps:
a) Sign In to Huawei Account and select Publisher Service as shown below:
b) After selecting Publisher Service, we need to go to My apps and select Add app as shown below:
c) Select the app name from the drop down which we have already created in AGC. When we select the app from the drop down it will automatically fill up the rest. After that click Submit as shown below:
d) Finally it will look like this:
Add a unit / slot Id
Now we will add a unit or slot Id. Currently, HUAWEI Ads supports the banner, native, rewarded, interstitial, and splash ads. You can add units for the ad formats based on the app running status.
Steps:
a) On HUAWEI Ads Publisher Console, click My Apps, and click Add ad unit in the Operation column of an app as shown below:
b) We have to choose an ads format as shown below:
c) After selecting any ads format, fill in the unit information, including the name and media type, and complete advanced settings as required.
Banner Ads:
Splash Ads:
Reward Ads:
Native Ads:
Interstitial Ads:
eCPM: We can set the minimum eCPM for an ad unit. If the bid of an ad is lower than the minimum eCPM you set, the ad is not displayed. However, a too high minimum eCPM may lower the ad fill rate.
Frequency control: To ensure the experience of users, we can use this setting to control the number of ad impressions. The time unit ofFrequency controlcan be minute, hour, or day. If we select minute, the time cannot exceed 60 minutes. If we select hour, the time cannot exceed 24 hours. If we select day, the time cannot exceed 30 days.
For example, you setFrequency controltoUp to 1 impression for every user per 1 hour. In this way, when a user uses our app, the user can view up to one ad in the ad unit within one hour after the ad is displayed.
d) Click Save
e) Finally we will get the Ads Slot ID as show below:
How to use it?
Follow these articles to know how to use these Ads Slot IDs:
1) Reward Ads: https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201221846399980002&fid=0101187876626530001
2) Banner Ads:https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201230166492630050&fid=0101187876626530001
3) Splash Ads:https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201224203738280005&fid=0101187876626530001
4) Native Ads:https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201246549267010138&fid=0101187876626530001
5) Interstitial Ads:https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201246769882920150&fid=0101187876626530001
Releasing Your Game on HUAWEI AppGallery via UDP
Background
These posts outline the first steps required for developing a Unity game:
Unity Editor Installation and APK Packaging
How Can I Use the HUAWEI Game Service Demo Provided by Unity?
Initializing a Huawei Game and Implementing HUAWEI ID Sign-in Using Unity
How to Integrate Unity IAP for a Game to Be Released on HUAWEI AppGallery
Here, we have built an APK that provides a range of basic functions, such as payment and game sign-in. This post details the process for releasing the APK to HUAWEI AppGallery, walking you through each step in the process and showing the final effects.
Uploading the APK to UDP
UDP is short for Unity Distribution Portal. First, we’ll need to upload the generated APK as follows.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
The following UI information is displayed on the figure below.
UDP Initialization: The initialize API of UDP has been called in the game.
IAP Transaction: The purchase API of UDP has been called in the game.
The two APIs must be called and tested prior to the game’s release.
Completing the Necessary Configurations Prior to the Game’s Release
You can refer to the Unity official materials for reference:
https://distribute.dashboard.unity.com/udp/guideDoc/HUAWEI
I have registered as a Huawei developer account, and created game information in AppGallery Connect, and related information has been recorded (see this post). Therefore, I’ll only need to supplement the information that has not yet been completed.
After a successful release, the Publish page will display. Click Register your game with HUAWEI AppGallery.
In the displayed dialog box, click Next.
Then, in the following dialog box, click Link game to UDP.
After linking, the following page will display. In this case, we’ll need to fill in the game registration information by referring to the Unity materials.
Please note that when you obtain the PubKey field in the game registration information, if the following page is displayed in AppGallery Connect, you’ll need to click Settings to obtain the payment public key.
Set PubKey and privacyPolicy in the game information, and then click REGISTER. The page below will then display. You can see that the game is in Ready to publish state.
There are two options in the drop-down list on the right.
Repack Game: Unity only uses Huawei SDK to repack the uploaded APK.
Submit to Store: Unity repacks the APK, and uploads the repacked APK to AppGallery Connect for review.
Repacking and Testing Your Game
Here, Repack Game is recommended. You’ll need to test the functions of the APK repacked by Unity before submitting it to Huawei for review.
Click Download to download the successfully repacked game package.
If you encounter any issues during the self-test:
Here, I ran into some issues, so I deleted the original APK from the game information and re-submitted an APK for release. The new package is as follows.
Re-download the package, and continue the test until no problems are detected during the self-test.
If no issues are encountered during the self-test:
You can proceed to the next section.
Releasing Your Game on AppGallery, and Awaiting Huawei’s Review
If no issues are encountered during your self-test, upload the APK once again, and select Submit to Store. Unity will pack the app again, and submit it to Huawei for review. The app information and product information will also be synchronized to AppGallery Connect.
Note: In the past, I thought that after I clicked Repack Game and confirmed that the package is normal, I could submit the package to Huawei for review by clicking Submit to Store. However, in reality, I found that the game and product information did not display after I clicked Submit to Store, which required that I fill in the information again. Therefore, I wouldn’t recommend this option. The details are as follows:
1. The product and game information needs to be maintained in UDP and AppGallery Connect, respectively. You’ll need to fill in the information twice.
2. You won’t be able to view the game release status in each app store via UDP.
Therefore, this solution can be used as an alternative unless a problem that is hard to handle or is caused due to callback failure, occurs during the synchronization of information from UDP to AppGallery Connect.
After I clicked Submit to Store, two warnings were displayed, as shown below.
The first warning is related to the configuration of the SHA-256 certificate fingerprint. I previously completed the configuration in this post. Here, I can just ignore it.
The second warning indicates that the release time is not set. In this case, after my game is submitted to Huawei for review, it will be released immediately after being approved. Therefore, if you do not want your game to be automatically released right after being approved by Huawei, click Modify to set the release time. I’m ignoring this setting here.
You can see that the game has been submitted to AppGallery Connect for review.
After signing in to AppGallery Connect, you’ll be able to see:
1. On the app information page, Unity has synchronized the app information to AppGallery Connect.
2. On the product management page, Unity has synchronized product information to AppGallery Connect.
3. The game is under review.
Thus far, I have successfully released a game to AppGallery through Unity, and am in the process of awaiting Huawei’s review result.
To complete the release process outlined in this post, you’ll need to be familiar with the development and release process for Huawei games in Unity. For more details, you can refer to the following posts:
Unity Editor Installation and APK Packaging: https://forums.developer.huawei.com/forumPortal/en/topic/0204435788744370088?fid=0101187876626530001
How Can I Use the HUAWEI Game Service Demo Provided by Unity?: https://forums.developer.huawei.com/forumPortal/en/topic/0204451267476400094?fid=0101188387844930001
Initializing a Huawei Game and Implementing HUAWEI ID Sign-in Using Unity: https://forums.developer.huawei.com/forumPortal/en/topic/0202458249587900041?fid=0101188387844930001
How to Integrate Unity IAP for a Game to Be Released on HUAWEI AppGallery: https://forums.developer.huawei.com/forumPortal/en/topic/0201472979681270115?fid=0101188387844930001
thanks for sharing
shikkerimath said:
thanks for sharing
Click to expand...
Click to collapse
thanks for your liking.
More and more advertisers are using HUAWEI Ads to promote their apps or web pages in order to attract more users and increase revenue. This article introduces how to track clicks and conversion rates of ads delivered using HUAWEI Ads. HUAWEI Ads works with Dynamic Tag Manager (DTM) to help you easily track conversions on web pages, as well as ad performance.
First of all, what is ad conversion tracking?
Let's use Huawei Vmall as an example. Ads for Vmall are served by HUAWEI Ads. After a user clicks such an ad to access Vmall, user actions, such as adding products to the shopping cart and purchasing products, on one or more in-app pages in a given period (30 days in general) will be tracked.
Now, let's take a look at ad conversion.
When a user clicks an ad to access Vmall and purchases a product in Vmall, this is considered as an ad conversion because a user has been converted into a paying user.
Next, let's see how to configure conversion tracking for web pages in DTM.
You can configure conversion tracking for landing pages, across web pages, or across domains and select an appropriate tracking mode for each scenario in DTM. The configuration involves the following steps:
1. Configuration preparations
2. Conversion tracking for landing pages
3. Cross-page conversion tracking for a single domain
4. Cross-domain conversion tracking
First, you need to perform the following operations before configuring conversion tracking:
1. Register a HUAWEI ID.
2. Register a HUAWEI Ads account.
3. Embed the JavaScript code obtained from DTM into the web page to be tracked.
Procedure:
Step 1 Access AppGallery Connect and register a HUAWEI ID.
Step 2 Access HUAWEI Ads and register an account.
You can use your HUAWEI ID to register a HUAWEI Ads account.
Step 3 Embed the JavaScript code obtained from DTM into the web page to be tracked.
1. Add a web app.
Sign in to AppGallery Connect, select My projects, click Add project, enter a project name, and click OK.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Click Add app. On the page displayed, select Web for Platform, set App name, and click OK.
2. Create a configuration in DTM.
In AppGallery Connect, go to Grow > Dynamic Tag Management.
Click Enable Dynamic Tag Manager. In the dialog box displayed, set Configuration name and URL, and click OK. Embed the generated JavaScript code snippet into all web pages to be promoted. The code needs to be embedded only once and will be valid indefinitely.
Step 4 Use Google Tag Manager (GTM) to embed the DTM-Web tracking code snippet.
During version development, it is unpractical to modify the code snippet and release it to the live network immediately. So, how can the code snippet be embedded into web pages without version release?
As many web pages integrate GTM, you can use it to embed the DTM code. The detailed configuration process is as follows:
1. Sign in to GTM and select the container corresponding to the web page to track.
2. Create a tag.
Go to Tags > New. On the page displayed, set Tag Type to Custom HTML and copy the DTM code snippet to the HTML area. Set Firing Triggers to Page View, enter a tag name, and click Save.
3. Create and release a version.
Click Submit. On the page displayed, select Publish and Create Version, enter a version name, and click Publish.
You have now completed the necessary preparations for configuring conversion tracking for web pages.
To learn more, please visit:
HUAWEI Developers official website
Development Guide
Reddit to join developer discussions
GitHub or Gitee to download the demo and sample code
Stack Overflow to solve integration problems
Original Source
HMS Core In-App Purchases can be easily integrated into apps to provide a high quality in-app payment experience for users. However, some developers may find that the payment screen of In-App Purchases cannot be opened normally. In this article, I will explain possible causes for this and provide solutions.
Scenario 1: In-App Purchases has been enabled on the Manage APIs page in AppGallery Connect, and the created product has taken effect. However, error code 60002 is recorded in logs.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Cause analysis
The payment public key is required for verifying the SHA256WithRSA signature of the In-App Purchases result. However, the developer has not configured a payment public key.
Solution
Check the following items:
(1) In-App Purchases has been enabled on the Manage APIs page. (The setting takes around half an hour to take effect.)
You can visit the official website to see how to enable the service.
(2) The public key switch is toggled on, and the public key is used correctly.
(3) The corresponding product category has been configured on PMS in AppGallery Connect, and has been activated successfully.
Scenario 2: Error 60051 is reported when the developer opens the subscription editing page in the member center.
According to the official website, error code 60051 indicates that a non-consumable product or subscription cannot be purchased repeatedly.
Cause analysis
After a subscription is completed, there is a refresh action when going back to the member center. An error will be reported if the subscription button is tapped again before the refresh occurs. The product can only be successfully subscribed to if the subscription button is tapped after the refresh. This is because if the refresh action is not triggered in time, cached data of the previous subscription will still exist. If another product is subscribed to immediately after a product is subscribed to, the ID of the previously subscribed product will be passed to the system instead of the newest product. As a result, an error is reported and the subscription editing page cannot be displayed due to product ID mismatch.
Solution:
Modify the timing for triggering the refresh action to prevent product subscription from occurring before the refresh.
Scenario 3: Error code 60003 is reported when a Huawei phone is used for payment debugging, but the product ID is correctly configured on PMS.
Cause analysis
Generally, error code 60003 indicates that the product information configured on PMS is incorrect. You can sign in to AppGallery Connect, click the desired app, go to Operate > Product Management > Products, and check that the corresponding product exists and mandatory information (such as the name, ID, price, type, and status of the product) is configured correctly.
In addition, you can check whether the product ID is correctly configured in the client code and consistent with that in AppGallery Connect. In particular, check that the field passed to the client code is correct.
Check whether the service region of the HUAWEI ID signed in on the Huawei phone supports In-App Purchases. To do this, call the Task<IsEnvReadyResult> isEnvReady() method.
Solution
After troubleshooting, the developer finds that the error is reported because the product ID passed to the client code is inconsistent with that in AppGallery Connect. After correcting the product ID in the client code, the issue is resolved.
Scenario 4: The payment screen is opened successfully when the checkout start API is called for the first time. However, after the payment is canceled, the payment screen fails to open when the API is called again.
Cause analysis
After a consumable product is purchased, the product can be purchased again only after the purchased product is consumed. Otherwise, error codes such as 60051 will be reported.
Solution
Redeliver the consumable product.
You need to trigger the redelivery process when:
The app launches.
Result code -1 (OrderStatusCode.ORDER_STATE_FAILED) is returned for a purchase request.
Result code 60051 (OrderStatusCode.ORDER_PRODUCT_OWNED) is returned for a purchase request.
Result code 1 (OrderStatusCode.ORDER_STATE_DEFAULT_CODE) is returned for a purchase request.
If the refund callback URL configured in the In-App Purchases configuration page is incorrect, reconfigure it correctly. You can click here for details.
In addition to the payment screen opening failure problem, another common problem is how to determine whether the sandbox environment is entered.
Scenario 5: A sandbox account is used for testing but no sandbox environment popup is displayed. How to check whether a sandbox environment is entered?
Cause analysis
Generally, a popup similar to the following will be displayed when the sandbox environment is entered.
The two mandatory conditions of the sandbox environment are met but still no sandbox environment popup is displayed. Does this mean that the sandbox environment is not entered?
The screenshot below shows relevant logs for the isSandboxActivated method.
According to the logs, the two mandatory conditions of the sandbox environment are met, which are:
The currently signed in HUAWEI ID is a sandbox account.
The version code is greater than that of the online version on AppGallery. (The APK has not been released to AppGallery. Therefore, the version code returned by AppGallery is 0.)
Theoretically, the sandbox environment has been entered. Are there other methods to check whether the sandbox environment is entered?
Solution
Check whether the sandbox environment is entered successfully using the following methods:
a) Check the returned purchase data, as shown in the screenshot below.
If the Huawei order ID specified in payOrderId begins with SandBox, the order is generated in the sandbox environment.
b) Check the payment report.
Check whether the payment report contains this order. If not, the order is generated in the sandbox environment. (Note: Data on the payment report is not updated in real time. If the order is placed on the current day, the developer can check the payment report on the next day to ensure accuracy.)
c) Clear the HMS Core (APK) cache.
You can try to clear the HMS Core (APK) cache. The system determines whether to display the sandbox environment popup based on relevant fields, which may not be updated in time due to the cache. You can go to Settings > Apps & services > Apps > HMS Core on the device to clear the cache.
References
In-App Purchases official website
In-App Purchases development guide