@movmo_app/payments 0.5.1 → 0.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/dist/index.d.ts CHANGED
@@ -39,6 +39,8 @@ declare interface CardFieldValidity {
39
39
  cvv: boolean;
40
40
  }
41
41
 
42
+ export declare type CardFormField = 'number' | 'expiry' | 'cvv' | 'zip' | 'name';
43
+
42
44
  export declare type CardFormStatus = 'idle' | 'loading' | 'ready' | 'tokenizing' | 'saving' | 'error';
43
45
 
44
46
  export declare interface CardholderTokenizeData {
@@ -52,6 +54,18 @@ export declare interface CardholderTokenizeData {
52
54
  zip?: string;
53
55
  }
54
56
 
57
+ /**
58
+ * PII-free validation snapshot: field KEYS only, never values. Lets a parent
59
+ * (e.g. `PaymentMethodsManager`) turn touched-invalid streaks into a
60
+ * consumer-side friction signal without the SDK importing an analytics
61
+ * library or leaking anything the traveler typed.
62
+ */
63
+ export declare interface CardValidationState {
64
+ valid: boolean;
65
+ missing: CardFormField[];
66
+ touchedInvalid: CardFormField[];
67
+ }
68
+
55
69
  /**
56
70
  * Builds an auth-aware `fetch` that the payments package (or any other
57
71
  * consumer that registers it via `setPaymentsConfig({ fetch })`) can call.
@@ -154,7 +168,7 @@ export declare const getPaymentsConfig: () => InternalPaymentsConfig;
154
168
  /* Excluded from this release type: InternalPaymentsConfig */
155
169
 
156
170
  export declare const MovmoCardForm: {
157
- ({ userId, onSuccess, onError, onErrorDetail, isDefault, className, defaultCardholderName, defaultCardholderFirstName, defaultCardholderLastName, autoSave, formId, hideInternalSaveButton, onCanSubmitChange, onSavingChange, autoFocus, }: MovmoCardFormProps): JSX_2.Element;
171
+ ({ userId, onSuccess, onError, onErrorDetail, isDefault, className, defaultCardholderName, defaultCardholderFirstName, defaultCardholderLastName, autoSave, formId, hideInternalSaveButton, onCanSubmitChange, onSavingChange, autoFocus, onValidationChange, }: MovmoCardFormProps): JSX_2.Element;
158
172
  displayName: string;
159
173
  };
160
174
 
@@ -221,6 +235,14 @@ export declare interface MovmoCardFormProps {
221
235
  * accounts-ui add-card modal so the user can start typing immediately.
222
236
  */
223
237
  autoFocus?: 'number' | 'cvv';
238
+ /**
239
+ * Fires whenever the validation snapshot changes (missing fields or
240
+ * touched-invalid fields). PII-free by design — carries field KEYS only,
241
+ * never values — so a parent can turn a touched-invalid streak into an
242
+ * analytics-neutral friction event without the SDK importing an analytics
243
+ * library.
244
+ */
245
+ onValidationChange?: (state: CardValidationState) => void;
224
246
  }
225
247
 
226
248
  /**
@@ -256,6 +278,30 @@ export declare interface PaymentManagerError {
256
278
  cause?: unknown;
257
279
  }
258
280
 
281
+ /**
282
+ * Payment-domain action reported by `PaymentMethodsManager`'s `onEvent`
283
+ * callback (MOVMO-479). Success-only — failures are covered by `onError`
284
+ * above. The package is analytics-agnostic: it never imports an analytics
285
+ * SDK, it just emits these action strings (plus PII-free props) for a
286
+ * consumer to map onto its own telemetry catalog.
287
+ *
288
+ * - `autoselected` — the manager auto-selected the default card on first load.
289
+ * - `selected` — a genuine user row click (NOT the internal reselection
290
+ * fired after `added`/`deleted`).
291
+ * - `added` — a new card was saved.
292
+ * - `edited` — the cardholder/zip PUT succeeded.
293
+ * - `deleted` — the delete request succeeded.
294
+ * - `set_default` — the set-default PUT succeeded.
295
+ * - `validation_error` — a touched card-form field is invalid (fires once per
296
+ * invalid streak, not per keystroke). This is a friction
297
+ * signal, not a failure — it's the analytics-neutral
298
+ * counterpart to `onError`'s `card-tokenize` source, meant
299
+ * to surface which fields trip people up. Props are
300
+ * `field_count` and `fields` (touched-invalid field KEYS
301
+ * only, e.g. `'zip'` — never card values).
302
+ */
303
+ export declare type PaymentMethodEvent = 'autoselected' | 'selected' | 'added' | 'edited' | 'deleted' | 'set_default' | 'validation_error';
304
+
259
305
  /**
260
306
  * Compact preview of a single saved card: brand icon + label. Used by
261
307
  * consumers (e.g. flights-ui's collapsed checkout drawer) to show the
@@ -288,7 +334,7 @@ export declare interface PaymentMethodPreviewProps {
288
334
  }
289
335
 
290
336
  export declare const PaymentMethodsManager: {
291
- ({ userId, defaultCardholderName, defaultCardholderFirstName, defaultCardholderLastName, selectedId, onSelect, onChange, onError, paymentTypeSelector, autoSaveFirstCard, selectionSetsDefault, showDefaultBadge, collapsible, cardLabelFormat, className, }: PaymentMethodsManagerProps): JSX_2.Element;
337
+ ({ userId, defaultCardholderName, defaultCardholderFirstName, defaultCardholderLastName, selectedId, onSelect, onChange, onError, onEvent, paymentTypeSelector, autoSaveFirstCard, selectionSetsDefault, showDefaultBadge, collapsible, cardLabelFormat, className, }: PaymentMethodsManagerProps): JSX_2.Element;
292
338
  displayName: string;
293
339
  };
294
340
 
@@ -319,6 +365,20 @@ export declare interface PaymentMethodsManagerProps {
319
365
  * gates. Additive and non-intrusive — errors are still rendered in-SDK.
320
366
  */
321
367
  onError?: (error: PaymentManagerError) => void;
368
+ /**
369
+ * Analytics-agnostic observability hook (MOVMO-479). Fires for successful
370
+ * payment-domain actions only — `onError` above already covers failures.
371
+ * The package never imports an analytics SDK; it just emits a
372
+ * `PaymentMethodEvent` action string plus PII-free props, and it's up to
373
+ * the consumer to map that to whatever telemetry system it uses (e.g.
374
+ * flights-ui's `@movmo_app/analytics` catalog). Fire points: `autoselected`
375
+ * (first-load default selection), `selected` (a genuine user row click —
376
+ * NOT the internal reselection after add/delete), `added`, `edited`
377
+ * (`fields` is key names only, never card values), `deleted`, and
378
+ * `set_default`. Kept referentially stable via a ref, same discipline as
379
+ * `onError`/`reportError`.
380
+ */
381
+ onEvent?: (action: PaymentMethodEvent, props?: Record<string, unknown>) => void;
322
382
  /**
323
383
  * Show the Credit card / PayPal / GooglePay / Klarna / ACH radios above
324
384
  * the card-capture form. Only Credit card is functional today; the others
@@ -384,7 +444,7 @@ export declare interface PaymentMethodSummary {
384
444
  vault?: 'stripe' | 'spreedly';
385
445
  /** Current cardholder name (MOVMO-381). Empty/absent for legacy rows. */
386
446
  cardholderName?: string;
387
- /** Current billing ZIP (MOVMO-381). Empty/absent for legacy rows. */
447
+ /** Current billing postal code (MOVMO-381). Empty/absent for legacy rows. */
388
448
  zip?: string;
389
449
  }
390
450