支付網關API
概述
接口對接方式
每個 API 請求都需要包含必要的鑑權信息和數據簽名,以保證數據的安全性和完整性。
API 請求規範:
鑑權方式
簽名加密方式
支持的支付通道
Channel:ALIPAY
通道配置:
PaymentMethodOption不同類型支付參數定義
AlipayMobileSecurityPayPaymentOptions 示例
"{\"trade_information\":{\"business_type\":\"5\",\"other_business_type\":\"Bus Ticket\"},\"payment_inst\":\"AILPAYHK\",\"refer_url\":\"https:\/\/www.chingchingpay.com\"}"
//如果用户是ALIPAYHK錢包,需要传递trade_information,具體值參考支付寶文檔https://global.alipay.com/docs/ac/hkapi/securitypay_pay,
//payment_inst值香港钱包为 ALIPAYHK, 如果是大陸錢包傳 "ALIPAYCN"
//refer_url:商户网站首页的URL。如果商户没有网站,则该字段可以使用商户APP下载地址。
AuthCodePaymentOptions 示例
{\"auth_code\":\"288747107207804180\"}"
Alipay Hong Kong AutoDebit(自動扣款)
支付方式
授權流程
1.
2.
3.
4.
5.
6.
商戶須知事項
1.
2.
3.
接口說明
1. 授權準備請求 (HK_ALIPAY_AUTODEBIT_PREPARE)
{
"transaction_type": "command",
"payment_method": "HK_ALIPAY_AUTODEBIT_PREPARE",
"payment_method_options": "{\"state\":\"unique_state_for_verification\",\"merchant_agreement_id\":\"agreement_id_for_this_authorization\",\"redirect_url\":\"https://your-redirect-url.com/auth_callback\"}"
}
2. 授權回調 (商戶自行實現的回調頁面)
redirect_url
(即由商戶自行實現的回調頁面),並附帶以下參數:參數名 | 描述 | 類型 | 必須 | 備註 | 範例 |
---|---|---|---|---|---|
state | 商戶在授權請求中提供的狀態值 | string | 是 | 用於防止CSRF攻擊 | 4657DDUER323DK |
auth_site | 授權用戶的站點 | string | 是 | 固定值 | ALIPAY_HK |
merchantAgreementId | 商戶在授權請求中提供的協議ID | string | 是 | e8qdwl9casxor13 | |
authCode | 支付寶返回的一次性授權碼 | string | 是 | 用於獲取訪問令牌 | 28100413kpBklrvUk33YgGgC9yS2o679 |
client_id | 授權商戶ID | string | 是 | 2160400000002012 |
3. 獲取訪問令牌 (HK_ALIPAY_AUTODEBIT_TOKEN)
{
"transaction_type": "command",
"payment_method": "HK_ALIPAY_AUTODEBIT_TOKEN",
"payment_method_options": "{\"auth_code\":\"authorization_code_from_redirect\"}"
// 其他參數參考接口說明
}
{
"code": 0,
"message": "success",
"data": {
"payment_id": "",
"transaction_id": "",
"transaction_type": "command",
"merchant_reference": "",
"payment_reference": "",
"result": "completed",
"message": "Access token obtained successfully",
"next_action": {
"type": "alipay_auto_debit",
"alipay_auto_debit": {
"access_token": "access_token",
"expires_in": "2037-12-31T16:00:48-08:00",
"refresh_token": "refresh_token",
"re_expires_in": "2037-12-31T16:00:48-08:00",
"token_status": "ACTIVE",
"auth_site_user_id": "auth_site_user_id"
}
}
}
}
4. 發起自動扣款 (HK_ALIPAY_AUTODEBIT_PAY)
{
"transaction_type": "command",
"payment_method": "HK_ALIPAY_AUTODEBIT_PAY",
"payment_method_options": "{\"access_token\":\"access_token_from_previous_step\"}"
// 其他參數參考接口說明
}
5. 取消授權 (HK_ALIPAY_AUTODEBIT_CANCELAUTH)
{
"transaction_type": "command",
"payment_method": "HK_ALIPAY_AUTODEBIT_CANCELAUTH",
"payment_method_options": "{\"merchant_agreement_id\":\"agreement_id_to_cancel\"}"
// 其他參數參考接口說明
}
{
"merchant_agreement_id": "12345456",
"cancel_time": "2025-03-26 06:22:41"
}
6. 查詢授權狀態 (HK_ALIPAY_AUTODEBIT_QUERYAUTH)
{
"transaction_type": "command",
"payment_method": "HK_ALIPAY_AUTODEBIT_QUERYAUTH",
"payment_method_options": "{\"merchant_agreement_id\":\"agreement_id_to_query\"}"
// 其他參數參考接口說明
}
Channel:Wechat Pay
通道配置:
PaymentMethodOption不同類型支付參數定義
AuthCodePaymentOptions 示例
{\"auth_code\":\"288747107207804180\"}"
MiniProgramPaymentOptions 示例
"{\"openid\": \"openid-123456\", \"appid\": \"appid-123456\"}"
WechatAuthCodePaymentOptions 示例
"{\"redirect_url\":\"https://www.xxxxx.xxx\"}"
//redirect_url 重定向地址,用于获取AUTH CODE,需要做urlencode
WechatJsapiPaymentOptions 示例
"{\"openid\":\"xxxxxx\"}" 或者 "{\"sub_openid\":\"xxxxxx\",\"sub_appid":\"xxxx\"}"
//openid 使用Gateway方式獲取到的openid
//sub_openid 使用自有公眾號方式獲取到的openid
//sub_appid自有公眾號appid
WechatInAppPaymentOptions 示例
"{\"appid\": \"appid-123456\"}"
Channel:QFPAY
通道配置:
Channel:Winning Pay
交易回調
回調請求
{
"payment_id": "string", // ChingchingPay 支付ID
"transaction_id": "string", // ChingchingPay 交易 ID
"transaction_type": "string", // 交易類型: sale, refund
"amount": 12345, // 交易金額
"currency": "string", // 交易貨幣
"merchant_reference": "string", // 商家訂單編號
"payment_reference": "string", // 支付服務商交易號碼
"result": "string", // 交易結果
"payer_id": "string", // 付款人 ID (可選)
"payed_time": 1234567890, // 交易時間 (Unix 時間戳)
"timestamp": 1234567890, // 回調時間 (Unix 時間戳)
"message": "string", // 交易結果消息 (可選)
"extra": "string" // 附加信息 (可選)
}
1.
2.
3.
Modified at 2025-03-26 06:38:04