Payout Components SDK
1. 概述
Midasbuy Payout Components SDK 是一个统一 Payout Components 加载器。该 SDK 提供开箱即用且可定制的组件,用于处理国际汇款与收款人信息管理。
2. 接入步骤
步骤 1. 安装并引入 SDK
# npm
npm install @txgw/payout-components
# pnpm
pnpm add @txgw/payout-components
# yarn
yarn add @txgw/payout-components
import { init, createElement } from "@txgw/payout-components";
步骤 2. 初始化 SDK
2.1 生成 code_verifier
在调用 SDK 初始化前,需要在前端生成 PKCE code_verifier。该值在交换授权码时是必需的,并遵循 RFC 7636 第 4 节。示例如下:
const dec2hex = (dec: number) => {
return ("0" + dec.toString(16)).slice(-2);
};
const generateCodeVerifier = () => {
const length = Math.random() * (129 - 43) + 43;
const array = new Uint32Array(length / 2);
window.crypto.getRandomValues(array);
return Array.from(array, dec2hex).join("");
};
const codeVerifier = generateCodeVerifier();
请将 codeVerifier 通过安全通道发送到服务端以便后续生成 code_challenge。
请先在服务端安装
js-base64以便对哈希结果进行编码:
npm install js-base64