@kevisual/payonner
v1.0.4
Published
Payoneer API 集成库,用于 Node.js。
Readme
Payonner
Payoneer API 集成库,用于 Node.js。
安装
pnpm install @kevisual/payonner环境配置
在 .env 文件中配置以下环境变量:
PAYONNER_PROGRAM_ID=your_program_id
PAYONNER_CLIENT_KEY=your_client_key
PAYONNER_CLIENT_SECRET=your_client_secret
PAYONNER_ENVIRONMENT=sandbox # 或 productionpayonner 参考API文档
https://developer.payoneer.com/docs/mass-payouts-v4.html#/9cb9f3a03440b-create-registration-linkPayoneerClient
Payoneer API 客户端,用于获取 Access Token 和创建 Registration Link。
获取 Access Token
import { PayoneerClient } from '@kevisual/payonner';
const client = new PayoneerClient({
programId: 'your_program_id',
clientKey: 'your_client_key',
clientSecret: 'your_client_secret',
environment: 'sandbox', // 或 'production'
});
const result = await client.getAccessToken();
// 返回: { status: 200, data: { access_token: 'xxx', expires_in: 2592000, ... } }创建 Registration Link
// 设置 Access Token
client.setAccessToken(result.data.access_token);
// 创建 Registration Link
const result = await client.createRegistrationLink('payee_id', {
redirect_url: 'https://your-callback-url.com',
state: 'optional-state',
});
// 返回: { status: 200, data: { registration_link: 'https://...' } }完整示例
import { PayoneerClient } from '@kevisual/payonner';
async function main() {
const client = new PayoneerClient({
programId: process.env.PAYONNER_PROGRAM_ID!,
clientKey: process.env.PAYONNER_CLIENT_KEY!,
clientSecret: process.env.PAYONNER_CLIENT_SECRET!,
environment: 'sandbox',
});
// 1. 获取 Access Token
const tokenResult = await client.getAccessToken();
console.log('Access Token:', tokenResult.data.access_token);
// 2. 设置 Token
client.setAccessToken(tokenResult.data.access_token);
// 3. 创建 Registration Link
const linkResult = await client.createRegistrationLink('RutenTaiwan', {
redirect_url: 'https://example.com/callback',
});
console.log('Registration Link:', linkResult.data.registration_link);
}
main();API 参考
PayoneerClient
new PayoneerClient(config: PayoneerConfig)PayoneerConfig
| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| programId | string | 是 | Payoneer Program ID |
| clientKey | string | 是 | Client Key |
| clientSecret | string | 是 | Client Secret |
| accessToken | string | 否 | Access Token(后续调用 API 需要) |
| environment | 'sandbox' \| 'production' | 否 | 环境,默认 sandbox |
方法
getAccessToken(scope?: string): Promise<ApiResponse<TokenResponse>>
获取 OAuth Access Token。
setAccessToken(token: string): void
设置 Access Token。
createRegistrationLink(payeeId: string, params?: CreateRegistrationLinkParams): Promise<ApiResponse<RegistrationLinkResponse>>
创建 Registration Link。
getLoginUrl(): string
获取 Login URL。
getApiBaseUrl(): string
获取 API Base URL。
License
ISC
