All Projects → HMS-Core → hms-iap-clientdemo-android-studio

HMS-Core / hms-iap-clientdemo-android-studio

Licence: Apache-2.0 license
This demo app provides all 3 types of product to demonstrate the procedure and capability of Huawei IAP.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to hms-iap-clientdemo-android-studio

hms-iap-serverdemo
IAP server sample encapsulates APIs of the HUAWEI IAP server. It provides many sample programs for your reference or usage. The repository contains 8 branches of java, csharp, golang, nodejs, perl, php, python and ruby demo.
Stars: ✭ 20 (-44.44%)
Mutual labels:  pay, purchase, huawei, hms
DYFStoreKit
([Swift] https://github.com/chenxing640/DYFStore) A lightweight and easy-to-use iOS library for In-App Purchases (Objective-C). DYFStoreKit uses blocks and notifications to wrap StoreKit, provides receipt verification and transaction persistence and doesn't require any external dependencies.
Stars: ✭ 52 (+44.44%)
Mutual labels:  pay, purchase, in-app-purchase
hms-push-serverdemo-csharp
C# sample code encapsulates APIs of the HUAWEI Push Kit server. It provides many sample programs for your reference or usage.
Stars: ✭ 25 (-30.56%)
Mutual labels:  huawei, hms
hms-audio-editor-demo
HUAWEI Audio Kit provides a wide range of audio editing capabilities, including auido import/export/editing/extracting and format conversion. This sample code describes how to integrate the Audio Editor Kit SDK.
Stars: ✭ 24 (-33.33%)
Mutual labels:  huawei, hms
hms-FIDO-demo-java
HMS FIDO demo, including fido2 demo, bioauthn demo and bioauthn-androidx demo.
Stars: ✭ 17 (-52.78%)
Mutual labels:  huawei, hms
hms-audio-demo
HMS audio android sample code encapsulates APIs of the HUAWEI Audio Kit, which focuses on audio playback, audio effects and audio data.
Stars: ✭ 20 (-44.44%)
Mutual labels:  huawei, hms
hms-push-serverdemo-java
Java sample code encapsulates APIs of the HUAWEI Push Kit server. It provides many sample programs for your reference or usage.
Stars: ✭ 39 (+8.33%)
Mutual labels:  huawei, hms
hms-av-pipeline-demo
HUAWEI AV Pipeline Kit sample code project, which contains the Java sample code to implement functions like video playback, video super-resolution and media asset management. C++ sample code is contained for calling MediaFilter to use the sound event detection plugin.
Stars: ✭ 14 (-61.11%)
Mutual labels:  huawei, hms
hms-image-vision-java
This sample code is to guide the developer how to integrate the Image Vision Sub-service of the Image Kit, calling the image filter function. This sub-service provides 24 unique filter effects to enhance the artistic conception and artistic sense of the images.
Stars: ✭ 22 (-38.89%)
Mutual labels:  huawei, hms
hms-health-demo-java
HMS Health demo code provides demo programs for your reference or usage. Developers can access the Huawei Health Platform and obtain sports & health data by integrating HUAWEI Health.
Stars: ✭ 37 (+2.78%)
Mutual labels:  huawei, hms
hms-cordova-plugin
This repo contains all of Cordova HMS plugins.
Stars: ✭ 78 (+116.67%)
Mutual labels:  huawei, hms
hms-health-demo-kotlin
HMS Health demo code provides demo programs for your reference or usage. Developers can access the Huawei Health Platform and obtain sports & health data by integrating HUAWEI Health.
Stars: ✭ 21 (-41.67%)
Mutual labels:  huawei, hms
PurchaseHelper
Sample app to explain the In-App purchase implementation in Android using Play-billing library
Stars: ✭ 30 (-16.67%)
Mutual labels:  purchase, in-app-purchase
huawei-account-demo
Sample code for quickly integrate Huawei ID. HUAWEI Account Kit provides developers with simple, secure, and quick sign-in and authorization functions.
Stars: ✭ 39 (+8.33%)
Mutual labels:  huawei, hms
DLInAppPurchase
A demo of In-App Purchase.苹果内购最详细教程
Stars: ✭ 37 (+2.78%)
Mutual labels:  purchase, in-app-purchase
hms-push-serverdemo-php
PHP sample code encapsulates APIs of the HUAWEI Push Kit server.It provides many sample PHP programs about quick access to HUAWEI Push Kit for your reference or usage.
Stars: ✭ 21 (-41.67%)
Mutual labels:  huawei, hms
hms-ecommerce-demo
Build a shopping app by HMS Core kits which shows how to use the HMS Core solution in E-Commerce industry.
Stars: ✭ 70 (+94.44%)
Mutual labels:  huawei, hms
from-gms-to-hms
Complete guide to adding support for Huawei's mobile services and distribution platform into your apps that are already published on Google Play.
Stars: ✭ 30 (-16.67%)
Mutual labels:  huawei, hms
hms-ads-demo-kotlin
HUAWEI Ads Kit Sample code in kotlin version, which provides the banner, native, rewarded, roll, interstitial and splash ad formats for integration
Stars: ✭ 16 (-55.56%)
Mutual labels:  huawei, hms
hms-video-editor-demo
HUAWEI Video Editor Kit provides full video editing functions like video import/export, editing and rendering. This sample code is used to describe how to integrate the Video Editor Kit SDK.
Stars: ✭ 45 (+25%)
Mutual labels:  huawei, hms

HMS Core In-App Purchases Client Sample Code

English | 中文

This section describes how to develop a client for accessing In-App Purchases (IAP) of HMS Core, helping you quickly understand the client APIs provided by IAP and how to use them.

Click here to learn more about the kit.

Contents

Introduction

IAP allows your users to buy three types of products, namely consumables, non-consumables, and subscriptions, in your app.

  • Consumables: Such products are depleted once they are used and can be purchased again.

  • Non-consumables: Such products are purchased once and never expire.

  • Subscriptions: Such products provide users with ongoing access to content or services in your app. Users are charged on a recurring basis until they decide to cancel.

This demo showcases the integration process and functions of IAP using the three products.

The products in the demo are only used to demonstrate the purchase process, and will not be put into commercial use.

You can use HMS Toolkit to quickly run the sample code. HMS Toolkit supports one-stop kit integration, and provides functions such as free app debugging on remote real devices. For details about HMS Toolkit, please refer to the HMS Toolkit documentation.

Preparations

  1. Install Android Studio on your computer. Use Android Studio to open the project-level build.gradle file of the sample code.

  2. Create an app in AppGallery Connect and configure the app information. For details, please refer to Configuring App Information in AppGallery Connect.

  3. Create and configure your products in AppGallery Connect. For details, please refer to Configuring Your Products.

  4. Import the demo to Android Studio 3.0 or later and build the demo.

  5. Configure the sample code:

    • Download the agconnect-services.json file of your app from AppGallery Connect, and add the file to the app-level directory of the demo.
    • Add the signing certificate and add configurations to the app-level build.gradle file.
    • Open the AndroidManifest file and change the package name to your app package name.
    • Replace PUBLIC_KEY in the CipherUtil class with the public key of your app. For details about how to obtain the public key, please refer to Querying IAP Information.
    • Replace the products in this demo with your products.
  6. Run the sample code on an Android device or simulator.

Environment Requirements

Android SDK 22 or later and JDK 1.8 or later are recommended.

Result

The following screen will be displayed when the demo is running.

demo home page

Consumables

We use gems in the game to showcase how to purchase consumables.

  1. Tap Consumable products to view the home page for purchasing consumables. The obtainProductInfo API is called to obtain the detailed information about this type of products.

consumable demo page

  1. Tap 5 gems, and the createPurchaseIntent API will be called to jump to the payment screen, which is supported by IAP.

    consumable payment selection
  2. After the payment is successful, you can own more gems. The consumeOwnedPurchase API will be called to notify the IAP server that the products have been consumed.

    gem purchase result

Note: If an exception (such as network error or process termination) occurs after the payment is made, the demo will update the gem quantity when you enter the screen again. (The obtainOwnedPurchases API is called to obtain information about the purchased consumables, and the consumeOwnedPurchase API is called to consume the products.)

  1. Tap History, and the obtainOwnedPurchaseRecord API will be called to obtain the purchase history.

    consumable purchase history

Non-consumables

This demo uses the hidden level product as an example to demonstrate how to purchase a non-consumable product.

  1. Tap Non-consumable product to view the home page for purchasing non-consumables. The obtainOwnedPurchases API will be called to obtain information about the non-consumables you have purchased.

  2. If you have not purchased hidden level, the screen below will be displayed. Tap hidden level to start purchase. The purchase process is the same as that of consumables.

    hidden level not purchased
  3. After the purchase is successful or the hidden level has been purchased before, the demo will display the hidden level that you have purchased.

    hidden level have been purchased

Subscriptions

The demo uses the subscription groups Service-One and Service-Two as examples to demonstrate the purchase process of subscriptions. Each subscription group contains two products and each product contains two options: BUY and ACTIVE.

(For more information about subscriptions and subscription groups, please refer to Subscription Functions.

  1. Tap Auto-renewable subscription to view the home page for purchasing subscriptions. The obtainOwnedPurchase API will be called to obtain information about the subscriptions. If you have subscribed to a product, the status of the product is displayed as ACTIVE.

    subscription homepage with active subscription
  2. Tap the BUY button of the product to be subscribed to. The demo will call the createPurchaseIntent API to start purchase.

    subscription payment selection

    Note: Currently, only Alipay is supported for subscription purchase.

  3. You will be asked to authorize the automatic renewal agreement. After the purchase is successful, the purchase result will be displayed on the screen, which is supported by IAP.

    subscription payment selection
  4. Tap MANAGE SUBSCRIPTION, and the subscription management screen will be displayed. This screen shows all the products you have subscribed to before, including expired ones.

    subscription manage
  5. Tap Happy Subscribe to edit the subscription. You can select another subscription in the same subscription group, or click UNSUBSCRIBE to cancel the subscription. The subscription is available until it expires.

    edit subscription

Technical Support

You can visit the Reddit community to obtain the latest information about HMS Core and communicate with other developers.

If you have any questions about the sample code, try the following:

  • Visit Stack Overflow, submit your questions, and tag them with huawei-mobile-services. Huawei experts will answer your questions.
  • Visit the HMS Core section in the HUAWE Developer Forum and communicate with other developers.

If you encounter any issues when using the sample code, submit your issues or submit a pull request.

License

The sample code is licensed under Apache License 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].