Understanding the IAP SDK/API Flow
The IAP SDK/API provides a lightweight, unified way to integrate in-app payments without having to build and maintain two separate payment integrations (one for Alipay and one for WeChat Pay).
In practice, the AppInChina Payments SDK still delegates to the official Alipay / WeChat Pay SDKs on the device, so you will include those dependencies — but you interact with a single, consistent AppInChina SDK/API surface.
It’s important to understand that:
- Alipay and WeChat Pay are the actual payment processors.
- The IAP system is a wrapper that simplifies integration and ensures transactions are consistently logged with the right metadata (product and user identifiers).
- Your system manages users and products. The IAP system only records transactions.
- If you’re unsure whether a feature is in scope (products, discounts, promo codes, user management, etc.), read: Capabilities and Limitations (Scope).
Key concepts
- Your system (products & users): You define products and manage user accounts in your own backend.
- IAP system (wrapper): Provides a single, consistent interface for payments. Internally, it launches the official Alipay or WeChat Pay SDK on the user’s device.
- Payment providers (Alipay / WeChat Pay): They handle the actual transaction — payment authorization, funds transfer, and result confirmation.
- IAP backend: Stores the transaction record, enriched with fields you provide (
goodsTitle,customerIdentity,phoneNumber).
If you’re unsure what to use for customerIdentity, read: Login → Payments integration (customer identity).
Typical flow
- User selects a product in your app.
- Product info comes from your backend (e.g., product ID, price).
- You call the IAP SDK with:
goodsTitle(product label)customerIdentity(your internal user ID)
- SDK delegates to payment provider:
- If user chooses WeChat → SDK invokes WeChat Pay SDK.
- If user chooses Alipay → SDK invokes Alipay SDK.
- Alipay/WeChat Pay process the payment
- They show their native UI on the user’s device.
- The user completes payment securely within the provider’s system.
- Result flows back
- Alipay/WeChat Pay return the outcome (success/failure).
- IAP SDK wraps this result and delivers it to your app.
- Transaction is logged in the IAP backend
- Stored with product/user identifiers from the request.
- Can later be grouped by
goodsTitleorcustomerIdentity.
- Your system updates product/user state
- Example: unlock premium features, extend subscription, deliver digital goods.
Why this design?
- Lightweight: You only integrate once with the IAP SDK, not twice with Alipay and WeChat Pay.
- Consistent: All transactions are stored with uniform metadata for reporting.
- Flexible: You remain in control of product catalogs and user management in your own system.
- Secure: Payments are always processed by the official Alipay and WeChat Pay SDKs.