@movmo_app/payments 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.
package/dist/index.d.ts CHANGED
@@ -126,6 +126,14 @@ export declare interface CreateMovmoAuthFetchOptions {
126
126
  readCookie?: (name: string) => string | null;
127
127
  }
128
128
 
129
+ /**
130
+ * The cardholder/zip subset of {@link UpdatePaymentMethodPatch} that the Edit
131
+ * flow (MOVMO-381) can mutate. Derived via `Pick` so it stays in sync if the
132
+ * editable field set grows — shared by the modal, the manager, and
133
+ * `useUpdatePaymentMethod` so the patch shape isn't restated in three places.
134
+ */
135
+ declare type EditablePaymentMethodFields = Pick<UpdatePaymentMethodPatch, 'cardholderName' | 'zip'>;
136
+
129
137
  export declare const getPaymentsConfig: () => InternalPaymentsConfig;
130
138
 
131
139
  /* Excluded from this release type: InternalPaymentsConfig */
@@ -296,6 +304,22 @@ export declare interface PaymentMethodSummary {
296
304
  expMonth: number;
297
305
  expYear: number;
298
306
  isDefault: boolean;
307
+ /**
308
+ * Which vault the row lives in. monolith-api returns this on every row
309
+ * post-MOVMO-381. Only `'spreedly'` rows accept cardholder/zip metadata
310
+ * edits — Stripe rows are immutable on those fields and the backend rejects
311
+ * the patch (4xx). The Edit menu item in PaymentMethodsManager is gated on
312
+ * this value.
313
+ *
314
+ * Optional so the UI doesn't crash on pre-MOVMO-381 monolith deployments
315
+ * that haven't shipped the new field yet — those rows behave as if
316
+ * Edit isn't available.
317
+ */
318
+ vault?: 'stripe' | 'spreedly';
319
+ /** Current cardholder name (MOVMO-381). Empty/absent for legacy rows. */
320
+ cardholderName?: string;
321
+ /** Current billing ZIP (MOVMO-381). Empty/absent for legacy rows. */
322
+ zip?: string;
299
323
  }
300
324
 
301
325
  export declare interface PaymentsConfig {
@@ -319,6 +343,14 @@ export declare interface PaymentsConfig {
319
343
 
320
344
  export declare const setPaymentsConfig: (config: Partial<PaymentsConfig>) => void;
321
345
 
346
+ export declare interface UpdatePaymentMethodPatch {
347
+ isDefault?: boolean;
348
+ /** MOVMO-381 — editable on Spreedly rows only; monolith-api rejects (4xx) Stripe rows. */
349
+ cardholderName?: string;
350
+ /** MOVMO-381 — editable on Spreedly rows only; monolith-api rejects (4xx) Stripe rows. */
351
+ zip?: string;
352
+ }
353
+
322
354
  /**
323
355
  * Calls `DELETE /v1/users/:userId/payment-methods/:methodId`.
324
356
  *
@@ -407,6 +439,27 @@ export declare interface UseSetDefaultPaymentMethodResult {
407
439
 
408
440
  export declare type UseSetDefaultPaymentMethodStatus = 'idle' | 'pending' | 'error';
409
441
 
442
+ /**
443
+ * Calls `PUT /v1/users/:userId/payment-methods/:methodId` with the
444
+ * cardholder-name + zip subset (MOVMO-381). The backend forwards to Spreedly
445
+ * for vault-backed rows and rejects the request (4xx) for Stripe-backed rows;
446
+ * the resulting `Error` carries the server's message so callers can surface it
447
+ * in the modal.
448
+ *
449
+ * Follows the same idle→pending→idle/error contract as
450
+ * `useSetDefaultPaymentMethod` (throws on failure so optimistic-update
451
+ * consumers can roll back), with a `(methodId, patch)` signature.
452
+ */
453
+ export declare const useUpdatePaymentMethod: (userId: string) => UseUpdatePaymentMethodResult;
454
+
455
+ export declare interface UseUpdatePaymentMethodResult {
456
+ updatePaymentMethod: (methodId: string, patch: EditablePaymentMethodFields) => Promise<void>;
457
+ status: UseUpdatePaymentMethodStatus;
458
+ error: string | null;
459
+ }
460
+
461
+ export declare type UseUpdatePaymentMethodStatus = 'idle' | 'pending' | 'error';
462
+
410
463
  /**
411
464
  * Fetches a user's saved payment methods from monolith-api.
412
465
  *