@jskit-ai/payments-core 0.1.1

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.
@@ -0,0 +1,718 @@
1
+ {
2
+ "version": 1,
3
+ "configurationCases": [
4
+ {
5
+ "id": "stripe-sandbox",
6
+ "document": {
7
+ "integrations": {
8
+ "billing": {
9
+ "provider": "stripe",
10
+ "accountMode": "shared",
11
+ "authentication": {
12
+ "method": "api-key",
13
+ "secretRef": "env:STRIPE_KEY"
14
+ }
15
+ }
16
+ },
17
+ "extensions": {
18
+ "payments": {
19
+ "version": 1,
20
+ "environments": {
21
+ "sandbox": {
22
+ "integrationId": "billing",
23
+ "providerAccountId": "acct_fixture",
24
+ "webhookSecretRef": "env:STRIPE_WEBHOOK_SECRET",
25
+ "returnUrlRef": "env:BILLING_RETURN_URL"
26
+ }
27
+ },
28
+ "plans": {
29
+ "pro": {
30
+ "name": "Pro",
31
+ "amount": 1200,
32
+ "currency": "USD",
33
+ "interval": "month",
34
+ "features": [
35
+ "export"
36
+ ],
37
+ "renewalCredits": 100
38
+ }
39
+ }
40
+ }
41
+ }
42
+ },
43
+ "schemaValid": true,
44
+ "configurationValid": true
45
+ },
46
+ {
47
+ "id": "paddle-sandbox",
48
+ "document": {
49
+ "integrations": {
50
+ "billing": {
51
+ "provider": "paddle",
52
+ "accountMode": "shared",
53
+ "authentication": {
54
+ "method": "api-key",
55
+ "secretRef": "env:STRIPE_KEY"
56
+ },
57
+ "settings": {
58
+ "environment": "sandbox"
59
+ }
60
+ }
61
+ },
62
+ "extensions": {
63
+ "payments": {
64
+ "version": 1,
65
+ "environments": {
66
+ "sandbox": {
67
+ "integrationId": "billing",
68
+ "providerAccountId": "acct_fixture",
69
+ "webhookSecretRef": "env:STRIPE_WEBHOOK_SECRET",
70
+ "returnUrlRef": "env:BILLING_RETURN_URL",
71
+ "taxCategory": "saas",
72
+ "publicClientTokenRef": "env:PADDLE_CLIENT_TOKEN"
73
+ }
74
+ },
75
+ "plans": {
76
+ "pro": {
77
+ "name": "Pro",
78
+ "amount": 1200,
79
+ "currency": "USD",
80
+ "interval": "month",
81
+ "features": [
82
+ "export"
83
+ ],
84
+ "renewalCredits": 100
85
+ }
86
+ }
87
+ }
88
+ }
89
+ },
90
+ "schemaValid": true,
91
+ "configurationValid": true
92
+ },
93
+ {
94
+ "id": "fractional-price",
95
+ "document": {
96
+ "integrations": {
97
+ "billing": {
98
+ "provider": "stripe",
99
+ "accountMode": "shared",
100
+ "authentication": {
101
+ "method": "api-key",
102
+ "secretRef": "env:STRIPE_KEY"
103
+ }
104
+ }
105
+ },
106
+ "extensions": {
107
+ "payments": {
108
+ "version": 1,
109
+ "environments": {
110
+ "sandbox": {
111
+ "integrationId": "billing",
112
+ "providerAccountId": "acct_fixture",
113
+ "webhookSecretRef": "env:STRIPE_WEBHOOK_SECRET",
114
+ "returnUrlRef": "env:BILLING_RETURN_URL"
115
+ }
116
+ },
117
+ "plans": {
118
+ "pro": {
119
+ "name": "Pro",
120
+ "amount": 12.5,
121
+ "currency": "USD",
122
+ "interval": "month",
123
+ "features": [
124
+ "export"
125
+ ],
126
+ "renewalCredits": 100
127
+ }
128
+ }
129
+ }
130
+ }
131
+ },
132
+ "schemaValid": false,
133
+ "configurationValid": false
134
+ },
135
+ {
136
+ "id": "negative-credits",
137
+ "document": {
138
+ "integrations": {
139
+ "billing": {
140
+ "provider": "stripe",
141
+ "accountMode": "shared",
142
+ "authentication": {
143
+ "method": "api-key",
144
+ "secretRef": "env:STRIPE_KEY"
145
+ }
146
+ }
147
+ },
148
+ "extensions": {
149
+ "payments": {
150
+ "version": 1,
151
+ "environments": {
152
+ "sandbox": {
153
+ "integrationId": "billing",
154
+ "providerAccountId": "acct_fixture",
155
+ "webhookSecretRef": "env:STRIPE_WEBHOOK_SECRET",
156
+ "returnUrlRef": "env:BILLING_RETURN_URL"
157
+ }
158
+ },
159
+ "plans": {
160
+ "pro": {
161
+ "name": "Pro",
162
+ "amount": 1200,
163
+ "currency": "USD",
164
+ "interval": "month",
165
+ "features": [
166
+ "export"
167
+ ],
168
+ "renewalCredits": -1
169
+ }
170
+ }
171
+ }
172
+ }
173
+ },
174
+ "schemaValid": false,
175
+ "configurationValid": false
176
+ },
177
+ {
178
+ "id": "duplicate-feature",
179
+ "document": {
180
+ "integrations": {
181
+ "billing": {
182
+ "provider": "stripe",
183
+ "accountMode": "shared",
184
+ "authentication": {
185
+ "method": "api-key",
186
+ "secretRef": "env:STRIPE_KEY"
187
+ }
188
+ }
189
+ },
190
+ "extensions": {
191
+ "payments": {
192
+ "version": 1,
193
+ "environments": {
194
+ "sandbox": {
195
+ "integrationId": "billing",
196
+ "providerAccountId": "acct_fixture",
197
+ "webhookSecretRef": "env:STRIPE_WEBHOOK_SECRET",
198
+ "returnUrlRef": "env:BILLING_RETURN_URL"
199
+ }
200
+ },
201
+ "plans": {
202
+ "pro": {
203
+ "name": "Pro",
204
+ "amount": 1200,
205
+ "currency": "USD",
206
+ "interval": "month",
207
+ "features": [
208
+ "export",
209
+ "export"
210
+ ],
211
+ "renewalCredits": 100
212
+ }
213
+ }
214
+ }
215
+ }
216
+ },
217
+ "schemaValid": false,
218
+ "configurationValid": false
219
+ },
220
+ {
221
+ "id": "inline-webhook-secret",
222
+ "document": {
223
+ "integrations": {
224
+ "billing": {
225
+ "provider": "stripe",
226
+ "accountMode": "shared",
227
+ "authentication": {
228
+ "method": "api-key",
229
+ "secretRef": "env:STRIPE_KEY"
230
+ }
231
+ }
232
+ },
233
+ "extensions": {
234
+ "payments": {
235
+ "version": 1,
236
+ "environments": {
237
+ "sandbox": {
238
+ "integrationId": "billing",
239
+ "providerAccountId": "acct_fixture",
240
+ "webhookSecretRef": "not-an-env-reference",
241
+ "returnUrlRef": "env:BILLING_RETURN_URL"
242
+ }
243
+ },
244
+ "plans": {
245
+ "pro": {
246
+ "name": "Pro",
247
+ "amount": 1200,
248
+ "currency": "USD",
249
+ "interval": "month",
250
+ "features": [
251
+ "export"
252
+ ],
253
+ "renewalCredits": 100
254
+ }
255
+ }
256
+ }
257
+ }
258
+ },
259
+ "schemaValid": false,
260
+ "configurationValid": false
261
+ },
262
+ {
263
+ "id": "missing-connection",
264
+ "document": {
265
+ "integrations": {},
266
+ "extensions": {
267
+ "payments": {
268
+ "version": 1,
269
+ "environments": {
270
+ "sandbox": {
271
+ "integrationId": "billing",
272
+ "providerAccountId": "acct_fixture",
273
+ "webhookSecretRef": "env:STRIPE_WEBHOOK_SECRET",
274
+ "returnUrlRef": "env:BILLING_RETURN_URL"
275
+ }
276
+ },
277
+ "plans": {
278
+ "pro": {
279
+ "name": "Pro",
280
+ "amount": 1200,
281
+ "currency": "USD",
282
+ "interval": "month",
283
+ "features": [
284
+ "export"
285
+ ],
286
+ "renewalCredits": 100
287
+ }
288
+ }
289
+ }
290
+ }
291
+ },
292
+ "schemaValid": true,
293
+ "configurationValid": false
294
+ },
295
+ {
296
+ "id": "per-user-merchant",
297
+ "document": {
298
+ "integrations": {
299
+ "billing": {
300
+ "provider": "stripe",
301
+ "accountMode": "per-user",
302
+ "authentication": {
303
+ "method": "api-key",
304
+ "secretRef": "env:STRIPE_KEY"
305
+ }
306
+ }
307
+ },
308
+ "extensions": {
309
+ "payments": {
310
+ "version": 1,
311
+ "environments": {
312
+ "sandbox": {
313
+ "integrationId": "billing",
314
+ "providerAccountId": "acct_fixture",
315
+ "webhookSecretRef": "env:STRIPE_WEBHOOK_SECRET",
316
+ "returnUrlRef": "env:BILLING_RETURN_URL"
317
+ }
318
+ },
319
+ "plans": {
320
+ "pro": {
321
+ "name": "Pro",
322
+ "amount": 1200,
323
+ "currency": "USD",
324
+ "interval": "month",
325
+ "features": [
326
+ "export"
327
+ ],
328
+ "renewalCredits": 100
329
+ }
330
+ }
331
+ }
332
+ }
333
+ },
334
+ "schemaValid": true,
335
+ "configurationValid": false
336
+ },
337
+ {
338
+ "id": "inline-api-key",
339
+ "document": {
340
+ "integrations": {
341
+ "billing": {
342
+ "provider": "stripe",
343
+ "accountMode": "shared",
344
+ "authentication": {
345
+ "method": "api-key",
346
+ "secretRef": "not-an-env-reference"
347
+ }
348
+ }
349
+ },
350
+ "extensions": {
351
+ "payments": {
352
+ "version": 1,
353
+ "environments": {
354
+ "sandbox": {
355
+ "integrationId": "billing",
356
+ "providerAccountId": "acct_fixture",
357
+ "webhookSecretRef": "env:STRIPE_WEBHOOK_SECRET",
358
+ "returnUrlRef": "env:BILLING_RETURN_URL"
359
+ }
360
+ },
361
+ "plans": {
362
+ "pro": {
363
+ "name": "Pro",
364
+ "amount": 1200,
365
+ "currency": "USD",
366
+ "interval": "month",
367
+ "features": [
368
+ "export"
369
+ ],
370
+ "renewalCredits": 100
371
+ }
372
+ }
373
+ }
374
+ }
375
+ },
376
+ "schemaValid": true,
377
+ "configurationValid": false
378
+ },
379
+ {
380
+ "id": "paddle-environment-mismatch",
381
+ "document": {
382
+ "integrations": {
383
+ "billing": {
384
+ "provider": "paddle",
385
+ "accountMode": "shared",
386
+ "authentication": {
387
+ "method": "api-key",
388
+ "secretRef": "env:STRIPE_KEY"
389
+ },
390
+ "settings": {
391
+ "environment": "live"
392
+ }
393
+ }
394
+ },
395
+ "extensions": {
396
+ "payments": {
397
+ "version": 1,
398
+ "environments": {
399
+ "sandbox": {
400
+ "integrationId": "billing",
401
+ "providerAccountId": "acct_fixture",
402
+ "webhookSecretRef": "env:STRIPE_WEBHOOK_SECRET",
403
+ "returnUrlRef": "env:BILLING_RETURN_URL",
404
+ "taxCategory": "saas",
405
+ "publicClientTokenRef": "env:PADDLE_CLIENT_TOKEN"
406
+ }
407
+ },
408
+ "plans": {
409
+ "pro": {
410
+ "name": "Pro",
411
+ "amount": 1200,
412
+ "currency": "USD",
413
+ "interval": "month",
414
+ "features": [
415
+ "export"
416
+ ],
417
+ "renewalCredits": 100
418
+ }
419
+ }
420
+ }
421
+ }
422
+ },
423
+ "schemaValid": true,
424
+ "configurationValid": false
425
+ },
426
+ {
427
+ "id": "paddle-client-token-missing",
428
+ "document": {
429
+ "integrations": {
430
+ "billing": {
431
+ "provider": "paddle",
432
+ "accountMode": "shared",
433
+ "authentication": {
434
+ "method": "api-key",
435
+ "secretRef": "env:STRIPE_KEY"
436
+ },
437
+ "settings": {
438
+ "environment": "sandbox"
439
+ }
440
+ }
441
+ },
442
+ "extensions": {
443
+ "payments": {
444
+ "version": 1,
445
+ "environments": {
446
+ "sandbox": {
447
+ "integrationId": "billing",
448
+ "providerAccountId": "acct_fixture",
449
+ "webhookSecretRef": "env:STRIPE_WEBHOOK_SECRET",
450
+ "returnUrlRef": "env:BILLING_RETURN_URL",
451
+ "taxCategory": "saas"
452
+ }
453
+ },
454
+ "plans": {
455
+ "pro": {
456
+ "name": "Pro",
457
+ "amount": 1200,
458
+ "currency": "USD",
459
+ "interval": "month",
460
+ "features": [
461
+ "export"
462
+ ],
463
+ "renewalCredits": 100
464
+ }
465
+ }
466
+ }
467
+ }
468
+ },
469
+ "schemaValid": true,
470
+ "configurationValid": false
471
+ }
472
+ ],
473
+ "accountScenario": {
474
+ "document": {
475
+ "integrations": {
476
+ "billing": {
477
+ "provider": "stripe",
478
+ "accountMode": "shared",
479
+ "authentication": {
480
+ "method": "api-key",
481
+ "secretRef": "env:STRIPE_KEY"
482
+ }
483
+ }
484
+ },
485
+ "extensions": {
486
+ "payments": {
487
+ "version": 1,
488
+ "environments": {
489
+ "sandbox": {
490
+ "integrationId": "billing",
491
+ "providerAccountId": "acct_fixture",
492
+ "webhookSecretRef": "env:STRIPE_WEBHOOK_SECRET",
493
+ "returnUrlRef": "env:BILLING_RETURN_URL"
494
+ }
495
+ },
496
+ "plans": {
497
+ "pro": {
498
+ "name": "Pro",
499
+ "amount": 1200,
500
+ "currency": "USD",
501
+ "interval": "month",
502
+ "features": [
503
+ "export"
504
+ ],
505
+ "renewalCredits": 100
506
+ }
507
+ }
508
+ }
509
+ }
510
+ },
511
+ "scope": {
512
+ "applicationId": "app-fixture",
513
+ "integrationId": "billing",
514
+ "providerAccountId": "acct_fixture",
515
+ "environment": "sandbox",
516
+ "subjectId": "tenant-a"
517
+ },
518
+ "clock": 1000,
519
+ "customerId": "customer-fixture",
520
+ "steps": [
521
+ {
522
+ "operation": "inspect",
523
+ "expect": {
524
+ "balance": 0,
525
+ "features": [],
526
+ "subscriptions": []
527
+ }
528
+ },
529
+ {
530
+ "operation": "reconcileEvent",
531
+ "input": {
532
+ "eventId": "event-one",
533
+ "customerId": "customer-fixture"
534
+ },
535
+ "facts": {
536
+ "subscription": {
537
+ "id": "sub_fixture",
538
+ "status": "active",
539
+ "planId": "pro",
540
+ "periodEnd": 5000
541
+ },
542
+ "renewal": {
543
+ "id": "invoice_fixture",
544
+ "planId": "pro",
545
+ "periodEnd": 5000
546
+ }
547
+ },
548
+ "expect": {
549
+ "duplicate": false,
550
+ "subscriptionId": "sub_fixture"
551
+ }
552
+ },
553
+ {
554
+ "operation": "inspect",
555
+ "expect": {
556
+ "balance": 100,
557
+ "features": [
558
+ "export"
559
+ ],
560
+ "subscriptions": [
561
+ {
562
+ "id": "sub_fixture",
563
+ "status": "active",
564
+ "planId": "pro",
565
+ "periodEnd": 5000
566
+ }
567
+ ]
568
+ }
569
+ },
570
+ {
571
+ "operation": "reconcileEvent",
572
+ "input": {
573
+ "eventId": "event-one",
574
+ "customerId": "customer-fixture"
575
+ },
576
+ "facts": {
577
+ "subscription": {
578
+ "id": "sub_fixture",
579
+ "status": "active",
580
+ "planId": "pro",
581
+ "periodEnd": 5000
582
+ },
583
+ "renewal": {
584
+ "id": "invoice_fixture",
585
+ "planId": "pro",
586
+ "periodEnd": 5000
587
+ }
588
+ },
589
+ "expect": {
590
+ "duplicate": true
591
+ }
592
+ },
593
+ {
594
+ "operation": "reconcileEvent",
595
+ "input": {
596
+ "eventId": "event-two",
597
+ "customerId": "customer-fixture"
598
+ },
599
+ "facts": {
600
+ "subscription": {
601
+ "id": "sub_fixture",
602
+ "status": "active",
603
+ "planId": "pro",
604
+ "periodEnd": 5000
605
+ },
606
+ "renewal": {
607
+ "id": "invoice_fixture",
608
+ "planId": "pro",
609
+ "periodEnd": 5000
610
+ }
611
+ },
612
+ "expect": {
613
+ "duplicate": false,
614
+ "creditGrant": {
615
+ "duplicate": true,
616
+ "granted": 100,
617
+ "expiresAt": 5000
618
+ }
619
+ }
620
+ },
621
+ {
622
+ "operation": "debitCredits",
623
+ "input": {
624
+ "reference": "export-one",
625
+ "units": 30
626
+ },
627
+ "expect": {
628
+ "duplicate": false,
629
+ "debited": 30
630
+ }
631
+ },
632
+ {
633
+ "operation": "debitCredits",
634
+ "input": {
635
+ "reference": "export-one",
636
+ "units": 30
637
+ },
638
+ "expect": {
639
+ "duplicate": true,
640
+ "debited": 30
641
+ }
642
+ },
643
+ {
644
+ "operation": "debitCredits",
645
+ "input": {
646
+ "reference": "export-one",
647
+ "units": 31
648
+ },
649
+ "error": "payment_reference_conflict"
650
+ },
651
+ {
652
+ "operation": "inspect",
653
+ "expect": {
654
+ "balance": 70,
655
+ "features": [
656
+ "export"
657
+ ]
658
+ }
659
+ },
660
+ {
661
+ "operation": "inspect",
662
+ "subjectId": "tenant-b",
663
+ "expect": {
664
+ "balance": 0,
665
+ "features": [],
666
+ "subscriptions": []
667
+ }
668
+ },
669
+ {
670
+ "operation": "inspect",
671
+ "clock": 5000,
672
+ "expect": {
673
+ "balance": 0,
674
+ "features": []
675
+ }
676
+ },
677
+ {
678
+ "operation": "refundDebit",
679
+ "input": {
680
+ "debitReference": "export-one"
681
+ },
682
+ "expect": {
683
+ "restored": 0,
684
+ "expired": 30,
685
+ "duplicate": false
686
+ }
687
+ },
688
+ {
689
+ "operation": "grantCredits",
690
+ "input": {
691
+ "reference": "promotion-one",
692
+ "units": 20,
693
+ "expiresAt": null
694
+ },
695
+ "expect": {
696
+ "granted": 20,
697
+ "expiresAt": null,
698
+ "duplicate": false
699
+ }
700
+ },
701
+ {
702
+ "operation": "debitCredits",
703
+ "input": {
704
+ "reference": "too-large",
705
+ "units": 21
706
+ },
707
+ "error": "payment_insufficient_credits"
708
+ },
709
+ {
710
+ "operation": "inspect",
711
+ "expect": {
712
+ "balance": 20,
713
+ "features": []
714
+ }
715
+ }
716
+ ]
717
+ }
718
+ }