@naturalpay/sdk 0.3.0 → 0.4.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.
Files changed (109) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/client.d.mts +22 -10
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +22 -10
  5. package/client.d.ts.map +1 -1
  6. package/client.js +14 -2
  7. package/client.js.map +1 -1
  8. package/client.mjs +15 -3
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/api-keys.d.mts +16 -2
  12. package/resources/api-keys.d.mts.map +1 -1
  13. package/resources/api-keys.d.ts +16 -2
  14. package/resources/api-keys.d.ts.map +1 -1
  15. package/resources/api-keys.js +7 -4
  16. package/resources/api-keys.js.map +1 -1
  17. package/resources/api-keys.mjs +7 -4
  18. package/resources/api-keys.mjs.map +1 -1
  19. package/resources/escalations.d.mts +1124 -0
  20. package/resources/escalations.d.mts.map +1 -0
  21. package/resources/escalations.d.ts +1124 -0
  22. package/resources/escalations.d.ts.map +1 -0
  23. package/resources/escalations.js +110 -0
  24. package/resources/escalations.js.map +1 -0
  25. package/resources/escalations.mjs +106 -0
  26. package/resources/escalations.mjs.map +1 -0
  27. package/resources/index.d.mts +6 -4
  28. package/resources/index.d.mts.map +1 -1
  29. package/resources/index.d.ts +6 -4
  30. package/resources/index.d.ts.map +1 -1
  31. package/resources/index.js +5 -1
  32. package/resources/index.js.map +1 -1
  33. package/resources/index.mjs +3 -1
  34. package/resources/index.mjs.map +1 -1
  35. package/resources/invitations.d.mts +16 -7
  36. package/resources/invitations.d.mts.map +1 -1
  37. package/resources/invitations.d.ts +16 -7
  38. package/resources/invitations.d.ts.map +1 -1
  39. package/resources/invitations.js +6 -4
  40. package/resources/invitations.js.map +1 -1
  41. package/resources/invitations.mjs +6 -4
  42. package/resources/invitations.mjs.map +1 -1
  43. package/resources/parties.d.mts +53 -26
  44. package/resources/parties.d.mts.map +1 -1
  45. package/resources/parties.d.ts +53 -26
  46. package/resources/parties.d.ts.map +1 -1
  47. package/resources/parties.js +27 -1
  48. package/resources/parties.js.map +1 -1
  49. package/resources/parties.mjs +27 -1
  50. package/resources/parties.mjs.map +1 -1
  51. package/resources/payment-requests.d.mts +738 -33
  52. package/resources/payment-requests.d.mts.map +1 -1
  53. package/resources/payment-requests.d.ts +738 -33
  54. package/resources/payment-requests.d.ts.map +1 -1
  55. package/resources/payment-requests.js +82 -1
  56. package/resources/payment-requests.js.map +1 -1
  57. package/resources/payment-requests.mjs +82 -1
  58. package/resources/payment-requests.mjs.map +1 -1
  59. package/resources/payments.d.mts +390 -24
  60. package/resources/payments.d.mts.map +1 -1
  61. package/resources/payments.d.ts +390 -24
  62. package/resources/payments.d.ts.map +1 -1
  63. package/resources/payments.js +53 -3
  64. package/resources/payments.js.map +1 -1
  65. package/resources/payments.mjs +53 -3
  66. package/resources/payments.mjs.map +1 -1
  67. package/resources/transactions.d.mts +50 -118
  68. package/resources/transactions.d.mts.map +1 -1
  69. package/resources/transactions.d.ts +50 -118
  70. package/resources/transactions.d.ts.map +1 -1
  71. package/resources/transactions.js +2 -2
  72. package/resources/transactions.mjs +2 -2
  73. package/resources/transfers.d.mts +1030 -0
  74. package/resources/transfers.d.mts.map +1 -0
  75. package/resources/transfers.d.ts +1030 -0
  76. package/resources/transfers.d.ts.map +1 -0
  77. package/resources/transfers.js +114 -0
  78. package/resources/transfers.js.map +1 -0
  79. package/resources/transfers.mjs +110 -0
  80. package/resources/transfers.mjs.map +1 -0
  81. package/resources/wallet.d.mts +1 -189
  82. package/resources/wallet.d.mts.map +1 -1
  83. package/resources/wallet.d.ts +1 -189
  84. package/resources/wallet.d.ts.map +1 -1
  85. package/resources/wallet.js +0 -66
  86. package/resources/wallet.js.map +1 -1
  87. package/resources/wallet.mjs +0 -66
  88. package/resources/wallet.mjs.map +1 -1
  89. package/resources/webhooks.d.mts +7 -7
  90. package/resources/webhooks.d.mts.map +1 -1
  91. package/resources/webhooks.d.ts +7 -7
  92. package/resources/webhooks.d.ts.map +1 -1
  93. package/src/client.ts +87 -11
  94. package/src/resources/api-keys.ts +26 -4
  95. package/src/resources/escalations.ts +1422 -0
  96. package/src/resources/index.ts +39 -5
  97. package/src/resources/invitations.ts +26 -10
  98. package/src/resources/parties.ts +85 -30
  99. package/src/resources/payment-requests.ts +949 -58
  100. package/src/resources/payments.ts +518 -23
  101. package/src/resources/transactions.ts +50 -136
  102. package/src/resources/transfers.ts +1338 -0
  103. package/src/resources/wallet.ts +0 -268
  104. package/src/resources/webhooks.ts +7 -0
  105. package/src/version.ts +1 -1
  106. package/version.d.mts +1 -1
  107. package/version.d.ts +1 -1
  108. package/version.js +1 -1
  109. package/version.mjs +1 -1
@@ -4,19 +4,23 @@ import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
5
  import { buildHeaders } from '../internal/headers';
6
6
  import { RequestOptions } from '../internal/request-options';
7
+ import { path } from '../internal/utils/path';
7
8
 
8
9
  /**
9
- * Payment and transaction operations
10
+ * Payment operations
10
11
  */
11
12
  export class Payments extends APIResource {
12
13
  /**
13
- * Create a payment with delegation validation and limit enforcement.
14
+ * Create a payment.
14
15
  *
15
16
  * @example
16
17
  * ```ts
17
18
  * const payment = await client.payments.create({
18
19
  * amount: 1,
19
- * counterparty: 'counterparty',
20
+ * counterparty: {
21
+ * type: 'type',
22
+ * value: 'dev@stainless.com',
23
+ * },
20
24
  * 'Idempotency-Key': 'Idempotency-Key',
21
25
  * });
22
26
  * ```
@@ -41,6 +45,61 @@ export class Payments extends APIResource {
41
45
  ]),
42
46
  });
43
47
  }
48
+
49
+ /**
50
+ * List payments initiated by the authenticated party.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const payments = await client.payments.list();
55
+ * ```
56
+ */
57
+ list(
58
+ params: PaymentListParams | null | undefined = {},
59
+ options?: RequestOptions,
60
+ ): APIPromise<PaymentListResponse> {
61
+ const { 'X-Agent-ID': xAgentID, 'X-Instance-ID': xInstanceID, ...query } = params ?? {};
62
+ return this._client.get('/payments', {
63
+ query,
64
+ ...options,
65
+ headers: buildHeaders([
66
+ {
67
+ ...(xAgentID != null ? { 'X-Agent-ID': xAgentID } : undefined),
68
+ ...(xInstanceID != null ? { 'X-Instance-ID': xInstanceID } : undefined),
69
+ },
70
+ options?.headers,
71
+ ]),
72
+ });
73
+ }
74
+
75
+ /**
76
+ * Get a payment initiated by the authenticated party.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * const payment = await client.payments.get(
81
+ * 'pay_ecc2efdd09bd231a9ad9bd2aada37aa7',
82
+ * );
83
+ * ```
84
+ */
85
+ get(
86
+ paymentID: string,
87
+ params: PaymentGetParams | null | undefined = {},
88
+ options?: RequestOptions,
89
+ ): APIPromise<PaymentGetResponse> {
90
+ const { 'X-Agent-ID': xAgentID, 'X-Instance-ID': xInstanceID, ...query } = params ?? {};
91
+ return this._client.get(path`/payments/${paymentID}`, {
92
+ query,
93
+ ...options,
94
+ headers: buildHeaders([
95
+ {
96
+ ...(xAgentID != null ? { 'X-Agent-ID': xAgentID } : undefined),
97
+ ...(xInstanceID != null ? { 'X-Instance-ID': xInstanceID } : undefined),
98
+ },
99
+ options?.headers,
100
+ ]),
101
+ });
102
+ }
44
103
  }
45
104
 
46
105
  export interface PaymentCreateResponse {
@@ -49,9 +108,169 @@ export interface PaymentCreateResponse {
49
108
 
50
109
  export namespace PaymentCreateResponse {
51
110
  export interface Data {
111
+ id: string;
112
+
113
+ /**
114
+ * Resource attributes
115
+ */
116
+ attributes: Data.Attributes;
117
+
118
+ /**
119
+ * Resource relationships
120
+ */
121
+ relationships: Data.Relationships;
122
+
123
+ type: string;
124
+ }
125
+
126
+ export namespace Data {
127
+ /**
128
+ * Resource attributes
129
+ */
130
+ export interface Attributes {
131
+ /**
132
+ * Amount in cents
133
+ */
134
+ amount: number;
135
+
136
+ /**
137
+ * When this payment was created
138
+ */
139
+ createdAt: string;
140
+
141
+ /**
142
+ * Currency code
143
+ */
144
+ currency: string;
145
+
146
+ /**
147
+ * Payment description
148
+ */
149
+ description: string | null;
150
+
151
+ /**
152
+ * Payment status
153
+ */
154
+ status:
155
+ | 'CREATED'
156
+ | 'PROCESSING'
157
+ | 'PENDING_CLAIM'
158
+ | 'IN_REVIEW'
159
+ | 'COMPLETED'
160
+ | 'FAILED'
161
+ | 'APPROVAL_DENIED'
162
+ | 'CANCELLED';
163
+
164
+ /**
165
+ * When this payment was last updated
166
+ */
167
+ updatedAt: string | null;
168
+ }
169
+
52
170
  /**
53
- * Resource ID
171
+ * Resource relationships
54
172
  */
173
+ export interface Relationships {
174
+ /**
175
+ * Recipient party for this payment, when known.
176
+ */
177
+ recipient: Relationships.Recipient;
178
+
179
+ /**
180
+ * Party that initiated the payment
181
+ */
182
+ sender: Relationships.Sender;
183
+
184
+ /**
185
+ * Sender-side transaction row for this payment, when available.
186
+ */
187
+ transaction: Relationships.Transaction;
188
+ }
189
+
190
+ export namespace Relationships {
191
+ /**
192
+ * Recipient party for this payment, when known.
193
+ */
194
+ export interface Recipient {
195
+ /**
196
+ * Related resource identifier
197
+ */
198
+ data: Recipient.Data | null;
199
+ }
200
+
201
+ export namespace Recipient {
202
+ /**
203
+ * Related resource identifier
204
+ */
205
+ export interface Data {
206
+ id: string;
207
+
208
+ /**
209
+ * Resource type
210
+ */
211
+ type: string;
212
+ }
213
+ }
214
+
215
+ /**
216
+ * Party that initiated the payment
217
+ */
218
+ export interface Sender {
219
+ /**
220
+ * Related resource identifier
221
+ */
222
+ data: Sender.Data;
223
+ }
224
+
225
+ export namespace Sender {
226
+ /**
227
+ * Related resource identifier
228
+ */
229
+ export interface Data {
230
+ id: string;
231
+
232
+ /**
233
+ * Resource type
234
+ */
235
+ type: string;
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Sender-side transaction row for this payment, when available.
241
+ */
242
+ export interface Transaction {
243
+ /**
244
+ * Related resource identifier
245
+ */
246
+ data: Transaction.Data | null;
247
+ }
248
+
249
+ export namespace Transaction {
250
+ /**
251
+ * Related resource identifier
252
+ */
253
+ export interface Data {
254
+ id: string;
255
+
256
+ /**
257
+ * Resource type
258
+ */
259
+ type: string;
260
+ }
261
+ }
262
+ }
263
+ }
264
+ }
265
+
266
+ export interface PaymentListResponse {
267
+ data: Array<PaymentListResponse.Data>;
268
+
269
+ meta: PaymentListResponse.Meta;
270
+ }
271
+
272
+ export namespace PaymentListResponse {
273
+ export interface Data {
55
274
  id: string;
56
275
 
57
276
  /**
@@ -78,9 +297,177 @@ export namespace PaymentCreateResponse {
78
297
  amount: number;
79
298
 
80
299
  /**
81
- * Claim link for unclaimed payments
300
+ * When this payment was created
301
+ */
302
+ createdAt: string;
303
+
304
+ /**
305
+ * Currency code
306
+ */
307
+ currency: string;
308
+
309
+ /**
310
+ * Payment description
311
+ */
312
+ description: string | null;
313
+
314
+ /**
315
+ * Payment status
316
+ */
317
+ status:
318
+ | 'CREATED'
319
+ | 'PROCESSING'
320
+ | 'PENDING_CLAIM'
321
+ | 'IN_REVIEW'
322
+ | 'COMPLETED'
323
+ | 'FAILED'
324
+ | 'APPROVAL_DENIED'
325
+ | 'CANCELLED';
326
+
327
+ /**
328
+ * When this payment was last updated
329
+ */
330
+ updatedAt: string | null;
331
+ }
332
+
333
+ /**
334
+ * Resource relationships
335
+ */
336
+ export interface Relationships {
337
+ /**
338
+ * Recipient party for this payment, when known.
339
+ */
340
+ recipient: Relationships.Recipient;
341
+
342
+ /**
343
+ * Party that initiated the payment
344
+ */
345
+ sender: Relationships.Sender;
346
+
347
+ /**
348
+ * Sender-side transaction row for this payment, when available.
349
+ */
350
+ transaction: Relationships.Transaction;
351
+ }
352
+
353
+ export namespace Relationships {
354
+ /**
355
+ * Recipient party for this payment, when known.
356
+ */
357
+ export interface Recipient {
358
+ /**
359
+ * Related resource identifier
360
+ */
361
+ data: Recipient.Data | null;
362
+ }
363
+
364
+ export namespace Recipient {
365
+ /**
366
+ * Related resource identifier
367
+ */
368
+ export interface Data {
369
+ id: string;
370
+
371
+ /**
372
+ * Resource type
373
+ */
374
+ type: string;
375
+ }
376
+ }
377
+
378
+ /**
379
+ * Party that initiated the payment
380
+ */
381
+ export interface Sender {
382
+ /**
383
+ * Related resource identifier
384
+ */
385
+ data: Sender.Data;
386
+ }
387
+
388
+ export namespace Sender {
389
+ /**
390
+ * Related resource identifier
391
+ */
392
+ export interface Data {
393
+ id: string;
394
+
395
+ /**
396
+ * Resource type
397
+ */
398
+ type: string;
399
+ }
400
+ }
401
+
402
+ /**
403
+ * Sender-side transaction row for this payment, when available.
404
+ */
405
+ export interface Transaction {
406
+ /**
407
+ * Related resource identifier
408
+ */
409
+ data: Transaction.Data | null;
410
+ }
411
+
412
+ export namespace Transaction {
413
+ /**
414
+ * Related resource identifier
415
+ */
416
+ export interface Data {
417
+ id: string;
418
+
419
+ /**
420
+ * Resource type
421
+ */
422
+ type: string;
423
+ }
424
+ }
425
+ }
426
+ }
427
+
428
+ export interface Meta {
429
+ pagination: Meta.Pagination;
430
+ }
431
+
432
+ export namespace Meta {
433
+ export interface Pagination {
434
+ hasMore: boolean;
435
+
436
+ nextCursor: string | null;
437
+ }
438
+ }
439
+ }
440
+
441
+ export interface PaymentGetResponse {
442
+ data: PaymentGetResponse.Data;
443
+ }
444
+
445
+ export namespace PaymentGetResponse {
446
+ export interface Data {
447
+ id: string;
448
+
449
+ /**
450
+ * Resource attributes
451
+ */
452
+ attributes: Data.Attributes;
453
+
454
+ /**
455
+ * Resource relationships
456
+ */
457
+ relationships: Data.Relationships;
458
+
459
+ type: string;
460
+ }
461
+
462
+ export namespace Data {
463
+ /**
464
+ * Resource attributes
465
+ */
466
+ export interface Attributes {
467
+ /**
468
+ * Amount in cents
82
469
  */
83
- claimLink: string | null;
470
+ amount: number;
84
471
 
85
472
  /**
86
473
  * When this payment was created
@@ -100,12 +487,20 @@ export namespace PaymentCreateResponse {
100
487
  /**
101
488
  * Payment status
102
489
  */
103
- status: 'PROCESSING' | 'PENDING_CLAIM' | 'IN_REVIEW' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
490
+ status:
491
+ | 'CREATED'
492
+ | 'PROCESSING'
493
+ | 'PENDING_CLAIM'
494
+ | 'IN_REVIEW'
495
+ | 'COMPLETED'
496
+ | 'FAILED'
497
+ | 'APPROVAL_DENIED'
498
+ | 'CANCELLED';
104
499
 
105
500
  /**
106
501
  * When this payment was last updated
107
502
  */
108
- updatedAt: string;
503
+ updatedAt: string | null;
109
504
  }
110
505
 
111
506
  /**
@@ -113,28 +508,33 @@ export namespace PaymentCreateResponse {
113
508
  */
114
509
  export interface Relationships {
115
510
  /**
116
- * Party receiving the payment
511
+ * Recipient party for this payment, when known.
512
+ */
513
+ recipient: Relationships.Recipient;
514
+
515
+ /**
516
+ * Party that initiated the payment
117
517
  */
118
- counterparty: Relationships.Counterparty;
518
+ sender: Relationships.Sender;
119
519
 
120
520
  /**
121
- * Party that made the payment
521
+ * Sender-side transaction row for this payment, when available.
122
522
  */
123
- customerParty: Relationships.CustomerParty;
523
+ transaction: Relationships.Transaction;
124
524
  }
125
525
 
126
526
  export namespace Relationships {
127
527
  /**
128
- * Party receiving the payment
528
+ * Recipient party for this payment, when known.
129
529
  */
130
- export interface Counterparty {
530
+ export interface Recipient {
131
531
  /**
132
532
  * Related resource identifier
133
533
  */
134
- data: Counterparty.Data | null;
534
+ data: Recipient.Data | null;
135
535
  }
136
536
 
137
- export namespace Counterparty {
537
+ export namespace Recipient {
138
538
  /**
139
539
  * Related resource identifier
140
540
  */
@@ -149,16 +549,40 @@ export namespace PaymentCreateResponse {
149
549
  }
150
550
 
151
551
  /**
152
- * Party that made the payment
552
+ * Party that initiated the payment
153
553
  */
154
- export interface CustomerParty {
554
+ export interface Sender {
155
555
  /**
156
556
  * Related resource identifier
157
557
  */
158
- data: CustomerParty.Data;
558
+ data: Sender.Data;
159
559
  }
160
560
 
161
- export namespace CustomerParty {
561
+ export namespace Sender {
562
+ /**
563
+ * Related resource identifier
564
+ */
565
+ export interface Data {
566
+ id: string;
567
+
568
+ /**
569
+ * Resource type
570
+ */
571
+ type: string;
572
+ }
573
+ }
574
+
575
+ /**
576
+ * Sender-side transaction row for this payment, when available.
577
+ */
578
+ export interface Transaction {
579
+ /**
580
+ * Related resource identifier
581
+ */
582
+ data: Transaction.Data | null;
583
+ }
584
+
585
+ export namespace Transaction {
162
586
  /**
163
587
  * Related resource identifier
164
588
  */
@@ -182,9 +606,10 @@ export interface PaymentCreateParams {
182
606
  amount: number;
183
607
 
184
608
  /**
185
- * Body param: Recipient: party ID (pty*\*), agent ID (agt*\*), email, or phone
609
+ * Body param: Recipient identifier. Provide exactly one typed email, phone, party
610
+ * ID, or agent ID value.
186
611
  */
187
- counterparty: string;
612
+ counterparty: PaymentCreateParams.UnionMember0 | PaymentCreateParams.UnionMember1;
188
613
 
189
614
  /**
190
615
  * Header param: Unique key for idempotent request handling. If a request with the
@@ -204,7 +629,7 @@ export interface PaymentCreateParams {
204
629
  customerPartyId?: string;
205
630
 
206
631
  /**
207
- * Body param: Payment description
632
+ * Body param: Payment description. Maximum 500 characters.
208
633
  */
209
634
  description?: string;
210
635
 
@@ -220,9 +645,79 @@ export interface PaymentCreateParams {
220
645
  'X-Instance-ID'?: string;
221
646
  }
222
647
 
648
+ export namespace PaymentCreateParams {
649
+ export interface UnionMember0 {
650
+ type: string;
651
+
652
+ /**
653
+ * Email address
654
+ */
655
+ value: string;
656
+ }
657
+
658
+ export interface UnionMember1 {
659
+ type: string;
660
+
661
+ /**
662
+ * Phone number in E.164 format
663
+ */
664
+ value: string;
665
+ }
666
+ }
667
+
668
+ export interface PaymentListParams {
669
+ /**
670
+ * Query param: Pagination cursor from previous response
671
+ */
672
+ cursor?: string;
673
+
674
+ /**
675
+ * Query param: Results per page
676
+ */
677
+ limit?: number;
678
+
679
+ /**
680
+ * Query param: Party ID for delegated payment lookup
681
+ */
682
+ partyId?: string;
683
+
684
+ /**
685
+ * Header param: Agent ID (agt_xxx) identifying which agent is making the request.
686
+ */
687
+ 'X-Agent-ID'?: string;
688
+
689
+ /**
690
+ * Header param: Required when X-Agent-ID is present. Session or conversation ID
691
+ * for agent observability.
692
+ */
693
+ 'X-Instance-ID'?: string;
694
+ }
695
+
696
+ export interface PaymentGetParams {
697
+ /**
698
+ * Query param: Party ID for delegated payment lookup
699
+ */
700
+ partyId?: string;
701
+
702
+ /**
703
+ * Header param: Agent ID (agt_xxx) identifying which agent is making the request.
704
+ */
705
+ 'X-Agent-ID'?: string;
706
+
707
+ /**
708
+ * Header param: Required when X-Agent-ID is present. Session or conversation ID
709
+ * for agent observability.
710
+ */
711
+ 'X-Instance-ID'?: string;
712
+ }
713
+
223
714
  export declare namespace Payments {
224
715
  export {
225
716
  type PaymentCreateResponse as PaymentCreateResponse,
717
+ type PaymentListResponse as PaymentListResponse,
718
+ type PaymentGetResponse as PaymentGetResponse,
226
719
  type PaymentCreateParams as PaymentCreateParams,
720
+ type PaymentListParams as PaymentListParams,
721
+ type PaymentGetParams as PaymentGetParams,
227
722
  };
228
723
  }