@waffo/waffo-node 2.5.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -4
- package/dist/index.d.mts +737 -605
- package/dist/index.d.ts +737 -605
- package/dist/index.js +34 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Waffo Node.js SDK
|
|
2
2
|
|
|
3
|
-
<!-- Synced with waffo-sdk/README.md @ commit
|
|
3
|
+
<!-- Synced with waffo-sdk/README.md @ commit 0e59bbc -->
|
|
4
4
|
|
|
5
5
|
**English** | [中文](README_CN.md)
|
|
6
6
|
|
|
@@ -666,18 +666,61 @@ if (response.isSuccess()) {
|
|
|
666
666
|
|
|
667
667
|
#### Query Available Payment Methods
|
|
668
668
|
|
|
669
|
+
The `payMethodDetails` response includes the payment method category, supported currency, order amount limits, and refund policy. `currentStatus` can be absent when real-time availability is temporarily unavailable.
|
|
670
|
+
|
|
669
671
|
```typescript
|
|
670
672
|
// merchantId is auto-injected from config if not provided
|
|
671
673
|
const response = await waffo.payMethodConfig().inquiry({});
|
|
672
674
|
|
|
673
675
|
if (response.isSuccess()) {
|
|
674
676
|
const data = response.getData();
|
|
675
|
-
for (const detail of data
|
|
676
|
-
console.log(
|
|
677
|
+
for (const detail of data?.payMethodDetails ?? []) {
|
|
678
|
+
console.log({
|
|
679
|
+
name: detail.payMethodName,
|
|
680
|
+
type: detail.payMethodType,
|
|
681
|
+
country: detail.country,
|
|
682
|
+
currency: detail.currency,
|
|
683
|
+
amountRange: [detail.orderAmountMin, detail.orderAmountMax],
|
|
684
|
+
refundAllowed: detail.refundAllowed,
|
|
685
|
+
currentStatus: detail.currentStatus,
|
|
686
|
+
});
|
|
677
687
|
}
|
|
688
|
+
} else {
|
|
689
|
+
console.error('Pay method config inquiry failed:', response.getCode(), response.getMessage());
|
|
690
|
+
}
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
### Wallet Address Inquiry (x402)
|
|
694
|
+
|
|
695
|
+
Inquire the on-chain stablecoin receiving address for an x402 payment. The response returns the target network, the on-chain token contract, and the Waffo platform wallet address to send funds to. Phase 1 supports `USDC`.
|
|
696
|
+
|
|
697
|
+
```typescript
|
|
698
|
+
// paymentRequestId: unique idempotency key for this inquiry
|
|
699
|
+
// orderCurrency: settlement currency of the order (Phase 1 supports USDC)
|
|
700
|
+
// merchantInfo is auto-injected from config if not provided
|
|
701
|
+
const response = await waffo.wallet().inquiry({
|
|
702
|
+
paymentRequestId: 'unique-request-id',
|
|
703
|
+
orderCurrency: 'USDC',
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
if (response.isSuccess()) {
|
|
707
|
+
const data = response.getData();
|
|
708
|
+
console.log('Network:', data?.network); // CAIP-2 network id, e.g. eip155:8453 (Base mainnet)
|
|
709
|
+
console.log('Asset:', data?.asset); // on-chain token contract address
|
|
710
|
+
console.log('Pay to:', data?.payTo); // Waffo platform receiving wallet address
|
|
711
|
+
} else {
|
|
712
|
+
console.error('Wallet inquiry failed:', response.getCode(), response.getMessage());
|
|
678
713
|
}
|
|
679
714
|
```
|
|
680
715
|
|
|
716
|
+
#### Wallet Inquiry Response Fields
|
|
717
|
+
|
|
718
|
+
| Field | Description |
|
|
719
|
+
|-------|-------------|
|
|
720
|
+
| `network` | CAIP-2 network id (Phase 1: `eip155:8453`, Base mainnet) |
|
|
721
|
+
| `asset` | On-chain token contract address for the network + currency |
|
|
722
|
+
| `payTo` | Waffo platform receiving wallet address (send funds here) |
|
|
723
|
+
|
|
681
724
|
## Webhook Handling
|
|
682
725
|
|
|
683
726
|
Waffo pushes payment results, refund results, subscription status changes, and more via webhooks.
|
|
@@ -862,6 +905,8 @@ The following examples show the actual payload structure for each notification t
|
|
|
862
905
|
}
|
|
863
906
|
```
|
|
864
907
|
|
|
908
|
+
For x402 stablecoin payments, `PAYMENT_NOTIFICATION.result` also includes `x402Info` with `x402Request`, `paymentSignatureHeader`, and `x402Response`.
|
|
909
|
+
|
|
865
910
|
#### SUBSCRIPTION_STATUS_NOTIFICATION / SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION
|
|
866
911
|
|
|
867
912
|
These two notification types share the same payload structure:
|
|
@@ -1294,7 +1339,7 @@ Error codes are classified by first letter:
|
|
|
1294
1339
|
| `S0004` | Response Signature Verification Failed | `ApiResponse.error()` | Check Waffo public key config, contact Waffo |
|
|
1295
1340
|
| `S0005` | Request Serialization Failed | `ApiResponse.error()` | Check request parameter format |
|
|
1296
1341
|
| `S0006` | SDK Unknown Error | `ApiResponse.error()` | Check logs, contact technical support |
|
|
1297
|
-
| `S0007` | Invalid Private Key | `WaffoError` | Check if private key is valid Base64
|
|
1342
|
+
| `S0007` | Invalid Private Key | `WaffoError` | Check if private key is valid Base64 encoded PKCS8 format |
|
|
1298
1343
|
|
|
1299
1344
|
> **Important**: `S0001` and `E0001` (returned by server) indicate **unknown status**. Do not close order directly! Should call query API or wait for webhook to confirm actual status.
|
|
1300
1345
|
|