All Projects → HMS-Core → hms-iap-serverdemo

HMS-Core / hms-iap-serverdemo

Licence: Apache-2.0 license
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.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to hms-iap-serverdemo

hms-iap-clientdemo-android-studio
This demo app provides all 3 types of product to demonstrate the procedure and capability of Huawei IAP.
Stars: ✭ 36 (+80%)
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 (+160%)
Mutual labels:  pay, purchase, in-app-purchases
hms-FIDO-demo-java
HMS FIDO demo, including fido2 demo, bioauthn demo and bioauthn-androidx demo.
Stars: ✭ 17 (-15%)
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 (-20%)
Mutual labels:  huawei, hms
hms-location-demo
HUAWEI Location Kit sample code encapsulates APIs of the HUAWEI Location Kit. It provides many sample programs for your reference or usage.
Stars: ✭ 32 (+60%)
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 (+20%)
Mutual labels:  huawei, hms
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 (+5%)
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 (+85%)
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 (+50%)
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 (-30%)
Mutual labels:  huawei, hms
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 (+25%)
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 (+95%)
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 (+0%)
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 (+10%)
Mutual labels:  huawei, hms
map-kit-android
An extensive framework for map development in Android.
Stars: ✭ 44 (+120%)
Mutual labels:  huawei, hms
hms-cordova-plugin
This repo contains all of Cordova HMS plugins.
Stars: ✭ 78 (+290%)
Mutual labels:  huawei, hms
hms-toolkit-convertor
Convertor is a code conversion tool supporting Java and Kotlin projects. It helps developers to automatically convert GMS APIs called by apps into corresponding HMS APIs, implementing quick conversion and HMS integration.
Stars: ✭ 29 (+45%)
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 (+250%)
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 (+5%)
Mutual labels:  huawei, hms
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 (+95%)
Mutual labels:  huawei, hms

iap-java-sample

English | 中文

Contents

Introduction

Java sample code encapsulates APIs of the HUAWEI IAP server. It provides many sample programs for your reference or use. The following describes packages of Java sample code.

AtDemo: Sample code of AccessToken. Each method can run independently. OrderService: Sample code of OrderService. Each method can run independently. SubscriptionService: Sample code of SubscriptionService. Each method can run independently. notification: Sample code of notification. Each method can run independently.

Installation

Before using Java sample code, check whether the Java environment has been installed. Decompress the Java sample code package.

Copy the Java sample code package in the decompressed folder to the project vendor directory in the path specified by JAVAPATH. Refresh the project and ensure that the file is successfully copied to the destination directory.

Environment Requirements

JDK 1.8 or a later version is recommended.

Configuration

To use functions provided in examples, you need to set related parameters in AtDemo.java, OrderService.java, SubscriptionService.java, and AppServer.java in the package.

The following describes parameters in AtDemo.java. clientId: Client ID, which is obtained from app information. clientSecret: Secret access key of an app, which is obtained from app information. tokenUrl: URL for the Huawei OAuth 2.0 service to obtain a token. Please refer to OAuth 2.0-based Authentication.

The following describes parameters in notification/AppServer.java. PUBLIC_KEY: RSA public key.

At first, the meaning of accountFlag should be clear. If field accountFlag in InappPurchaseData equals to 1, the account belongs to telecom carrier (TOBTOC_SITE_URL); otherwise, to Huawei (TOC_SITE_URL).
For both OrderService and SubscriptionService, you need to choose appropriate site. TOC_SITE_URL: The TOC_SITE_URL has different URLs at different sites, you should always choose the address of the nearest site to access. TOBTOC_SITE_URL: The site for telecom carrier.

Sample Code

Each method in the Java sample calls an API of the HUAWEI IAP server. The following describes methods in the Java sample.

  1. AtDemo: getAppAT()

    You can call this method to get an app-level Access Token. Code location: src/main/java/com/example/demo/AtDemo.java

  2. OrderService: verifyToken()

    You can call this method to verify the purchase token in the payment result with the Huawei payment server to confirm the accuracy of the payment result. The URL is {rootUrl}/applications/purchases/tokens/verify. The rootUrl has different URLs at different sites, you should always choose the Order service address of the nearest site to access. Code location: src/main/java/com/example/demo/OrderService.java

  3. OrderService: cancelledListPurchase()

    You can call this method to pagination query all purchase information that has been cancelled or has a refund. The URL is {rootUrl}/applications/{apiVersion}/purchases/cancelledList. The rootUrl has different URLs at different sites, you should always choose the Order service address of the nearest site to access. Code location: src/main/java/com/example/demo/OrderService.java

  4. SubscriptionService: getSubscription()

    You can call this method to verify a purchased subscription product, such as to obtain the validity period and status. The URL is {rootUrl}/sub/applications/{apiVersion}/purchases/get. The rootUrl has different URLs at different sites, you should always choose the Subscription service address of the nearest site to access. Code location: src/main/java/com/example/demo/SubscriptionService.java

  5. SubscriptionService: stopSubscription()

    You can call this method to cancel an already subscribed product, the subscription is still valid during the validity period, and subsequent renewals will be terminated. The URL is {rootUrl}/sub/applications/{apiVersion}/purchases/stop. The rootUrl has different URLs at different sites, you should always choose the Subscription service address of the nearest site to access. Code location: src/main/java/com/example/demo/SubscriptionService.java

  6. SubscriptionService: delaySubscription()

    You can call this method to renew a subscription product for a customer until a specified time in the future. After success, the customer's subscription will expire at a future time. The URL is {rootUrl}/sub/applications/{apiVersion}/purchases/delay. The rootUrl has different URLs at different sites, you should always choose the Subscription service address of the nearest site to access. Code location: src/main/java/com/example/demo/SubscriptionService.java

  7. SubscriptionService: returnFeeSubscription()

    You can call this method to refund the last renewal fee of a subscription product, but the subscription product is still valid during the validity period, and subsequent renewals will be performed normally. The URL is {rootUrl}/sub/applications/{apiVersion}/purchases/returnFee. The rootUrl has different URLs at different sites, you should always choose the Subscription service address of the nearest site to access. Code location: src/main/java/com/example/demo/SubscriptionService.java

  8. SubscriptionService: withdrawSubscription()

    You can call this method to cancel a subscription, which is equivalent to executing the returnFeeSubscription method, and immediately ending the subscription service and subsequent renewal. The URL is {rootUrl}/sub/applications/{apiVersion}/purchases/withdrawal. The rootUrl has different URLs at different sites, you should always choose the Subscription service address of the nearest site to access. Code location: src/main/java/com/example/demo/SubscriptionService.java

  9. AppServer: dealNotification()

    You can call this method to handle subscription event notifications. The information parameter is obtained from subscription event notification. Code location: src/main/java/com/example/demo/notification/AppServer.java

  10. OrderService: confirmPurchase()

    You can call this method to confirm purchase after sending out product. The URL is {rootUrl}/applications/{apiVersion}/purchases/confirm. The rootUrl has different URLs at different sites, you should always choose the Order service address of the nearest site to access. Code location: OrderService.java

License

IAP Java sample is licensed under Apache License, Version 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].