Website Alipay/WeChat Pay Integration Guide: From Zero to Successful Payment

For websites serving Chinese users, Alipay and WeChat Pay are essential payment methods.

1. Prerequisites

1.1 Required Qualifications

Payment Requirements
Alipay Business license (or sole proprietorship)
WeChat Pay Business license (or sole proprietorship)

1.2 Website Requirements

  • ICP备案 completed
  • HTTPS enabled
  • Complete product/service pages
  • Clear refund and after-sales policy

2. Alipay Integration

2.1 Registration

  1. Log in to Alipay Open Platform
  2. Create application → Web/Mobile App
  3. Configure encryption (RSA2 recommended)
  4. Submit for review (1-3 business days)

2.2 Initiate Payment

$aop = new AopClient();
$aop->gatewayUrl = $config['gateway_url'];
$aop->appId = $config['app_id'];
$aop->rsaPrivateKey = $config['merchant_private_key'];

$request = new AlipayTradePagePayRequest();
$request->setBizContent(json_encode([
    'out_trade_no' => 'ORDER_' . time(),
    'product_code' => 'FAST_INSTANT_TRADE_PAY',
    'total_amount' => '99.99',
    'subject' => 'Product Name',
]));
$result = $aop->pageExecute($request);

3. WeChat Pay Integration

3.1 Registration

  1. Log in to WeChat Pay Merchant Platform
  2. Submit business documents
  3. Complete account verification
  4. Obtain merchant ID

3.2 Native Payment (PC Website)

const { code_url } = await wechatPay.native({
  description: 'Product Name',
  out_trade_no: 'ORDER_' + Date.now(),
  amount: { total: 9999, currency: 'CNY' },
});
// Display QR code for user to scan

4. Payment Notification Handling

4.1 Alipay Async Notification

$aop = new AopClient();
$result = $aop->rsaCheckV1($_POST, $config['alipay_public_key'], 'RSA2');
if ($result && $_POST['trade_status'] == 'TRADE_SUCCESS') {
    updateOrderStatus($_POST['out_trade_no'], 'paid');
    echo 'success';
}

5. Fee Comparison

Item Alipay WeChat Pay
Rate 0.6%-1.2% 0.6%-1.0%
Standard 0.6% (most industries) 0.6% (most)
Withdrawal Free Free
Settlement T+1 T+1

6. Summary

Integrate both Alipay and WeChat Pay to cover 95%+ of Chinese mobile payment users. If resources are limited, consider third-party payment aggregators.