@thorprovider/types 7.6.0 → 7.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/src/order.ts CHANGED
@@ -101,6 +101,21 @@ export interface OrderDeliveryGroup {
101
101
  lineIds?: string[];
102
102
  }
103
103
 
104
+ /** One payment captured/authorized against an order. */
105
+ export type OrderPaymentStatus = 'authorized' | 'captured' | 'canceled' | 'pending';
106
+
107
+ export interface OrderPayment {
108
+ id: string;
109
+ providerId: string;
110
+ /** Provider display label when the adapter can resolve one. */
111
+ label?: string;
112
+ /** Payment amount in the order currency. */
113
+ amount?: Money;
114
+ status: OrderPaymentStatus;
115
+ capturedAt?: string;
116
+ canceledAt?: string;
117
+ }
118
+
104
119
  /**
105
120
  * Order
106
121
  *
@@ -153,7 +168,15 @@ export interface Order {
153
168
  providerId?: string;
154
169
  label?: string;
155
170
  detail?: string;
171
+ amount?: Money;
172
+ capturedAt?: string;
156
173
  };
174
+ /**
175
+ * Every payment on the order, when the backend reports them. Kept separate
176
+ * from `payment` (the first/primary payment) so a multi-instrument checkout
177
+ * can render its breakdown after a reload without inventing amounts.
178
+ */
179
+ payments?: OrderPayment[];
157
180
  /** Backend tax rate in basis points, when the order reports one rate. */
158
181
  taxRateBps?: number;
159
182
 
package/src/payment.ts CHANGED
@@ -8,6 +8,8 @@
8
8
  * @see packages/adapters/PAYMENT_METHODS_ARCHITECTURE.md
9
9
  */
10
10
 
11
+ import type { Money } from './common';
12
+
11
13
  /**
12
14
  * Payment method type identifier
13
15
  * Normalized across all backends
@@ -22,11 +24,13 @@
22
24
  */
23
25
  export type PaymentMethodType =
24
26
  | 'card' // Credit/debit cards (Visa, Mastercard, Amex, etc.)
25
- | 'wallet' // Digital wallets (Apple Pay, Google Pay, PayPal)
26
- | 'bank_transfer' // Bank transfers (ACH, SEPA, wire transfer)
27
+ | 'wallet' // Digital wallets (Apple Pay, Google Pay, PayPal, Cash App)
28
+ | 'bank_transfer' // Bank transfers (ACH, SEPA, wire transfer, Zelle)
27
29
  | 'buy_now_pay_later' // BNPL services (Klarna, Affirm, Afterpay)
28
30
  | 'cash_on_delivery' // Cash on delivery / Manual payment
29
31
  | 'crypto' // Cryptocurrency payments
32
+ | 'gift_card' // Redeemable gift-card balance
33
+ | 'store_credit' // Customer store-credit balance
30
34
  | 'other'; // Custom or unclassified methods
31
35
 
32
36
  /**
@@ -257,3 +261,96 @@ export interface CachedPaymentMethods {
257
261
  */
258
262
  ttl: number;
259
263
  }
264
+
265
+ /**
266
+ * When a checkout payment is captured.
267
+ *
268
+ * - `now`: captured as part of the checkout completion (gift card, store credit,
269
+ * card/PSP that supports immediate capture).
270
+ * - `deferred`: authorized at checkout and captured later by the admin (Zelle,
271
+ * Cash App, system/manual methods).
272
+ */
273
+ export type CheckoutCapturePolicy = 'now' | 'deferred'
274
+
275
+ /**
276
+ * One instrument of the checkout payment plan.
277
+ *
278
+ * The backend is authoritative: `amount` is the exact amount for this
279
+ * instrument and the plan must sum to the cart total. Gift card and store credit
280
+ * carry the data the backend needs to validate and create the payment session.
281
+ */
282
+ export interface CheckoutPaymentPlanItem {
283
+ provider_id: string
284
+ amount: number
285
+ capture: CheckoutCapturePolicy
286
+ /** Gift-card code; required when `provider_id` is the gift-card provider. */
287
+ gift_card_code?: string
288
+ /** Store-credit account id; resolved from the customer when omitted. */
289
+ account_id?: string
290
+ }
291
+
292
+ /**
293
+ * Result of validating a gift-card code before it is added to a payment plan.
294
+ *
295
+ * The backend is the authority: this is a read-only check, not a session or a
296
+ * reservation. The balance and currency belong to the gift card; a valid card
297
+ * can still be rejected later when the plan is completed if its balance or
298
+ * currency changed.
299
+ */
300
+ export type GiftCardValidationResult =
301
+ | {
302
+ valid: true
303
+ status: string
304
+ balance: Money
305
+ expiresAt?: string
306
+ }
307
+ | {
308
+ valid: false
309
+ reason: string
310
+ status?: string
311
+ }
312
+
313
+ /**
314
+ * One store-credit account available to the authenticated customer.
315
+ *
316
+ * Amounts are backend-authoritative. The checkout only offers accounts whose
317
+ * currency matches the cart currency; the backend still validates the account
318
+ * and amount again when the payment plan is completed.
319
+ */
320
+ export interface StoreCreditAccountSummary {
321
+ id: string
322
+ currencyCode: string
323
+ balance: Money
324
+ credits?: Money
325
+ debits?: Money
326
+ }
327
+
328
+ /**
329
+ * Authoritative payment state returned by the checkout completion.
330
+ *
331
+ * `captured_amount` and `pending_amount` are separate from `total`: the order
332
+ * total is never reduced by a payment.
333
+ */
334
+ export interface CheckoutPaymentSummaryPayment {
335
+ id: string
336
+ provider_id: string
337
+ amount: number
338
+ capture: CheckoutCapturePolicy
339
+ captured_at: string | null
340
+ }
341
+
342
+ export type CheckoutPaymentSummaryStatus =
343
+ | 'captured'
344
+ | 'partially_captured'
345
+ | 'pending'
346
+ | 'reconciliation_required'
347
+
348
+ export interface CheckoutPaymentSummary {
349
+ total: number
350
+ captured_amount: number
351
+ pending_amount: number
352
+ status: CheckoutPaymentSummaryStatus
353
+ payments: CheckoutPaymentSummaryPayment[]
354
+ reconciliation_required: boolean
355
+ errors?: Array<{ code: string; message: string }>
356
+ }
package/AGENTS.md DELETED
@@ -1 +0,0 @@
1
- <!-- TYPES-AGENTS-MD-START -->[@thorprovider/types Docs]|root: ./types|Electrostore MVP: see director roadmap.|To regenerate: yarn generate:agents-index|.:{README.md}|src:{header-config.README.md}<!-- TYPES-AGENTS-MD-END -->