Overview
Alipay is a leading mobile payment platform in China. This guide will walk you through the complete process of integrating Alipay H5 payment, including application registration, payment credentials, and configuration in superun.Please note
Alipay payment integration requires users to complete application registration and credential acquisition themselves. superun provides guidance for configuring environment variables. Use Alipay’s sandbox environment when testing.
Step 1: Alipay Open Platform Configuration
1.1 Registration and Login
- Visit Alipay Open Platform
- Log in with Enterprise Alipay Account (personal accounts cannot apply for payment products)
- Complete developer certification (requires business license)
1.2 Create Application
Enter Console
After logging in, click “Console” in the top right → “My Applications” → “Create Application”Select Application Type
| Type | Description | Use Case |
|---|---|---|
| Web Application | For PC/H5 web pages | Choose this |
| Mobile Application | For iOS/Android native apps | - |
| Mini Program | For Alipay Mini Programs | - |
Fill in Application Information
- Application Name: e.g., “Travel Puzzle Workshop”
- Application Icon: Upload application logo (200x200px)
- Application Description: Brief description of application functionality
- Application Type: Web Application
2021006128604471)
1.3 Configure Keys (Important)
Download Key Tool
- Go to application details page → “Development Settings” → “Interface Signature Method”
- Click “Set” → Download Alipay Key Generation Tool
Generate Key Pair
Open the key tool:- Key Format: Select PKCS8 (Java compatible)
- Key Length: Select RSA2 (2048)
- Click “Generate Key”
- Application Public Key.txt - Upload to Alipay
- Application Private Key.txt - Save securely, configure on your server
Upload Public Key to Get Alipay Public Key
- Return to Alipay Open Platform → “Interface Signature Method” → “Set”
- Signature Mode: Select “Public Key”
- Fill Application Public Key: Copy and paste content from
Application Public Key.txt - Click “Save Settings”
Three Keys and Their Uses
| Key | Source | Purpose | Storage Location |
|---|---|---|---|
| Application Private Key | You generate | Sign requests | ALIPAY_PRIVATE_KEY |
| Application Public Key | You generate | Upload to Alipay | Alipay backend |
| Alipay Public Key | Provided by Alipay | Verify callback signatures | ALIPAY_PUBLIC_KEY |
1.4 Bind Payment Products
Enter Product Binding
Application details page → Left menu “Callable Products” → In the product list, select “Payment” → “PC Website Payment” or “Mobile Website Payment” → Clicking will open the product details page in a new tab, where you can perform the binding operationSelect Payment Product
| Product Name | API | Use Case | Fee Rate |
|---|---|---|---|
| PC Website Payment | alipay.trade.page.pay | PC web payment | 0.6% |
| Mobile Website Payment | alipay.trade.wap.pay | Mobile H5 | 0.6% |
| APP Payment | alipay.trade.app.pay | Native App | 0.6% |
Sign Product Contract
After binding, merchant contract is required:- Click “Sign” next to the product
- Fill in merchant information (business license, legal representative info, etc.)
- Submit for review (1-3 business days)
- Product becomes available after approval
1.5 Configure Callback Address
Set Authorization Callback
Application details page → “Development Settings” → “Authorization Callback Address” Fill in your domain (e.g.,https://your-domain.com)
Interface Content Encryption (Optional)
For higher security, you can enable AES encryption:- “Development Settings” → “Interface Content Encryption Method” → “Set”
- Select “AES Key”
- Click “Generate AES Key” and save
1.6 Application Launch
Submit for Review
Application details page → Click “Submit for Review” Fill in review information:- Application website (must be ICP registered)
- Test account (if any)
- Application description
Review Period
Usually 1-3 business days Status changes to “Launched” after approvalNote: Application launch ≠ Product available, products need separate contracts
1.7 Final Configuration Checklist
After completing the above steps, you need to save the following information:Step 2: Database Design
Create the following tables in superun Cloud:Step 3: Edge Function Implementation
3.1 Create Order (alipay-create-order)
Create functionalipay-create-order in Build → Services → Edge Functions:
3.2 Payment Callback (alipay-notify)
Create functionalipay-notify to handle payment callbacks:
3.3 Query Order (alipay-query-order)
Create functionalipay-query-order for active order status queries:
Step 4: Frontend Integration
4.1 Create Order and Redirect to Payment
4.2 Query Result After Payment Completion
Step 5: Configuration Checklist
5.1 Edge Functions Configuration
Configure insupabase/config.toml:
5.2 Environment Variables (Secrets)
Set the following environment variables in Build → Services → Alipay Payment:| Variable Name | Description |
|---|---|
ALIPAY_APP_ID | Alipay application APPID |
ALIPAY_PRIVATE_KEY | Application private key (PKCS8 format) |
ALIPAY_PUBLIC_KEY | Alipay public key |
Step 6: API Reference
| Product Type | API Method | Product Code | Use Case |
|---|---|---|---|
| PC Website Payment | alipay.trade.page.pay | FAST_INSTANT_TRADE_PAY | PC Web |
| Mobile Website Payment | alipay.trade.wap.pay | QUICK_WAP_WAY | Mobile H5 |
| Order Query | alipay.trade.query | - | Active status query |
Step 7: Testing Process
- Create a sandbox application in Alipay Open Platform for testing
- Use a 1 cent plan to test the complete payment flow
- Check if database order status is updated
- Verify if membership status is correctly activated
Step 8: Process Summary
Step 9: Common Errors
insufficient-isv-permissions (Insufficient Permissions)
insufficient-isv-permissions (Insufficient Permissions)
Cause: Product not bound or contract not signed.Solution:
- Check if application has bound corresponding payment product
- Check if product contract is completed
- Check if application is launched
invalid-signature (Signature Error)
invalid-signature (Signature Error)
Cause: Key configuration error.Solution:
- Confirm using PKCS8 format private key
- Confirm private key has no line breaks or extra spaces
- Confirm Alipay public key is copied from backend (not the application public key you generated)
Signature Verification Failed
Signature Verification Failed
Cause: Private key format is incorrect or public key doesn’t match.Solution: Ensure the private key is in PKCS8 format, and the public key is the correct one obtained from Alipay Open Platform.
Product Not Enabled
Product Not Enabled
Cause: Application has not bound the corresponding payment product.Solution: Bind “PC Website Payment” or “Mobile Website Payment” product in the Alipay Open Platform application details page.
Callback Verification Failed
Callback Verification Failed
Cause: Callback URL is incorrectly configured or public key is incorrect.Solution: Ensure the callback URL is correctly configured as the Edge Function address, and use the correct Alipay public key.
Mobile Website Payment vs PC Website Payment
Mobile Website Payment vs PC Website Payment
| Comparison | Mobile Website Payment | PC Website Payment |
|---|---|---|
| API | alipay.trade.wap.pay | alipay.trade.page.pay |
| Product Code | QUICK_WAP_WAY | FAST_INSTANT_TRADE_PAY |
| Payment Interface | Mobile optimized | PC optimized |
| H5 Usage | Recommended | Usable but experience is average |
superun Website
Learn more about product features and examples.

