zkpsdk-client 中文文档教程

发布于 2年前 浏览 11 项目主页 更新于 2年前

功能

  • 允许商家访问 ZKPay API 以创建订单/交易、获取交易信息等

安装

客户端需要 Node.js v10+ 才能运行。 安装依赖项并启动服务器。

npm i zkpsdk-client

使用此客户端所需的信息

#描述
代码注册 zkpay 时接收。用于识别
商户秘密注册到zkpay时接收的 。用于商户之间的哈希/安全检查数据 - zkpay
apiKey注册到 zkpay 时接收。用于访问标头为“x-api-key”的商户 API
returnUrl支付成功后返回页面/回调页面呈现给用户。 成功后,zkpay 会将用户重定向至 https://merchant.site/order?id=[merchantOrder]
示例:returnUrl: https://merchant.site/order 支付测试使用 test/sandbox 环境

开发

  1. 创建支付重定向页面:
...
 // init client
  const client = new ZkClient({
      code: "...",
      secret: "...",
      apiKey: "...",
      returnUrl: "...",
      test: true,
  });

 // init order
 const order: MerchantOrder = {
    orderId: "...",
    userId: "...",
    amount: 1000000,
};

// create payment url
const redirectUrl = client.getOrderRedirectUrl(order);
...
  1. 回调结果 当 zkpay 收到您的订单付款时。具有详细负载的回调操作将执行到商家注册的钩子 API

Init order ->重定向至zkpay ->用户付款->订单成功回调

#描述
merchantId您的注册ID,用于标识该交易属于哪个商户
merchantOrder您的订单ID
状态您订单的zkpay 交易状态。 “成功”=>已付费, // 或已过期 =>未付款
transactionIdzkpay 交易 ID

在某些意外情况下,您的订单可能会被标记为 EXPIRED(由于银行延迟)。再次收到成功付款后我们会执行回调动作。 在这种情况下,请处理以下流程:

Init order ->重定向至zkpay ->用户付款(银行延迟)->订单过期回调-> (zkpay收款->订单成功回调)

Features

  • Allow merchant access to ZKPay APIs to create order/transaction, get transaction information and more

Installation

The client requires Node.js v10+ to run. Install the dependencies and start the server.

npm i zkpsdk-client

Required information to use this client

#Description
codeReceive when registered to zkpay. Use to identify merchant
secretReceive when registered to zkpay. Use for hash/security check data between merchant - zkpay
apiKeyReceive when registered to zkpay. Use for access to merchant APIs with header "x-api-key"
returnUrlReturn page/Callback page after success payment to render to user. Example: returnUrl: https://merchant.site/order then zkpay will redirect user to https://merchant.site/order?id=[merchantOrder] after success payment
testUse test/sandbox environment

Development

  1. Create payment redirect page:
...
 // init client
  const client = new ZkClient({
      code: "...",
      secret: "...",
      apiKey: "...",
      returnUrl: "...",
      test: true,
  });

 // init order
 const order: MerchantOrder = {
    orderId: "...",
    userId: "...",
    amount: 1000000,
};

// create payment url
const redirectUrl = client.getOrderRedirectUrl(order);
...
  1. Callback result When zkpay receive payment of your order. A callback action with detail payload will execute to merchant registered hook API

Init order -> Redirect to zkpay -> user make a payment -> success order callback

#Description
merchantIdYour registered ID to identity which merchant the transaction belongs to
merchantOrderYour order ID
statusStatus of zkpay transaction for your order. "SUCCESS" => Paid, // or EXPIRED => Unpaid
transactionIdzkpay transaction ID

In some unexpected cases, your order can be marked as EXPIRED (due to banking delay). We will execute the callback action after receive success payment again. In this case please handle the following flow:

Init order -> Redirect to zkpay -> user make a payment (banking delay) -> Order expired callback -> (zkpay receive payment -> success order callback)

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文