Quick app access to in-app payment service guide

Huawei Quick App Access In-App Payment Service Development Guide

1. Introduction of in-app payment service

     Huawei's in-app payment service ( In-App Purchases , IAP ) provides a convenient in-app payment experience for applications, and the access process is simple and helps your business monetize. In-app payments allow users to purchase various types of virtual goods within your app, including consumables, non-consumables, and subscriptions.

1.png

                          Figure Features of in-app payment

     The Huawei in-app payment service includes a Product Management System ( PMS ). After you enter the product ID and price on the Huawei AppGallery Connect website , you can host the product. IAP displays localized language and currency prices based on region and exchange rate, enabling global distribution.

  1. Currency and language : Huawei specifies a default currency and a default language for each country / region. It does not support configuring multiple languages ​​for one country /
  2. Product pricing : Huawei provides reference prices for various countries that have been paid by Huawei based on the exchange rate conversion price (tax included) and exchange rate you set. You can modify the price in each country by yourself.
  3.   Exchange rate : fixed exchange rate, this exchange rate is not real-time exchange rate, Huawei will update currency prices according to this exchange rate. If you do not modify the price of the product, Huawei's updated exchange rate will not affect the price of your product. 

2. Development process

2.png

                            Figure Overall access process

When you need to make business calls with the IAP server (for example, the Order service needs to call the verification and purchase Token interface provided by the IAP server ), or only rely on your client to handle more complex business logic, you can increase the server-side development stage.

2.1 Interaction process 

3.png

Figure Consumables

4.png

Figure 4   Non-consumable goods

5.png

Figure Subscription products

2.2 Get Purchase History 

There are two interfaces with similar names in the payment interface, they are pay.obtainOwnedPurchaseRecord and pay.obtainOwnedPurchases . In usage scenarios, the two interfaces are different.

pay.obtainOwnedPurchases:

  1. Consumable commodities: Check whether there are commodities that need to be re-delivered. If the returned data is not empty, re-delivery processing is required, and  the pay.consumeOwnedPurchase interface is called for consumption processing. Usually called when the application starts and the payment returns a 60051 or -1 error code. 
  2. Non-consumable commodities: query the records of commodities purchased by the current user.
  3. Subscription products: Query the existing subscription relationship of the user who is currently logged in to the Huawei account under this app.

pay.obtainOwnedPurchaseRecord:

  1. Consumable Commodities: Query the records of commodities that have been shipped and consumed.
  2. Subscription products: Query all renewal records of the current user in this application.

2.3 Development self-test 

   In order to ensure that you correctly complete the in-app payment service access, and prevent the listing review from being rejected due to access problems or complaints and losses in the online operation, please be sure to conduct a self-check before listing.

  1. The description language of the product name is the language corresponding to the service location of the account. The account service location switching path is: App Market app- >My-> Country / region . After switching between different service locations, you can check whether the product name is the same as that on the PMS system.
  2. The commodity price is displayed as the currency unit + unit price of the corresponding account's service location .
  3. The payment interface pops up, and the commodity name and commodity price in the payment interface are the same as those in the application.
  4. Purchase a consumable item, which can be purchased again after it has been shipped and consumed.
  5. After purchasing a non-consumable product, the product cannot be purchased again, and the error code 60051 will be returned to the purchase again . After the first purchase is successful, the app needs to provide corresponding services.
  6. After purchasing a subscription type product, you cannot purchase the product again, and the error code 60051 will be returned if you purchase it again . After the first purchase is successful, the app needs to provide corresponding services.
  7. The purchase of consumable goods is abnormally dropped, and re-entry into the application requires a supplementary order.

3. Sandbox testing 

     Sandbox testing allows you to complete the end-to-end test without real payment during the joint debugging process of accessing Huawei in-app payment. You can configure a test account in AppGallery Connect (the account must be a real Huawei account), and set to allow these The account performs sandbox testing.

6.png
  1. Purchase non-consumable goods in the sandbox environment, you can perform consumption after purchase, and then you can purchase again to facilitate testing  ( not in the live network environment ) .  
  2. After a successful purchase, the receipt information will carry a purchaseType field with a value of  0 , indicating that the purchase is a sandbox test record. 
  3. Sandbox Test When you pull up the cash register, a pop-up box of the sandbox environment logo will pop up. The cash register and the success page also have the sandbox environment logo.
  4. Subscription renewal times in a sandbox environment will be faster than normal.
7.png

4. Sample code

For example code, please refer to the demo section of the official website of Huawei Quick App Reference to access payment services .

This article is the word version of the MOOC instruction for quick app access to in-app payment . For the specific demo explanation, please refer to the MOOC video tutorial .

{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/4478396/blog/5510754