跳到主要内容

API 签名

sso-login认证

信息

集成将从登录 API 开始,该 API 将对客户进行身份验证。 身份验证方法:使用 payment gateway system 颁发的密钥对 ssoCustomerId 进行 HMAC 哈希处理

身份验证步骤:

商家网站根据 ssoCustomerId 为登录用户创建带有共享密钥的 sso 哈希,然后将该哈希传递给登录 API 登录 API 将进行身份验证并发出 JWT 承载令牌以供后续 API 访问。 在 API 请求中发送授权标头的 Node.js 示例:

提示

ssoCustomerId 在整个认证中请保持一致,以便于确保验签的通过,同时也保证相关请求的一致性

创建和验证哈希的 Node.js 示例:

const crypto = require('crypto')
const sharedSecretKey = 'abcdef12-abcd-abcd-abcd-abcdef012345' // 商户完成 onboarding 后发送至邮箱的 SecretKey
const sso_customer_id = '' // 商户自定义的唯一id

const hash = crypto
.createHmac('sha256', sharedSecretKey)
.update(sso_customer_id)
.digest('hex')
注意

密钥必须作为密钥安全地存储在商家的服务器中,并且绝不能暴露给前端

身份验证失败返回:

{ "message": "Missing Authentication Token" }

public api签名

备注

商家在调用 payment gateway system 的公共api时需要添加此签名到http header

注意

签名的body 字段顺序一定要按照文档的字段顺序进行签名否则会导致验签失败

nodejs 示例

const ssoOrderId =  "API-TEST-NUVEI-TESTER-03"
const sign = crypto
.createHmac('sha256', YourSecretKey) // 由 payment gateway system 下发的 秘钥
.update(ssoOrderId)
.digest('hex');

const body = {
ssoOrderId: ssoOrderId,
merchantId: "1" ,
sign: sign,
status:'S'
}

const hash = crypto
.createHmac('sha256', YourSecretKey) // 由 payment gateway system 下发的 秘钥
.update(JSON.stringify(body))
.digest('hex');

const url = 'https://api-onramp.eopay.io/webhook/update-order-status'
const response = await fetch(url, {
method: 'POST',
body: JSON.stringify(body),
headers: { 'X-HMAC-SIGNATURE': hash}
})

退款和更新订单状态api签名

备注

商家在调用 payment gateway system 的公共api时需要添加此签名到http header

注意

签名的body 字段顺序一定要按照文档的字段顺序进行签名否则会导致验签失败

nodejs 示例

const sign = crypto
.createHmac('sha256', YourSecretKey) // 由 payment gateway system 下发的密钥
.update(ssoOrderId) // 商户定义的ssoOrderId
.digest('hex');

const url = 'https://api-onramp.eopay.io/payment/refund-payment'
const response = await fetch(url, {
method: 'POST',
body: JSON.stringify(body),
headers: { 'X-HMAC-SIGNATURE': hash}
})

获取订单状态签名

const data = { ssoOrderId: 'ssoOrderId', merchantId: 'merchantId' }
const hash = crypto
.createHmac('sha256', YourSecretKey)
.update(JSON.stringify(data))
.digest('hex');

const url = 'https://api-onramp.eopay.io/order/get-sso-order-status'
const response = await fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: { 'X-HMAC-SIGNATURE': hash}
})