API 文档介绍

访问官方文档

ePayments支付接口规范描述了 第三方商城 商户系统与ePayments支付系统的相关协议, 包括支付调起接口、支付结果同步返回接口、支付结果异步通知接口、查询支付接口和申请退款接口。

ePayments支付接口规范对ePayments系统协作中的交互模式、数据交互格式、安全机制等制定了统一标准。

基本信息

  • 所有澳洲的API请求都应发送到 https://api.wetopay.com/api/v1
  • 所有新西兰和其他地区的API请求都应发送到 https://www.kiwifast.com/api/v1
  • 所有请求和响应数据都采用JSON格式
  • 所有请求都需要使用HTTPS

签名算法

为确保API调用的安全性,所有请求都需要进行签名验证。签名使用MD5算法,按照以下步骤生成:

签名步骤
  1. 将所有参数按照键名进行字典序排序
  2. 将排序后的参数以 key=value&key=value 的格式拼接成字符串
  3. 在字符串末尾追加商户密钥
  4. 对最终字符串进行MD5加密,得到32位小写签名
示例代码
const crypto = require('crypto');

function nonce_str(length = 16) {
    return crypto.randomBytes(length).toString('hex').slice(0, length);
}

function generateSignature(params, secretKey) {

    // Step 1: Sort parameters by key
    const sortedKeys = Object.keys(params).sort();
    
    // Step 2: Create the query string
    const signString = sortedKeys.map(key => `${key}=${params[key]}`).join('&');

    // Step 3: Append the secret key
    const signStringKey = signString + secretKey;

    // Step 5: Generate MD5 hash
    const signature = crypto.createHash('md5')
        .update(signStringKey, 'utf8')
        .digest('hex');

    return signature;
}
使用示例
// 请求参数示例
const params = {
    merchant_id: '123456',
    nonce_str: nonce_str(),
    timestamp: Math.floor(Date.now() / 1000),
    order_id: 'ORDER_123',
    amount: 100
};

const secretKey = 'your_secret_key';
const signature = generateSignature(params, secretKey);

// 将签名添加到请求参数中
params.signature = signature;

console.log('最终请求参数:', params);
注意:请勿在客户端进行签名操作,应在服务器端完成签名以确保密钥安全。