⚡ 快速開始
1
申請商戶賬號
聯繫我們開通商戶賬號,獲取 merchantCode 和 API 密鑰
3
集成測試
使用測試環境進行對接,確認無誤後上線
API 基礎地址:
生產環境:https://easylink-api-v2.jimsbond007.workers.dev/api/v1/{merchantCode}
測試環境:請聯繫技術支持獲取
🔐 認證方式
所有 API 請求需要在 Header 中攜帶認證信息:
{
"Authorization": "Bearer {your_api_key}",
"Content-Type": "application/json"
}
重要:請妥善保管您的 API 密鑰,不要在客戶端代碼中暴露。
💳 核心支付 API
創建支付訂單,返回支付跳轉鏈接
請求參數
| 參數 | 類型 | 必填 | 說明 |
| amount | number | 必填 | 支付金額(港元),如 100.50 |
| payType | string | 必填 | 支付方式:UP_OP(銀聯)、ALI_H5(支付寶)、WX_H5(微信) |
| orderNo | string | 選填 | 商戶訂單號,如不傳則系統自動生成 |
| description | string | 選填 | 訂單描述,會顯示在支付頁面 |
| notifyUrl | string | 選填 | 支付結果異步通知地址 |
| returnUrl | string | 選填 | 支付完成後跳轉地址 |
請求示例
curl -X POST 'https://easylink-api-v2.jimsbond007.workers.dev/api/v1/{merchantCode}/payment/create' \\
-H 'Authorization: Bearer {your_api_key}' \\
-H 'Content-Type: application/json' \\
-d '{
"amount": 100.00,
"payType": "UP_OP",
"orderNo": "ORDER_202403250001",
"description": "商品購買",
"notifyUrl": "https://your-site.com/webhook",
"returnUrl": "https://your-site.com/payment/success"
}'
響應示例(成功)
{
"success": true,
"data": {
"orderNo": "KC20240325120000ABC123",
"payOrderId": "P202403251200001234567",
"payUrl": "https://cashier.95516.com/...",
"amount": 100.00,
"currency": "HKD",
"status": "pending",
"createdAt": "2024-03-25T12:00:00+08:00"
}
}
查詢訂單狀態和詳情
請求示例
curl -X GET 'https://easylink-api-v2.jimsbond007.workers.dev/api/v1/{merchantCode}/payment/query?orderNo=KC20240325120000ABC123' \\
-H 'Authorization: Bearer {your_api_key}'
響應示例
{
"success": true,
"data": {
"orderNo": "KC20240325120000ABC123",
"payOrderId": "P202403251200001234567",
"amount": 100.00,
"status": "success",
"payType": "UP_OP",
"paidAt": "2024-03-25T12:05:30+08:00",
"channelOrderNo": "202403251200001234567890"
}
}
💸 退款 API
對已支付訂單發起退款(支持部分退款)
| 參數 | 類型 | 必填 | 說明 |
| orderNo | string | 必填 | 原支付訂單號 |
| refundAmount | number | 必填 | 退款金額(不能超過原訂單金額) |
| refundNo | string | 選填 | 商戶退款單號,系統會自動生成 |
| reason | string | 選填 | 退款原因 |
| notifyUrl | string | 選填 | 退款結果通知地址 |
請求示例
curl -X POST 'https://easylink-api-v2.jimsbond007.workers.dev/api/v1/{merchantCode}/refund/create' \\
-H 'Authorization: Bearer {your_api_key}' \\
-H 'Content-Type: application/json' \\
-d '{
"orderNo": "KC20240325120000ABC123",
"refundAmount": 50.00,
"reason": "客戶要求部分退款",
"notifyUrl": "https://your-site.com/refund/webhook"
}'
注意:同一訂單可以多次退款,但累計退款金額不能超過原訂單金額。
📬 Webhook 通知
當訂單狀態變更時,我們會向您配置的 notifyUrl 發送異步通知。
通知頻率:0s / 30s / 60s / 90s / 120s / 150s(最多 6 次)
響應要求:您的服務器需要返回字符串 "success"(小寫)
支付通知內容
{
"event": "payment.success",
"orderNo": "KC20240325120000ABC123",
"payOrderId": "P202403251200001234567",
"amount": 100.00,
"status": "success",
"payType": "UP_OP",
"paidAt": "2024-03-25T12:05:30+08:00",
"channelOrderNo": "202403251200001234567890",
"sign": "a1b2c3d4e5f6..."
}
⚠️ 錯誤碼對照表
| 錯誤碼 | 說明 | 處理建議 |
| 4001 | 參數缺失 | 檢查請求參數是否完整 |
| 4002 | 簽名錯誤 | 檢查 API Key 和簽名算法 |
| 4003 | 訂單不存在 | 檢查 orderNo 是否正確 |
| 4004 | 訂單已支付 | 該訂單已完成支付,不能重複支付 |
| 4005 | 餘額不足 | 商戶賬戶餘額不足,請充值 |
| 4006 | 退款超額 | 退款金額超過可退款餘額 |
| 5001 | 服務器內部錯誤 | 請聯繫技術支持 |
💻 SDK 示例
class EasyLinkClient {
constructor(apiKey, merchantCode, baseUrl) {
this.apiKey = apiKey;
this.merchantCode = merchantCode;
this.baseUrl = baseUrl;
}
async createPayment(params) {
const response = await fetch(
`${this.baseUrl}/api/v1/${this.merchantCode}/payment/create`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
}
);
return response.json();
}
async queryOrder(orderNo) {
const response = await fetch(
`${this.baseUrl}/api/v1/${this.merchantCode}/payment/query?orderNo=${orderNo}`,
{
headers: { 'Authorization': `Bearer ${this.apiKey}` }
}
);
return response.json();
}
}
// 使用示例
const client = new EasyLinkClient(
'pk_live_your_api_key',
'KC',
'https://easylink-api-v2.jimsbond007.workers.dev'
);
const result = await client.createPayment({
amount: 100.00,
payType: 'UP_OP',
description: '商品購買'
});
if (result.success) {
window.location.href = result.data.payUrl;
}
import requests
class EasyLinkClient:
def __init__(self, api_key, merchant_code, base_url):
self.api_key = api_key
self.merchant_code = merchant_code
self.base_url = base_url
def create_payment(self, params):
url = f"{self.base_url}/api/v1/{self.merchant_code}/payment/create"
headers = {
"Authorization": f"Bearer {self.api_key}",
"Content-Type": "application/json"
}
return requests.post(url, json=params, headers=headers).json()
def query_order(self, order_no):
url = f"{self.base_url}/api/v1/{self.merchant_code}/payment/query"
headers = {"Authorization": f"Bearer {self.api_key}"}
return requests.get(url, params={"orderNo": order_no}, headers=headers).json()
<?php
class EasyLinkClient {
private $apiKey;
private $merchantCode;
private $baseUrl;
public function __construct($apiKey, $merchantCode, $baseUrl) {
$this->apiKey = $apiKey;
$this->merchantCode = $merchantCode;
$this->baseUrl = $baseUrl;
}
public function createPayment($params) {
$url = "{$this->baseUrl}/api/v1/{$this->merchantCode}/payment/create";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer {$this->apiKey}",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
return json_decode(curl_exec($ch), true);
}
}
?>
📞 技術支持
集成過程中遇到問題?
請聯繫我們的技術支持團隊:
📧 Email: support@easylink.com.hk
📱 WhatsApp: +852 9811 3210
🕐 服務時間:週一至週五 9:00-18:00