{"_id":"@bebebus/merchant-openapi-sdk","_rev":"8-f98720ca30d0797faf488d90c75ee42a","name":"@bebebus/merchant-openapi-sdk","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@bebebus/merchant-openapi-sdk","version":"1.0.0","keywords":["payment","openapi","merchant","sdk"],"license":"MIT","_id":"@bebebus/merchant-openapi-sdk@1.0.0","maintainers":[{"name":"bebebus","email":"fitz@zerotier.email"}],"homepage":"https://github.com/bebebus/SDK/tree/main/nodejs#readme","bugs":{"url":"https://github.com/bebebus/SDK/issues"},"dist":{"shasum":"21573139eea60a9ecd30b01b330916c36cf9264d","tarball":"https://registry.npmjs.org/@bebebus/merchant-openapi-sdk/-/merchant-openapi-sdk-1.0.0.tgz","fileCount":11,"integrity":"sha512-sM206lFFjuAJIU/Vr/jCE5SKB0W4avtlzraN4aZ9mh6l7+9mhipTbQnkC0Xc+hrSb2Aju1NTBGawGGspaAUeBw==","signatures":[{"sig":"MEUCIFvG03ibqLQ0/P+jyzZNOSOrhewWAVIgfJVvDRvroBeHAiEA0Ydt1f8EZJkji454hjxK/niFP9R36tS1sCVHOyHPAXo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32046},"main":"src/index.js","type":"module","engines":{"node":">=18"},"exports":{".":"./src/index.js"},"gitHead":"6041ffddaa9dfe57ded0a6610617f09c8ed6c1db","scripts":{"test":"node --test"},"_npmUser":{"name":"bebebus","email":"fitz@zerotier.email"},"repository":{"url":"git+https://github.com/bebebus/SDK.git","type":"git","directory":"nodejs"},"_npmVersion":"10.5.0","description":"商户支付 OpenAPI Node.js SDK（零第三方依赖，ESM）","directories":{},"_nodeVersion":"21.7.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/merchant-openapi-sdk_1.0.0_1782161743134_0.2221295298307706","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@bebebus/merchant-openapi-sdk","version":"1.1.0","keywords":["payment","openapi","merchant","sdk"],"license":"MIT","_id":"@bebebus/merchant-openapi-sdk@1.1.0","maintainers":[{"name":"bebebus","email":"fitz@zerotier.email"}],"homepage":"https://github.com/bebebus/SDK/tree/main/nodejs#readme","bugs":{"url":"https://github.com/bebebus/SDK/issues"},"dist":{"shasum":"5a5669c4603ae1af142edf01ab2629c0e95e3015","tarball":"https://registry.npmjs.org/@bebebus/merchant-openapi-sdk/-/merchant-openapi-sdk-1.1.0.tgz","fileCount":11,"integrity":"sha512-PrRX5S26NYm1cG3TuUi55FrBKgEPS6qPEASdXyhJniHH99Lr4W/jzs1gSmHr4PRJteiTplJ7w5HLvENQw/8ZGg==","signatures":[{"sig":"MEYCIQDjSTVFZfIXrf5WRZP8XU4HguqdhBjGim/Q/Eiog4L5cgIhAKGNbH8bSUehodid6/JVZ2I9FBfMkZg3kKFohIVDyU91","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36050},"main":"src/index.js","type":"module","engines":{"node":">=18"},"exports":{".":"./src/index.js"},"gitHead":"4fb3cbf142a170ca21ff029c0bb99a17a8d1bfb4","scripts":{"test":"node --test"},"_npmUser":{"name":"bebebus","email":"fitz@zerotier.email"},"repository":{"url":"git+https://github.com/bebebus/SDK.git","type":"git","directory":"nodejs"},"_npmVersion":"10.5.0","description":"商户支付 OpenAPI Node.js SDK（零第三方依赖，ESM）","directories":{},"_nodeVersion":"21.7.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/merchant-openapi-sdk_1.1.0_1782192639239_0.9118155772035108","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@bebebus/merchant-openapi-sdk","version":"1.1.1","keywords":["payment","openapi","merchant","sdk"],"license":"MIT","_id":"@bebebus/merchant-openapi-sdk@1.1.1","maintainers":[{"name":"bebebus","email":"fitz@zerotier.email"}],"homepage":"https://github.com/bebebus/SDK/tree/main/nodejs#readme","bugs":{"url":"https://github.com/bebebus/SDK/issues"},"dist":{"shasum":"efcf1a64ce33b0cb495cc7ef18c41cdcec75af41","tarball":"https://registry.npmjs.org/@bebebus/merchant-openapi-sdk/-/merchant-openapi-sdk-1.1.1.tgz","fileCount":13,"integrity":"sha512-8GMSJ4pBRQoPaVjBfuI1KGcU/lHWizI8rGRUbV7B/F+fnlhNzWPuN4pz9aTT0WBvR6fcjrwEsdhfCsyToyGk9w==","signatures":[{"sig":"MEYCIQC2+gy8eUBtL9oPCFfTbLzt3jZJTc6psxopSKTHg722gAIhAPCRTfmDdf+g2SVhR+gUxi9c+EsQWCNTrKkz7gG8Z7en","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51075},"main":"src/index.js","type":"module","types":"src/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./src/index.d.ts","default":"./src/index.js"}},"gitHead":"7870f41dd964ec2aacc88bb30c17b24b1a8afd9d","scripts":{"test":"node --test"},"_npmUser":{"name":"bebebus","email":"fitz@zerotier.email"},"repository":{"url":"git+https://github.com/bebebus/SDK.git","type":"git","directory":"nodejs"},"_npmVersion":"10.5.0","description":"商户支付 OpenAPI Node.js SDK（零第三方依赖，ESM）","directories":{},"_nodeVersion":"21.7.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/merchant-openapi-sdk_1.1.1_1782395070827_0.8676756475959237","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@bebebus/merchant-openapi-sdk","version":"1.1.2","keywords":["payment","openapi","merchant","sdk"],"license":"MIT","_id":"@bebebus/merchant-openapi-sdk@1.1.2","maintainers":[{"name":"bebebus","email":"fitz@zerotier.email"}],"homepage":"https://github.com/bebebus/SDK/tree/main/nodejs#readme","bugs":{"url":"https://github.com/bebebus/SDK/issues"},"dist":{"shasum":"fd3fc25893cde22727aed84eb633a5df059c46e0","tarball":"https://registry.npmjs.org/@bebebus/merchant-openapi-sdk/-/merchant-openapi-sdk-1.1.2.tgz","fileCount":13,"integrity":"sha512-2RKknOZKxZb0c3BotXqxRlZPdPq9vqtOhn1eaSZuT1vH3fpVfd9VN0Vw6UXrpY5DZBZqQzXXhUOuq8TF+t8+JQ==","signatures":[{"sig":"MEYCIQDJMcneWmtIUaGLqVLxkG/mZQrCXRjm6kTGfsKzs9OgqAIhAL4wwYSqv9DcsRM9ur3fjwzeNZOpmeRJuAwyYFJN160Y","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51048},"main":"src/index.js","type":"module","types":"src/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./src/index.d.ts","default":"./src/index.js"}},"gitHead":"8911614f02ab59c2fcc418fe088b2959f219f660","scripts":{"test":"node --test"},"_npmUser":{"name":"bebebus","email":"fitz@zerotier.email"},"repository":{"url":"git+https://github.com/bebebus/SDK.git","type":"git","directory":"nodejs"},"_npmVersion":"10.9.8","description":"商户支付 OpenAPI Node.js SDK（零第三方依赖，ESM）","directories":{},"_nodeVersion":"22.23.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/merchant-openapi-sdk_1.1.2_1783699781540_0.24642981182518975","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@bebebus/merchant-openapi-sdk","version":"1.2.0","keywords":["payment","openapi","merchant","sdk"],"license":"MIT","_id":"@bebebus/merchant-openapi-sdk@1.2.0","maintainers":[{"name":"bebebus","email":"fitz@zerotier.email"}],"homepage":"https://github.com/bebebus/SDK/tree/main/nodejs#readme","bugs":{"url":"https://github.com/bebebus/SDK/issues"},"dist":{"shasum":"f5fddcf75d4487e98aaf1e3a3b15dcc39c86d8ac","tarball":"https://registry.npmjs.org/@bebebus/merchant-openapi-sdk/-/merchant-openapi-sdk-1.2.0.tgz","fileCount":13,"integrity":"sha512-agoP8o/Ss4oMcHkIPYuN6SfHtvYfRjxu2bU/3TTsYfjxD2u8vep2Pm2fc20gZsI/vQiaPFaTpcrKQlBklVNI0w==","signatures":[{"sig":"MEUCIQDPyCDDb8VwhsTl1q8m37Sgb0zuubKBbTdN/04kiHo99gIgbCDfXJHicyVXT87W36XIGM8Wgr1rx/RDO8DjTmUVVKY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":53488},"main":"src/index.js","type":"module","types":"src/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./src/index.d.ts","default":"./src/index.js"}},"gitHead":"b4e658f12227d4a8ceec3ddba2bc144ed05fbcd5","scripts":{"lint":"biome check .","test":"node --test"},"_npmUser":{"name":"bebebus","email":"fitz@zerotier.email"},"repository":{"url":"git+https://github.com/bebebus/SDK.git","type":"git","directory":"nodejs"},"_npmVersion":"10.9.8","description":"商户支付 OpenAPI Node.js SDK（零第三方依赖，ESM）","directories":{},"_nodeVersion":"22.23.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@biomejs/biome":"2.5.8"},"_npmOperationalInternal":{"tmp":"tmp/merchant-openapi-sdk_1.2.0_1786713093969_0.8359673291151488","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@bebebus/merchant-openapi-sdk","version":"1.2.1","keywords":["payment","openapi","merchant","sdk"],"license":"MIT","_id":"@bebebus/merchant-openapi-sdk@1.2.1","maintainers":[{"name":"bebebus","email":"fitz@zerotier.email"}],"homepage":"https://github.com/bebebus/SDK/tree/main/nodejs#readme","bugs":{"url":"https://github.com/bebebus/SDK/issues"},"dist":{"shasum":"82c122043bcc272f118c6c7ffbd64f530dcde84e","tarball":"https://registry.npmjs.org/@bebebus/merchant-openapi-sdk/-/merchant-openapi-sdk-1.2.1.tgz","fileCount":13,"integrity":"sha512-GK0RYas/3Yle3JzVchJyaVumuhmuRMrflb4FyE32sBKPULCyBoxHow76Wmlng1gUuQb8M2ZuyHM1TpSr1Y7R1g==","signatures":[{"sig":"MEUCIQDwG9d6xtbkv0o8lhgnNSOLUhJXwfa3Xazy+5KI4bK9FQIgDjTgwhKR1AxL1l1AYCDtMoeGbMB3cuCwObHRnXuAd5k=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@bebebus%2fmerchant-openapi-sdk@1.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":53504},"main":"src/index.js","type":"module","types":"src/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./src/index.d.ts","default":"./src/index.js"}},"gitHead":"5b3700e4a877e84b5de14f7c27b780266538604e","scripts":{"lint":"biome check .","test":"node --test"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:0339aaf4-4ba9-41e0-a84b-d399682d61e1"}},"repository":{"url":"git+https://github.com/bebebus/SDK.git","type":"git","directory":"nodejs"},"_npmVersion":"12.0.2","description":"商户支付 OpenAPI Node.js SDK（零第三方依赖，ESM）","directories":{},"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@biomejs/biome":"2.5.8"},"_npmOperationalInternal":{"tmp":"tmp/merchant-openapi-sdk_1.2.1_1786722219254_0.2995170199876447","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"@bebebus/merchant-openapi-sdk","version":"1.3.0","keywords":["payment","openapi","merchant","sdk"],"license":"MIT","_id":"@bebebus/merchant-openapi-sdk@1.3.0","maintainers":[{"name":"bebebus","email":"fitz@zerotier.email"}],"homepage":"https://github.com/bebebus/SDK/tree/main/nodejs#readme","bugs":{"url":"https://github.com/bebebus/SDK/issues"},"dist":{"shasum":"5710b95d316f078d3eb4981158e5668d4ada8808","tarball":"https://registry.npmjs.org/@bebebus/merchant-openapi-sdk/-/merchant-openapi-sdk-1.3.0.tgz","fileCount":13,"integrity":"sha512-0U11wTWw/S47krMCTL0YWFMz/kOWC+3kXsFZ8Av66xKjDD9gRBzbcPrqNQsYr0Xdef8BtEXQSgWOsRTtBgvrvg==","signatures":[{"sig":"MEQCIDKb+PC5xsMr/hOWC3GTHm/0lhD/zZOV5KFsD30F6WGKAiB5lfqSAIX3Xz7/Z2cqFfts0ZaabWySuuZADqFPsQKL6w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@bebebus%2fmerchant-openapi-sdk@1.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":56621},"main":"src/index.js","type":"module","types":"src/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./src/index.d.ts","default":"./src/index.js"}},"gitHead":"9994175989480557ea1c12a72e943715d04be890","scripts":{"lint":"biome check .","test":"node --test"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:0339aaf4-4ba9-41e0-a84b-d399682d61e1"}},"repository":{"url":"git+https://github.com/bebebus/SDK.git","type":"git","directory":"nodejs"},"_npmVersion":"12.0.2","description":"商户支付 OpenAPI Node.js SDK（零第三方依赖，ESM）","directories":{},"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@biomejs/biome":"2.5.8"},"_npmOperationalInternal":{"tmp":"tmp/merchant-openapi-sdk_1.3.0_1786797751997_0.3235793616952365","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bebebus/merchant-openapi-sdk","version":"2.0.0","description":"商户支付 OpenAPI Node.js SDK（零第三方依赖，ESM）","type":"module","main":"src/index.js","types":"src/index.d.ts","exports":{".":{"types":"./src/index.d.ts","default":"./src/index.js"}},"scripts":{"lint":"biome check .","test":"node --test"},"devDependencies":{"@biomejs/biome":"2.5.8"},"engines":{"node":">=18"},"license":"MIT","keywords":["payment","openapi","merchant","sdk"],"repository":{"type":"git","url":"git+https://github.com/bebebus/SDK.git","directory":"nodejs"},"homepage":"https://github.com/bebebus/SDK/tree/main/nodejs#readme","bugs":{"url":"https://github.com/bebebus/SDK/issues"},"publishConfig":{"access":"public"},"gitHead":"db0246647000c38a203b31331709671f3e75ef3a","_id":"@bebebus/merchant-openapi-sdk@2.0.0","_nodeVersion":"22.23.2","_npmVersion":"12.0.2","dist":{"integrity":"sha512-Xr5HjeDL7UV/m5lzrYhu2rn+bJJA0nKyVZLY8gLTlJO4oqbTwN2ShaStbSYMAGtguBTUXuy0Rw6VGEuovmiZgg==","shasum":"a2dd442f80c137322bb3cc1b030744202be57a3e","tarball":"https://registry.npmjs.org/@bebebus/merchant-openapi-sdk/-/merchant-openapi-sdk-2.0.0.tgz","fileCount":13,"unpackedSize":53079,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@bebebus%2fmerchant-openapi-sdk@2.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBMTSQwyHNmuZNeMLWONnHzGME8XaFp8brB39Qw7ST1XAiBFrFQV1I6K0jxCW0dSz/hX1vwYeXdCKKuTDMNj4B0e1w=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:0339aaf4-4ba9-41e0-a84b-d399682d61e1"}},"directories":{},"maintainers":[{"name":"bebebus","email":"fitz@zerotier.email"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/merchant-openapi-sdk_2.0.0_1787042945794_0.5299908847758243"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-22T20:55:42.962Z","modified":"2026-08-18T08:49:06.228Z","1.0.0":"2026-06-22T20:55:43.275Z","1.1.0":"2026-06-23T05:30:39.379Z","1.1.1":"2026-06-25T13:44:30.978Z","1.1.2":"2026-07-10T16:09:41.710Z","1.2.0":"2026-08-14T13:11:34.102Z","1.2.1":"2026-08-14T15:43:39.393Z","1.3.0":"2026-08-15T12:42:32.150Z","2.0.0":"2026-08-18T08:49:05.933Z"},"bugs":{"url":"https://github.com/bebebus/SDK/issues"},"license":"MIT","homepage":"https://github.com/bebebus/SDK/tree/main/nodejs#readme","keywords":["payment","openapi","merchant","sdk"],"repository":{"type":"git","url":"git+https://github.com/bebebus/SDK.git","directory":"nodejs"},"description":"商户支付 OpenAPI Node.js SDK（零第三方依赖，ESM）","maintainers":[{"name":"bebebus","email":"fitz@zerotier.email"}],"readme":"> 中文 | [English](./README.en.md)\n\n# 商户支付 OpenAPI —— Node.js SDK（ESM）\n\n[![npm](https://img.shields.io/npm/v/@bebebus/merchant-openapi-sdk?label=npm)](https://www.npmjs.com/package/@bebebus/merchant-openapi-sdk) [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)\n\n零第三方依赖：仅使用 Node 标准库（`node:http` / `node:https`、`node:crypto`、`node:test`）。\n签名、HTTP、JSON、测试框架全部用官方内建，**无需 `npm install`**。\n\n- 签名算法：HMAC-SHA256 → hex 小写，见仓库根 [`SIGNING.md`](../SIGNING.md)\n- 接口契约：环境/鉴权/12 个签名端点/回调/错误码，见 [`INTERFACES.md`](../INTERFACES.md)\n- 标准答案向量：[`test-vectors.json`](../test-vectors.json)\n- 附录配置（可查看 / 下载）：[`appendix/config.example.json`](./appendix/config.example.json) · [`appendix/catalog.json`](./appendix/catalog.json)\n\n下载地址：\n- 配置模板：https://raw.githubusercontent.com/bebebus/SDK/main/nodejs/appendix/config.example.json （[文档站](https://openapi.overseas.cniia.cloud/sdk-config/config.example.json)）\n- 国家/币种附录：https://raw.githubusercontent.com/bebebus/SDK/main/nodejs/appendix/catalog.json （[文档站](https://openapi.overseas.cniia.cloud/appendix/catalog.json)）\n\n## 引入（无需安装依赖）\n\n要求 Node ≥ 18（用到 `node:test`、`crypto.randomUUID`、`crypto.timingSafeEqual`）。\n\n```js\n// 直接从源码导入\nimport { Client, Config, Environment, ApiError, TransportError } from './src/index.js';\n```\n\n如作为本地包引用，在你的 `package.json` 用文件路径依赖即可（本包自身 `dependencies` 为空）：\n\n```json\n{ \"dependencies\": { \"merchant-openapi-sdk\": \"file:../sdk/nodejs\" } }\n```\n\n本包是 ESM（`\"type\": \"module\"`），调用方需用 `import`（或在 CJS 中用动态 `import()`）。\n\n## 快速开始\n\n```js\nimport { Client, Config, Environment } from './src/index.js';\n\nconst client = new Client(new Config({\n  merchantNo: 'M00000001',\n  apiKey: 'ak_xxx',\n  apiSecretPay: 'sk_pay_xxx',       // pay 类接口 / 代收·退款回调\n  apiSecretPayout: 'sk_payout_xxx', // payout 类接口 / 代付回调\n  // PRODUCTION 无内置 URL，必须显式传入\n  baseUrl: 'https://api.<service_domain>/api/open/v1',\n}));\n\n// 代收下单（pay_method 必填；金额是最小单位整数，10000 = 1 元）\nconst { data, raw } = await client.payCreate({\n  out_order_no: 'ORDER_' + Date.now(),\n  amount: 10000,\n  currency: 'PHP',\n  pay_method: 'gcash',\n  country: 'PH',\n  notify_url: 'https://merchant.example.com/api/notify/pay',\n});\nconsole.log(data.pay_url, raw.code);\n```\n\n每个方法返回 `{ data, raw }`：`data` 是统一信封里的 `data` 字段，`raw` 是完整 `{code,message,data}`（保留拿原始响应的途径）。\n\n## 双环境 + 自定义基址\n\n```js\nimport { Config, Environment } from './src/index.js';\n\n// 预设：正式（无内置 URL，必须显式传 baseUrl，否则抛错）\nnew Config({ /* ... */ environment: Environment.PRODUCTION, baseUrl: 'https://api.<service_domain>/api/open/v1' });\n// 预设：本地/沙箱\nnew Config({ /* ... */ environment: Environment.SANDBOX });\n// 自定义（服务商提供的地址或自定义端口）—— baseUrl 优先于 environment\nnew Config({ /* ... */ baseUrl: 'https://api.<service_domain>/api/open/v1' });\n```\n\n| 预设 | Base URL |\n|------|----------|\n| `Environment.PRODUCTION` | 无内置 URL，请向服务商获取 `https://api.<service_domain>/api/open/v1`，并显式传入 `baseUrl` |\n| `Environment.SANDBOX` | `http://127.0.0.1:3090/api/open/v1` |\n\n## 全部 12 个端点\n\n| 方法 | 端点 | 密钥 |\n|------|------|------|\n| `payCreate(params)` | `/merchant/pay/create` | pay |\n| `payQuery(params)` | `/merchant/pay/query` | pay |\n| `payMethodsQuery(params?)` | `/merchant/pay-methods/query` | pay |\n| `groupsQuery(params?)` | `/merchant/groups/query` | pay（兼容别名） |\n| `balanceQuery(params?)` | `/merchant/balance/query` | pay |\n| `payTestComplete(params)` | `/merchant/pay/test/complete` | pay（仅测试密钥） |\n| `payoutCreate(params)` | `/merchant/payout/create` | payout |\n| `payoutQuery(params)` | `/merchant/payout/query` | payout |\n| `payoutBanksQuery(params)` | `/merchant/payout/banks/query` | payout |\n| `payoutProofQuery(params)` | `/merchant/payout/proof/query` | payout |\n| `payoutReceiptQuery(params)` | `/merchant/payout/receipt/query` | payout |\n| `payoutTestComplete(params)` | `/merchant/payout/test/complete` | payout（仅测试密钥） |\n\n请求构建说明：\n\n- 自动注入 `merchant_no`、`api_key`、`timestamp`（Unix 秒）与唯一 `nonce`（`crypto.randomUUID`）。\n- 值为 `null` / `undefined` 的字段**不放入请求体也不参与签名**。\n- `payoutReceiptQuery` 的 `inline` 会被转成**整数 `1`/`0`** 发送（避免布尔签名歧义）。\n- 客户端各方法自动选对密钥（pay 类用 `apiSecretPay`，payout 类用 `apiSecretPayout`）。\n\n## 错误处理\n\n```js\nimport { ApiError, TransportError } from './src/index.js';\n\ntry {\n  await client.payQuery({ out_order_no: 'x' });\n} catch (err) {\n  if (err instanceof ApiError) {\n    // 业务失败：code !== 0，携带 code/message/data 与原始信封 raw\n    console.error(err.code, err.message, err.data);\n  } else if (err instanceof TransportError) {\n    // HTTP/网络层：statusCode、body、cause\n    console.error(err.statusCode, err.body);\n  }\n}\n```\n\n## 回调验签（时序安全）\n\n`verifyCallback` / `client.verifyPayCallback` / `client.verifyPayoutCallback` 按「除 `sign` 外所有字段参与」通用计算（不硬编码字段表），并用 `crypto.timingSafeEqual` 做时序安全比较。\n\n代收/退款回调用 `apiSecretPay`，代付回调用 `apiSecretPayout`。验签失败时**不要回成功应答**；同一订单可能再次收到回调。成功处理后回 **HTTP 200 + 纯文本 `success`**，处理务必**幂等**。\n\n完整示例（代收 + 代付各演示一次、含幂等与篡改反例）见 [`examples/callback_verify.js`](./examples/callback_verify.js)：\n\n```bash\nnode examples/callback_verify.js\n```\n\n## 运行示例\n\n```bash\nnode examples/pay_create.js       # 代收下单 + 查单\nnode examples/payout_create.js    # 代付下单 + 查单 + 查可用银行\nnode examples/callback_verify.js  # 回调验签 + 幂等处理 + 应答（代收 + 代付）\n```\n\n凭证可用环境变量传入：`PP_MERCHANT_NO` / `PP_API_KEY` / `PP_API_SECRET_PAY` / `PP_API_SECRET_PAYOUT` / `PP_BASE_URL`。\n\n## 跑测试\n\n标准库测试设施（`node:test` + `node:assert`），无需安装任何依赖：\n\n```bash\nnode --test\n# 或\nnpm test\n```\n\n测试内容：\n\n- `tests/signer.test.js`：读取 `../test-vectors.json`，对**每个向量**断言 `buildSignBase == base` 且 `sign == sign`；回调验签正例 + 篡改一字节/换错密钥/缺 sign 的反例。\n- `tests/client.test.js`：用本地 `node:http` 桩服务器校验请求构建（通用字段/nonce 唯一/null 过滤/密钥选择/`inline` 整数化/path）与信封解析（`ApiError` / `TransportError`），全程不依赖外网。\n","readmeFilename":"README.md"}