@openrails/billing-ui 0.233.2 → 0.235.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 (41) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +18 -14
  3. package/dist/account/account-billing.d.ts +6 -3
  4. package/dist/account/change-card-dialog.d.ts +5 -2
  5. package/dist/account/payment-methods-panel.d.ts +6 -3
  6. package/dist/client/client.d.ts +33 -17
  7. package/dist/client/errors.d.ts +1 -4
  8. package/dist/client/generated/error-codes.d.ts +1 -1
  9. package/dist/client/generated/routes.d.ts +150 -147
  10. package/dist/client/generated/wire.d.ts +204 -49
  11. package/dist/client/index.d.ts +2 -2
  12. package/dist/client/types.d.ts +131 -42
  13. package/dist/{client-DXUPzA8C.js → client-BpzCZes3.js} +93 -51
  14. package/dist/client-BpzCZes3.js.map +1 -0
  15. package/dist/client.js +1 -1
  16. package/dist/{config-BQELtBh4.js → config-qLcHvK0Q.js} +13 -13
  17. package/dist/config-qLcHvK0Q.js.map +1 -0
  18. package/dist/i18n/context.d.ts +1 -1
  19. package/dist/i18n/messages.d.ts +1 -1
  20. package/dist/index.js +184 -177
  21. package/dist/index.js.map +1 -1
  22. package/dist/locales/de.js +5 -4
  23. package/dist/locales/de.js.map +1 -1
  24. package/dist/locales/en.d.ts +5 -4
  25. package/dist/locales/en.js +5 -4
  26. package/dist/locales/en.js.map +1 -1
  27. package/dist/locales/es.js +5 -4
  28. package/dist/locales/es.js.map +1 -1
  29. package/dist/locales/ja.js +5 -4
  30. package/dist/locales/ja.js.map +1 -1
  31. package/dist/locales/ko.js +5 -4
  32. package/dist/locales/ko.js.map +1 -1
  33. package/dist/locales/zh.js +5 -4
  34. package/dist/locales/zh.js.map +1 -1
  35. package/dist/react/context.d.ts +6 -5
  36. package/dist/react/hooks.d.ts +10 -10
  37. package/dist/react.js +1 -1
  38. package/dist/styles.css +1 -1
  39. package/package.json +2 -2
  40. package/dist/client-DXUPzA8C.js.map +0 -1
  41. package/dist/config-BQELtBh4.js.map +0 -1
@@ -42,6 +42,13 @@ export type Capabilities = {
42
42
  route_groups: Record<string, boolean> | null;
43
43
  features: Record<string, boolean> | null;
44
44
  };
45
+ export type CaptchaConfig = {
46
+ provider: string;
47
+ site_key: string;
48
+ script_url: string;
49
+ action: string;
50
+ token_header: string;
51
+ };
45
52
  export type CaptchaStatus = {
46
53
  enabled: boolean;
47
54
  required: boolean;
@@ -61,9 +68,6 @@ export type CardEntry = {
61
68
  exp_year?: number;
62
69
  cvc?: string;
63
70
  };
64
- export type ChangeTierParams = {
65
- price_id?: string;
66
- };
67
71
  export type CheckoutSession = {
68
72
  id: string;
69
73
  status: string;
@@ -129,9 +133,10 @@ export type CheckoutSessionSavedMethod = {
129
133
  rail: string;
130
134
  card: CardDetails | null;
131
135
  };
132
- export type CollectionPaymentMethod = {
133
- currency: string;
134
- payment_method_id: string;
136
+ export type CreateOrderParams = {
137
+ lines?: OrderLineParams[];
138
+ expected_total?: string;
139
+ payment?: OrderPayment;
135
140
  };
136
141
  export type CreatePaymentMethodParams = {
137
142
  psp_id?: string;
@@ -150,6 +155,12 @@ export type CurrencyUnits = {
150
155
  decimals: number;
151
156
  minor_decimals: number;
152
157
  };
158
+ export type CustomerAccount = {
159
+ id: string;
160
+ balances: Balance[];
161
+ default_payment_methods: DefaultPaymentMethod[];
162
+ unread_notifications: number;
163
+ };
153
164
  export type CustomerAmount = {
154
165
  min_amount: string;
155
166
  max_amount: string;
@@ -158,16 +169,23 @@ export type CustomerCancelSubscriptionParams = {
158
169
  reason?: string;
159
170
  signature?: string;
160
171
  };
161
- export type CustomerChangeTierParams = {
162
- price_id?: string;
172
+ export type CustomerChangeSubscriptionParams = {
173
+ price_id?: string | null;
174
+ quantity?: number | null;
163
175
  signature?: string;
164
176
  };
165
177
  export type CustomerEntitlement = {
178
+ customer_id: string;
166
179
  entitlement: string;
180
+ quantity: number | null;
167
181
  };
168
182
  export type CustomerNotificationLookup = {
169
183
  notifications: Record<string, Notification | null> | null;
170
184
  };
185
+ export type DefaultPaymentMethod = {
186
+ currency: string;
187
+ payment_method_id: string;
188
+ };
171
189
  export type DriftField = {
172
190
  field: string;
173
191
  openrails_value: string;
@@ -198,10 +216,11 @@ export type Invoice = {
198
216
  tax: Record<string, unknown> | null;
199
217
  billing_contacts: InvoiceContact[];
200
218
  memo: string | null;
201
- status: "draft" | "open" | "paid" | "past_due" | "uncollectible" | "voided";
219
+ status: "draft" | "open" | "paid" | "uncollectible" | "voided";
202
220
  collection_method: "charge_automatically" | "send_invoice";
203
221
  issued_at: string | null;
204
222
  due_at: string | null;
223
+ delinquent: boolean;
205
224
  paid_at: string | null;
206
225
  voided_at: string | null;
207
226
  uncollectible_at: string | null;
@@ -227,26 +246,32 @@ export type InvoiceLineItem = {
227
246
  };
228
247
  export type InvoicePayNow = {
229
248
  invoice: Invoice;
230
- payment: InvoicePayment;
249
+ payment_id: string | null;
231
250
  operation: PaymentOperation;
232
251
  replayed: boolean;
233
252
  };
234
- export type InvoicePayment = {
253
+ export type Mandate = {
235
254
  id: string;
236
- invoice_id: string;
237
- currency: string;
238
- amount: string;
239
- status: "attempted" | "failed" | "settled";
255
+ customer_id: string;
240
256
  payment_method_id: string | null;
241
- rail: string | null;
242
- transaction_id: string | null;
243
- failure_code: string | null;
244
- failure_reason: string | null;
245
- attempted_at: string;
246
- settled_at: string | null;
257
+ psp_id: string;
258
+ kind: "card_on_file" | "recurring" | "unscheduled";
259
+ subscription_id: string | null;
260
+ currency: string | null;
261
+ status: "active" | "ended" | "requires_reconsent" | "revoked";
262
+ end_reason: "brand_changed" | "closed" | "customer_revoked" | "payment_method_removed" | "replaced" | "subscription_ended" | null;
263
+ ended_at: string | null;
264
+ card_brand: string | null;
265
+ initial_transaction_id: string | null;
266
+ network_transaction_id: string | null;
267
+ transaction_link_id: string | null;
268
+ storing_attempt_id: string | null;
269
+ accepted_at: string;
270
+ created_at: string;
247
271
  };
248
272
  export type MarkNotificationsReadParams = {
249
273
  notification_ids?: string[];
274
+ all?: boolean;
250
275
  };
251
276
  export type MintCheckoutSessionParams = {
252
277
  price_id?: string;
@@ -260,6 +285,8 @@ export type NextAction = {
260
285
  type: string;
261
286
  url: string | null;
262
287
  transactions: string[];
288
+ psp_id: string | null;
289
+ payload: Record<string, string> | null;
263
290
  };
264
291
  export type Notification = {
265
292
  id: string;
@@ -304,10 +331,84 @@ export type NotificationData = {
304
331
  rail?: string;
305
332
  rail_subscription_id?: string;
306
333
  transaction_id?: string;
334
+ quantity?: number;
307
335
  amount?: string;
308
336
  product_name?: string;
309
337
  payment_method?: string;
310
338
  user_email?: string;
339
+ payment_id?: string;
340
+ order_id?: string;
341
+ order_number?: string;
342
+ };
343
+ export type Order = {
344
+ id: string;
345
+ customer_id: string;
346
+ origin: "customer" | "merchant";
347
+ status: "canceled" | "expired" | "open" | "paid" | "processing" | "requires_action";
348
+ number: string | null;
349
+ currency: string;
350
+ total: string;
351
+ lines: OrderLine[];
352
+ next_action: NextAction | null;
353
+ last_payment_error: PaymentFailure | null;
354
+ payment_options: OrderPaymentOption[];
355
+ payment_method_id: string | null;
356
+ payment_id: string | null;
357
+ expires_at: string;
358
+ paid_at: string | null;
359
+ canceled_at: string | null;
360
+ expired_at: string | null;
361
+ created_at: string;
362
+ };
363
+ export type OrderLine = {
364
+ id: string;
365
+ price_id: string;
366
+ product_id: string;
367
+ description: string;
368
+ quantity: number | null;
369
+ unit_amount: string;
370
+ amount: string;
371
+ ownership: "consumable" | "extend" | "unique";
372
+ billing_interval_hours: number | null;
373
+ access_duration_hours: number | null;
374
+ subscription_id: string | null;
375
+ product_access_id: string | null;
376
+ };
377
+ export type OrderLineParams = {
378
+ price_id?: string;
379
+ quantity?: number;
380
+ };
381
+ export type OrderLineRefusal = {
382
+ code: string;
383
+ message: string;
384
+ owned_by: string | null;
385
+ hint: string | null;
386
+ };
387
+ export type OrderPayment = {
388
+ payment_method_id?: string;
389
+ };
390
+ export type OrderPaymentOption = {
391
+ psp_id: string;
392
+ rail: string;
393
+ accepts: string[];
394
+ };
395
+ export type OrderPreview = {
396
+ currency: string;
397
+ total: string;
398
+ lines: OrderPreviewLine[];
399
+ payment_options: OrderPaymentOption[];
400
+ };
401
+ export type OrderPreviewLine = {
402
+ price_id: string;
403
+ product_id: string;
404
+ description: string;
405
+ quantity: number | null;
406
+ unit_amount: string;
407
+ amount: string;
408
+ ownership: "consumable" | "extend" | "unique";
409
+ billing_interval_hours: number | null;
410
+ access_duration_hours: number | null;
411
+ refusal: OrderLineRefusal | null;
311
412
  };
312
413
  export type PSPLinkState = {
313
414
  status: "error" | "linked" | "pending_manual_link" | "sync_disabled";
@@ -340,6 +441,10 @@ export type PayCheckoutSessionParams = {
340
441
  export type PayInvoiceParams = {
341
442
  payment_method_id?: string;
342
443
  };
444
+ export type PayOrderParams = {
445
+ payment?: OrderPayment;
446
+ expected_total?: string;
447
+ };
343
448
  export type Payment = {
344
449
  id: string;
345
450
  kind: "charge" | "chargeback" | "dispute_reversal" | "refund";
@@ -349,7 +454,10 @@ export type Payment = {
349
454
  currency: string;
350
455
  customer_id: string;
351
456
  subscription_id: string | null;
352
- price_id: string;
457
+ order_id: string | null;
458
+ invoice_id: string | null;
459
+ quantity: number | null;
460
+ price_id: string | null;
353
461
  price: Price | null;
354
462
  product: ProductSummary | null;
355
463
  channel: "manual" | "rail";
@@ -377,11 +485,16 @@ export type PaymentMethod = {
377
485
  customer_id: string;
378
486
  rail: string;
379
487
  psp_id: string | null;
488
+ status: "active" | "closed" | "removed" | "replaced";
489
+ replaced_by: string | null;
380
490
  card: CardDetails | null;
381
491
  billing_details: BillingDetails | null;
382
492
  health: PaymentMethodHealth;
493
+ contact_cardholder_at: string | null;
494
+ reusable: boolean;
495
+ mandates: Mandate[];
383
496
  subscriptions: PaymentMethodSubscription[];
384
- collection_currencies: string[];
497
+ default_currencies: string[];
385
498
  created_at: string;
386
499
  };
387
500
  export type PaymentMethodHealth = {
@@ -425,9 +538,18 @@ export type PendingAction = {
425
538
  export type PortalResponse = {
426
539
  url: string;
427
540
  };
541
+ export type PreviewOrderParams = {
542
+ lines?: OrderLineParams[];
543
+ };
544
+ export type PreviewSubscriptionChangeParams = {
545
+ price_id?: string | null;
546
+ quantity?: number | null;
547
+ };
428
548
  export type Price = {
429
549
  customer_amount?: CustomerAmount;
550
+ quantity: Quantity | null;
430
551
  revision: number;
552
+ version: number;
431
553
  id: string;
432
554
  key: string;
433
555
  product_id: string;
@@ -453,6 +575,7 @@ export type Product = {
453
575
  credit_grant?: CreditGrantSpec;
454
576
  tier_group: string | null;
455
577
  tier_rank: number;
578
+ ownership: "consumable" | "extend" | "unique" | null;
456
579
  archived: boolean;
457
580
  prices: Price[];
458
581
  created_at: string;
@@ -467,6 +590,7 @@ export type ProductAccessGrant = {
467
590
  source_type: "grace" | "grant" | "purchase" | "subscription";
468
591
  source_id: string;
469
592
  payment_id: string | null;
593
+ quantity: number | null;
470
594
  grant_reason: "comp" | "import" | "migration" | "staff" | null;
471
595
  granted_by: string | null;
472
596
  note: string | null;
@@ -490,7 +614,19 @@ export type ProductSummary = {
490
614
  export type PublicConfig = {
491
615
  capabilities: Capabilities;
492
616
  currencies: CurrencyUnits[];
617
+ rails: RailDefinition[];
493
618
  payment: PaymentConfig | null;
619
+ captcha: CaptchaConfig | null;
620
+ };
621
+ export type Quantity = {
622
+ min: number;
623
+ max: number;
624
+ };
625
+ export type RailDefinition = {
626
+ rail: "ccbill" | "nmi" | "solana" | "stripe";
627
+ display_name: string;
628
+ credential_keys: string[];
629
+ setting_keys: string[];
494
630
  };
495
631
  export type ReplacePaymentMethodCardParams = {
496
632
  payment_token?: string;
@@ -500,9 +636,22 @@ export type ReplacePaymentMethodCardParams = {
500
636
  export type RetrySubscriptionNowParams = {
501
637
  payment_method_id?: string;
502
638
  };
503
- export type SetSubscriptionPaymentMethodParams = {
639
+ export type ScheduledChange = {
640
+ price_id: string;
641
+ quantity: number | null;
642
+ effective_at: string;
643
+ source: "change" | "migration";
644
+ price_migration_id: string | null;
645
+ created_at: string;
646
+ price?: Price;
647
+ product?: ProductSummary;
648
+ };
649
+ export type SetDefaultPaymentMethodParams = {
504
650
  payment_method_id?: string;
505
651
  };
652
+ export type SetSubscriptionPaymentMethodParams = {
653
+ payment_method_id?: string | null;
654
+ };
506
655
  export type SolanaPayGetResponse = {
507
656
  label: string;
508
657
  icon: string;
@@ -553,23 +702,20 @@ export type StripeEngineAuthentication = {
553
702
  export type Subscription = {
554
703
  collection_policy: string;
555
704
  recovery?: PaymentRecovery;
556
- last_retry_at: string | null;
557
- retry_attempts: number | null;
558
- next_retry_at: string | null;
559
- grace_ends_at: string | null;
705
+ dunning: SubscriptionDunning | null;
560
706
  deletion_scheduled_at?: string;
561
- payments?: Payment[];
562
707
  id: string;
563
708
  customer_id: string;
564
709
  product_id: string;
565
710
  price_id: string;
566
- quantity: number;
711
+ quantity: number | null;
567
712
  psp_id: string;
568
713
  rail: string;
569
714
  rail_subscription_id: string | null;
570
715
  status: "active" | "awaiting_method" | "canceled" | "past_due" | "pending" | "unverified";
571
- scheduled_price_id?: string;
716
+ scheduled_change: ScheduledChange | null;
572
717
  payment_method_id: string | null;
718
+ mandate_id: string | null;
573
719
  started_at: string;
574
720
  ended_at: string | null;
575
721
  current_period_starts_at: string | null;
@@ -582,8 +728,6 @@ export type Subscription = {
582
728
  cancel_mode: string;
583
729
  price?: Price;
584
730
  product?: ProductSummary;
585
- scheduled_price?: Price;
586
- scheduled_product?: ProductSummary;
587
731
  card?: CardDetails;
588
732
  cancel_portal_url?: string;
589
733
  access?: SubscriptionAccess;
@@ -601,19 +745,11 @@ export type SubscriptionAccess = {
601
745
  starts_at: string;
602
746
  ends_at?: string;
603
747
  };
604
- export type SubscriptionRetryNowResult = {
605
- subscription: Subscription;
606
- operation: PaymentOperation;
607
- replayed: boolean;
608
- };
609
- export type SupportedTokensResponse = {
610
- tokens: TokenInfo[];
611
- };
612
- export type TierChange = {
748
+ export type SubscriptionChange = {
613
749
  status: string;
614
- action?: string;
615
750
  effective?: string;
616
751
  price_id: string;
752
+ quantity: number | null;
617
753
  rail: string;
618
754
  subscription_id?: string;
619
755
  next_action?: NextAction;
@@ -626,18 +762,34 @@ export type TierChange = {
626
762
  next_charge_date?: string;
627
763
  operation_id?: string;
628
764
  };
629
- export type TierChangePreview = {
630
- action: string;
765
+ export type SubscriptionChangePreview = {
766
+ effective: string;
631
767
  price_id: string;
768
+ quantity: number | null;
632
769
  rail: string;
633
770
  currency: string;
634
771
  amount_due_now: string;
635
772
  next_charge_amount: string;
636
773
  next_charge_date?: string;
637
- effective: string;
638
774
  is_estimate: boolean;
639
775
  message?: string;
640
776
  };
777
+ export type SubscriptionDunning = {
778
+ attempts: number;
779
+ retries_left: number | null;
780
+ next_retry_at: string | null;
781
+ final_retry_at: string | null;
782
+ waiting_for_new_card: boolean;
783
+ last_failure_reason: "authentication_required" | "blocked_by_psp" | "call_issuer" | "card_not_supported" | "communication_error" | "currency_not_supported" | "do_not_honor" | "duplicate_transaction" | "expired_card" | "fraudulent" | "gateway_rejected" | "generic_decline" | "incorrect_address" | "incorrect_cvc" | "incorrect_number" | "incorrect_zip" | "insufficient_funds" | "invalid_account" | "invalid_expiry" | "invalid_pin" | "invalid_request" | "issuer_unavailable" | "lost_card" | "merchant_config" | "no_such_issuer" | "over_limit" | "pickup_card" | "processing_error" | "restricted_card" | "retry_later" | "security_violation" | "stolen_card" | "stop_recurring" | "transaction_not_allowed" | "try_again_later" | "unknown" | "update_cardholder_data" | null;
784
+ };
785
+ export type SubscriptionRetryNowResult = {
786
+ subscription: Subscription;
787
+ operation: PaymentOperation;
788
+ replayed: boolean;
789
+ };
790
+ export type SupportedTokensResponse = {
791
+ tokens: TokenInfo[];
792
+ };
641
793
  export type TokenBalance = {
642
794
  amount: string;
643
795
  units: string;
@@ -663,15 +815,18 @@ export type TokenQuote = {
663
815
  quoted_at: string;
664
816
  expires_at: string;
665
817
  };
666
- export type UnreadCount = {
667
- unread_count: number;
818
+ export type UpdatePaymentMethodParams = {
819
+ exp_month?: number;
820
+ exp_year?: number;
821
+ billing_details?: BillingDetails;
822
+ reusable?: boolean;
668
823
  };
669
824
  export type Usage = {
670
825
  customer_id: string;
671
826
  currency: string;
672
827
  from: string;
673
828
  to: string;
674
- group_by: "event_type" | "function" | "invoker" | "resource" | "tier";
829
+ group_by: "event_type" | "invoker" | "resource";
675
830
  rows: UsageRow[];
676
831
  };
677
832
  export type UsageRow = {
@@ -1,4 +1,4 @@
1
- export { CANCEL_REASON_MAX, CANCEL_REASON_MIN, createBillingClient, isWalletAction, isWalletRejection, RETRY_BUDGET_MS, signWalletAction, WalletRejectedError, type BillingClient, type BillingClientOptions, type CheckoutSourceOptions, type ListOptions, type SendSolanaTransaction, } from './client';
1
+ export { CANCEL_REASON_MAX, CANCEL_REASON_MIN, createBillingClient, isWalletAction, isWalletRejection, RETRY_BUDGET_MS, signWalletAction, WalletRejectedError, type BillingClient, type BillingClientOptions, type CheckoutSourceOptions, type ListOptions, type SendSolanaTransaction, type SubscriptionChangeInput, } from './client';
2
2
  export { BillingError, isBillingError, isServerError, readBillingError, toBillingError, type BillingErrorBody, } from './errors';
3
- export type { CardSetup, CardSummary, Currency, CurrencyScales, PaymentConfig, PublicConfig, CheckoutSessionLink, Invoice, ListPage, NewCard, NextAction, Page, Payment, PaymentAuthentication, PaymentMethod, PaymentOperation, PaymentRecovery, Price, Product, SolanaToken, Subscription, SubscriptionProduct, SubscriptionStatus, TierChange, TierChangePreview, } from './types';
3
+ export type { Account, Balance, CaptchaConfig, CardSetup, CardSummary, Currency, CurrencyScales, PaymentConfig, PublicConfig, CheckoutSessionLink, Invoice, ListPage, NewCard, NextAction, Page, Payment, PaymentAuthentication, PaymentMethod, PaymentOperation, PaymentRecovery, Price, Product, SolanaToken, Subscription, SubscriptionDunning, SubscriptionProduct, SubscriptionStatus, SubscriptionChange, SubscriptionChangePreview, } from './types';
4
4
  export { amountToDecimal, decimalToAmount, formatAmount, type Amount, } from '../lib/money';