@openrails/billing-ui 0.233.2 → 0.234.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.
@@ -133,6 +133,11 @@ export type CollectionPaymentMethod = {
133
133
  currency: string;
134
134
  payment_method_id: string;
135
135
  };
136
+ export type CreateOrderParams = {
137
+ lines?: OrderLineParams[];
138
+ expected_total?: string;
139
+ payment?: OrderPayment;
140
+ };
136
141
  export type CreatePaymentMethodParams = {
137
142
  psp_id?: string;
138
143
  payment_token?: 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
+ collection_payment_methods: CollectionPaymentMethod[];
162
+ unread_notifications: number;
163
+ };
153
164
  export type CustomerAmount = {
154
165
  min_amount: string;
155
166
  max_amount: string;
@@ -198,10 +209,11 @@ export type Invoice = {
198
209
  tax: Record<string, unknown> | null;
199
210
  billing_contacts: InvoiceContact[];
200
211
  memo: string | null;
201
- status: "draft" | "open" | "paid" | "past_due" | "uncollectible" | "voided";
212
+ status: "draft" | "open" | "paid" | "uncollectible" | "voided";
202
213
  collection_method: "charge_automatically" | "send_invoice";
203
214
  issued_at: string | null;
204
215
  due_at: string | null;
216
+ delinquent: boolean;
205
217
  paid_at: string | null;
206
218
  voided_at: string | null;
207
219
  uncollectible_at: string | null;
@@ -227,24 +239,10 @@ export type InvoiceLineItem = {
227
239
  };
228
240
  export type InvoicePayNow = {
229
241
  invoice: Invoice;
230
- payment: InvoicePayment;
242
+ payment_id: string | null;
231
243
  operation: PaymentOperation;
232
244
  replayed: boolean;
233
245
  };
234
- export type InvoicePayment = {
235
- id: string;
236
- invoice_id: string;
237
- currency: string;
238
- amount: string;
239
- status: "attempted" | "failed" | "settled";
240
- 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;
247
- };
248
246
  export type MarkNotificationsReadParams = {
249
247
  notification_ids?: string[];
250
248
  };
@@ -260,6 +258,8 @@ export type NextAction = {
260
258
  type: string;
261
259
  url: string | null;
262
260
  transactions: string[];
261
+ psp_id: string | null;
262
+ payload: Record<string, string> | null;
263
263
  };
264
264
  export type Notification = {
265
265
  id: string;
@@ -309,6 +309,76 @@ export type NotificationData = {
309
309
  payment_method?: string;
310
310
  user_email?: string;
311
311
  };
312
+ export type Order = {
313
+ id: string;
314
+ customer_id: string;
315
+ origin: "customer" | "merchant";
316
+ status: "canceled" | "expired" | "open" | "paid" | "processing" | "requires_action";
317
+ number: string | null;
318
+ currency: string;
319
+ total: string;
320
+ lines: OrderLine[];
321
+ next_action: NextAction | null;
322
+ last_payment_error: PaymentFailure | null;
323
+ payment_options: OrderPaymentOption[];
324
+ payment_method_id: string | null;
325
+ payment_id: string | null;
326
+ expires_at: string;
327
+ paid_at: string | null;
328
+ canceled_at: string | null;
329
+ expired_at: string | null;
330
+ created_at: string;
331
+ };
332
+ export type OrderLine = {
333
+ id: string;
334
+ price_id: string;
335
+ product_id: string;
336
+ description: string;
337
+ quantity: number | null;
338
+ unit_amount: string;
339
+ amount: string;
340
+ ownership: "consumable" | "extend" | "unique";
341
+ billing_interval_hours: number | null;
342
+ access_duration_hours: number | null;
343
+ subscription_id: string | null;
344
+ product_access_id: string | null;
345
+ };
346
+ export type OrderLineParams = {
347
+ price_id?: string;
348
+ quantity?: number;
349
+ };
350
+ export type OrderLineRefusal = {
351
+ code: string;
352
+ message: string;
353
+ owned_by: string | null;
354
+ hint: string | null;
355
+ };
356
+ export type OrderPayment = {
357
+ payment_method_id?: string;
358
+ };
359
+ export type OrderPaymentOption = {
360
+ psp_id: string;
361
+ rail: string;
362
+ accepts: string[];
363
+ };
364
+ export type OrderPreview = {
365
+ currency: string;
366
+ total: string;
367
+ lines: OrderPreviewLine[];
368
+ payment_options: OrderPaymentOption[];
369
+ };
370
+ export type OrderPreviewLine = {
371
+ price_id: string;
372
+ product_id: string;
373
+ description: string;
374
+ quantity: number | null;
375
+ unit_amount: string;
376
+ amount: string;
377
+ ownership: "consumable" | "extend" | "unique";
378
+ billing_interval_hours: number | null;
379
+ access_duration_hours: number | null;
380
+ refusal: OrderLineRefusal | null;
381
+ };
312
382
  export type PSPLinkState = {
313
383
  status: "error" | "linked" | "pending_manual_link" | "sync_disabled";
314
384
  ids: Record<string, string> | null;
@@ -340,6 +410,10 @@ export type PayCheckoutSessionParams = {
340
410
  export type PayInvoiceParams = {
341
411
  payment_method_id?: string;
342
412
  };
413
+ export type PayOrderParams = {
414
+ payment?: OrderPayment;
415
+ expected_total?: string;
416
+ };
343
417
  export type Payment = {
344
418
  id: string;
345
419
  kind: "charge" | "chargeback" | "dispute_reversal" | "refund";
@@ -349,7 +423,9 @@ export type Payment = {
349
423
  currency: string;
350
424
  customer_id: string;
351
425
  subscription_id: string | null;
352
- price_id: string;
426
+ order_id: string | null;
427
+ invoice_id: string | null;
428
+ price_id: string | null;
353
429
  price: Price | null;
354
430
  product: ProductSummary | null;
355
431
  channel: "manual" | "rail";
@@ -425,6 +501,9 @@ export type PendingAction = {
425
501
  export type PortalResponse = {
426
502
  url: string;
427
503
  };
504
+ export type PreviewOrderParams = {
505
+ lines?: OrderLineParams[];
506
+ };
428
507
  export type Price = {
429
508
  customer_amount?: CustomerAmount;
430
509
  revision: number;
@@ -453,6 +532,7 @@ export type Product = {
453
532
  credit_grant?: CreditGrantSpec;
454
533
  tier_group: string | null;
455
534
  tier_rank: number;
535
+ ownership: "consumable" | "extend" | "unique" | null;
456
536
  archived: boolean;
457
537
  prices: Price[];
458
538
  created_at: string;
@@ -500,6 +580,16 @@ export type ReplacePaymentMethodCardParams = {
500
580
  export type RetrySubscriptionNowParams = {
501
581
  payment_method_id?: string;
502
582
  };
583
+ export type ScheduledChange = {
584
+ price_id: string;
585
+ quantity: number | null;
586
+ effective_at: string;
587
+ source: "change" | "migration";
588
+ price_migration_id: string | null;
589
+ created_at: string;
590
+ price?: Price;
591
+ product?: ProductSummary;
592
+ };
503
593
  export type SetSubscriptionPaymentMethodParams = {
504
594
  payment_method_id?: string;
505
595
  };
@@ -553,10 +643,7 @@ export type StripeEngineAuthentication = {
553
643
  export type Subscription = {
554
644
  collection_policy: string;
555
645
  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;
646
+ dunning: SubscriptionDunning | null;
560
647
  deletion_scheduled_at?: string;
561
648
  payments?: Payment[];
562
649
  id: string;
@@ -568,7 +655,7 @@ export type Subscription = {
568
655
  rail: string;
569
656
  rail_subscription_id: string | null;
570
657
  status: "active" | "awaiting_method" | "canceled" | "past_due" | "pending" | "unverified";
571
- scheduled_price_id?: string;
658
+ scheduled_change: ScheduledChange | null;
572
659
  payment_method_id: string | null;
573
660
  started_at: string;
574
661
  ended_at: string | null;
@@ -582,8 +669,6 @@ export type Subscription = {
582
669
  cancel_mode: string;
583
670
  price?: Price;
584
671
  product?: ProductSummary;
585
- scheduled_price?: Price;
586
- scheduled_product?: ProductSummary;
587
672
  card?: CardDetails;
588
673
  cancel_portal_url?: string;
589
674
  access?: SubscriptionAccess;
@@ -601,6 +686,14 @@ export type SubscriptionAccess = {
601
686
  starts_at: string;
602
687
  ends_at?: string;
603
688
  };
689
+ export type SubscriptionDunning = {
690
+ attempts: number;
691
+ retries_left: number | null;
692
+ next_retry_at: string | null;
693
+ final_retry_at: string | null;
694
+ waiting_for_new_card: boolean;
695
+ 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;
696
+ };
604
697
  export type SubscriptionRetryNowResult = {
605
698
  subscription: Subscription;
606
699
  operation: PaymentOperation;
@@ -663,15 +756,12 @@ export type TokenQuote = {
663
756
  quoted_at: string;
664
757
  expires_at: string;
665
758
  };
666
- export type UnreadCount = {
667
- unread_count: number;
668
- };
669
759
  export type Usage = {
670
760
  customer_id: string;
671
761
  currency: string;
672
762
  from: string;
673
763
  to: string;
674
- group_by: "event_type" | "function" | "invoker" | "resource" | "tier";
764
+ group_by: "event_type" | "invoker" | "resource";
675
765
  rows: UsageRow[];
676
766
  };
677
767
  export type UsageRow = {
@@ -1,4 +1,4 @@
1
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';
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, CardSetup, CardSummary, Currency, CurrencyScales, PaymentConfig, PublicConfig, CheckoutSessionLink, Invoice, ListPage, NewCard, NextAction, Page, Payment, PaymentAuthentication, PaymentMethod, PaymentOperation, PaymentRecovery, Price, Product, SolanaToken, Subscription, SubscriptionDunning, SubscriptionProduct, SubscriptionStatus, TierChange, TierChangePreview, } from './types';
4
4
  export { amountToDecimal, decimalToAmount, formatAmount, type Amount, } from '../lib/money';
@@ -109,6 +109,21 @@ export declare const nextActionSchema: z.ZodObject<{
109
109
  transactions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
110
110
  }, z.core.$strip>;
111
111
  export type NextAction = z.infer<typeof nextActionSchema>;
112
+ /**
113
+ * A declined renewal being collected. `retries_left` and `final_retry_at`
114
+ * follow the merchant's dunning policy; both are null when the provider runs
115
+ * the retries. While `waiting_for_new_card`, nothing is charged until the card
116
+ * is replaced, and the subscription ends at `final_retry_at`.
117
+ */
118
+ export declare const subscriptionDunningSchema: z.ZodObject<{
119
+ attempts: z.ZodNumber;
120
+ retries_left: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
121
+ next_retry_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
122
+ final_retry_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
123
+ waiting_for_new_card: z.ZodBoolean;
124
+ last_failure_reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
125
+ }, z.core.$strip>;
126
+ export type SubscriptionDunning = z.infer<typeof subscriptionDunningSchema>;
112
127
  export declare const subscriptionSchema: z.ZodObject<{
113
128
  id: z.ZodString;
114
129
  status: z.ZodString;
@@ -131,8 +146,14 @@ export declare const subscriptionSchema: z.ZodObject<{
131
146
  starts_at: z.ZodString;
132
147
  ends_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
133
148
  }, z.core.$strip>>>;
134
- grace_ends_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
135
- next_retry_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
149
+ dunning: z.ZodOptional<z.ZodNullable<z.ZodObject<{
150
+ attempts: z.ZodNumber;
151
+ retries_left: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
152
+ next_retry_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
153
+ final_retry_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
154
+ waiting_for_new_card: z.ZodBoolean;
155
+ last_failure_reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
156
+ }, z.core.$strip>>>;
136
157
  price: z.ZodOptional<z.ZodNullable<z.ZodObject<{
137
158
  id: z.ZodString;
138
159
  key: z.ZodString;
@@ -166,38 +187,44 @@ export declare const subscriptionSchema: z.ZodObject<{
166
187
  tier_group: z.ZodOptional<z.ZodNullable<z.ZodString>>;
167
188
  tier_rank: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
168
189
  }, z.core.$strip>>>;
169
- scheduled_price: z.ZodOptional<z.ZodNullable<z.ZodObject<{
170
- id: z.ZodString;
171
- key: z.ZodString;
172
- revision: z.ZodOptional<z.ZodNumber>;
173
- product_id: z.ZodString;
174
- archived: z.ZodBoolean;
175
- unit_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
176
- customer_amount: z.ZodOptional<z.ZodNullable<z.ZodObject<{
177
- min_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
178
- max_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
190
+ scheduled_change: z.ZodOptional<z.ZodNullable<z.ZodObject<{
191
+ price_id: z.ZodString;
192
+ quantity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
193
+ effective_at: z.ZodString;
194
+ source: z.ZodString;
195
+ price: z.ZodOptional<z.ZodNullable<z.ZodObject<{
196
+ id: z.ZodString;
197
+ key: z.ZodString;
198
+ revision: z.ZodOptional<z.ZodNumber>;
199
+ product_id: z.ZodString;
200
+ archived: z.ZodBoolean;
201
+ unit_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
202
+ customer_amount: z.ZodOptional<z.ZodNullable<z.ZodObject<{
203
+ min_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
204
+ max_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
205
+ }, z.core.$strip>>>;
206
+ currency: z.ZodString;
207
+ access_duration_hours: z.ZodNullable<z.ZodNumber>;
208
+ billing_interval_hours: z.ZodNullable<z.ZodNumber>;
209
+ trial_unit_amount: z.ZodNullable<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
210
+ trial_duration_hours: z.ZodNullable<z.ZodNumber>;
211
+ psps: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodObject<{
212
+ status: z.ZodString;
213
+ ids: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
214
+ sync_status: z.ZodOptional<z.ZodNullable<z.ZodString>>;
215
+ }, z.core.$strip>>>>;
216
+ created_at: z.ZodString;
217
+ updated_at: z.ZodString;
218
+ }, z.core.$strip>>>;
219
+ product: z.ZodOptional<z.ZodNullable<z.ZodObject<{
220
+ id: z.ZodString;
221
+ key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
222
+ revision: z.ZodOptional<z.ZodNumber>;
223
+ display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
224
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
225
+ tier_group: z.ZodOptional<z.ZodNullable<z.ZodString>>;
226
+ tier_rank: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
179
227
  }, z.core.$strip>>>;
180
- currency: z.ZodString;
181
- access_duration_hours: z.ZodNullable<z.ZodNumber>;
182
- billing_interval_hours: z.ZodNullable<z.ZodNumber>;
183
- trial_unit_amount: z.ZodNullable<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
184
- trial_duration_hours: z.ZodNullable<z.ZodNumber>;
185
- psps: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodObject<{
186
- status: z.ZodString;
187
- ids: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
188
- sync_status: z.ZodOptional<z.ZodNullable<z.ZodString>>;
189
- }, z.core.$strip>>>>;
190
- created_at: z.ZodString;
191
- updated_at: z.ZodString;
192
- }, z.core.$strip>>>;
193
- scheduled_product: z.ZodOptional<z.ZodNullable<z.ZodObject<{
194
- id: z.ZodString;
195
- key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
196
- revision: z.ZodOptional<z.ZodNumber>;
197
- display_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
198
- description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
199
- tier_group: z.ZodOptional<z.ZodNullable<z.ZodString>>;
200
- tier_rank: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
201
228
  }, z.core.$strip>>>;
202
229
  card: z.ZodOptional<z.ZodNullable<z.ZodObject<{
203
230
  brand: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -427,6 +454,37 @@ export declare const paymentSchema: z.ZodObject<{
427
454
  }, z.core.$strip>>>;
428
455
  }, z.core.$strip>;
429
456
  export type Payment = z.infer<typeof paymentSchema>;
457
+ /** A customer's money in one currency. */
458
+ export declare const balanceSchema: z.ZodObject<{
459
+ currency: z.ZodString;
460
+ billing_mode: z.ZodString;
461
+ balance_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
462
+ held_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
463
+ available_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
464
+ owed_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
465
+ }, z.core.$strip>;
466
+ export type Balance = z.infer<typeof balanceSchema>;
467
+ /**
468
+ * The signed-in customer's summary (`GET /me`): money per currency, the card
469
+ * that pays each currency's invoices, and how many notices are unread.
470
+ */
471
+ export declare const accountSchema: z.ZodObject<{
472
+ id: z.ZodString;
473
+ balances: z.ZodArray<z.ZodObject<{
474
+ currency: z.ZodString;
475
+ billing_mode: z.ZodString;
476
+ balance_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
477
+ held_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
478
+ available_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
479
+ owed_amount: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
480
+ }, z.core.$strip>>;
481
+ collection_payment_methods: z.ZodArray<z.ZodObject<{
482
+ currency: z.ZodString;
483
+ payment_method_id: z.ZodString;
484
+ }, z.core.$strip>>;
485
+ unread_notifications: z.ZodNumber;
486
+ }, z.core.$strip>;
487
+ export type Account = z.infer<typeof accountSchema>;
430
488
  export declare const invoiceSchema: z.ZodObject<{
431
489
  id: z.ZodString;
432
490
  currency: z.ZodString;
@@ -439,6 +497,7 @@ export declare const invoiceSchema: z.ZodObject<{
439
497
  status: z.ZodString;
440
498
  issued_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
441
499
  due_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
500
+ delinquent: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
442
501
  paid_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
443
502
  recovery: z.ZodOptional<z.ZodNullable<z.ZodObject<{
444
503
  last_failure_reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;