@authvia/payment-method-create 1.0.4 → 1.0.6

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.
@@ -1,4 +1,5 @@
1
1
  import { PaymentMethodFormData } from '../../types';
2
+ import { PaymentMethodSuccessPayload } from '../../utils/paymentMethodSuccessPayload';
2
3
  export type FormErrorPhase = 'init' | 'submit';
3
4
  export type EmittedFormError = {
4
5
  phase: FormErrorPhase;
@@ -9,19 +10,15 @@ export type EmittedFormError = {
9
10
  */
10
11
  export type AuthviaPaymentMethodFormEmit = {
11
12
  (event: 'submit', data: PaymentMethodFormData): void;
12
- (event: 'success', data: unknown): void;
13
+ (event: 'success', data: PaymentMethodSuccessPayload): void;
13
14
  (event: 'error', err: EmittedFormError | Record<string, unknown>): void;
14
15
  (event: 'ready'): void;
15
16
  };
16
- /** Normalized object emitted on `success` when the child passes a string id or structured payload. */
17
- export type EmittedFormPaymentMethodSuccess = {
18
- paymentMethodId: string;
19
- type?: string;
20
- use?: boolean;
21
- };
22
17
  /** What {@link usePaymentMethodFormHandlers.handlePaymentMethodSuccess} accepts from Options. */
23
- export type FormPaymentMethodSuccessEventPayload = string | {
24
- type: string;
25
- paymentMethodId: string;
26
- use: boolean;
27
- };
18
+ export type FormPaymentMethodSuccessEventPayload = string | PaymentMethodSuccessPayload | (Partial<PaymentMethodSuccessPayload> & {
19
+ paymentMethodId?: string;
20
+ use?: boolean;
21
+ data?: Partial<PaymentMethodSuccessPayload> & {
22
+ id?: string;
23
+ };
24
+ });
@@ -1,13 +1,25 @@
1
+ import { PaymentMethodSuccessPayload } from '../../utils/paymentMethodSuccessPayload';
1
2
  export type MethodSuccessPayload = {
2
3
  id?: string;
4
+ type?: string;
5
+ permission?: 'use' | 'single-use';
6
+ brand?: string;
7
+ subType?: string;
8
+ identity?: string;
3
9
  use?: boolean;
4
10
  forgetCard?: boolean;
5
11
  data?: {
6
12
  id?: string;
13
+ type?: string;
14
+ permission?: 'use' | 'single-use';
15
+ brand?: string;
16
+ subType?: string;
17
+ identity?: string;
7
18
  };
8
19
  };
9
- export type PazeSuccessPayload = string | {
20
+ export type PazeSuccessPayload = string | PaymentMethodSuccessPayload | {
10
21
  id: string;
22
+ permission?: 'use' | 'single-use';
11
23
  forgetCard?: boolean;
12
24
  } | null;
13
25
  export type PaymentMethodOptionsEmit = (event: 'on-success' | 'on-error' | 'on-submit' | 'update:forgetCard', payload?: unknown) => void;
@@ -76,7 +76,6 @@ declare class AuthviaPaymentMethodFormElement extends HTMLElement {
76
76
  private removeDependencyObserver;
77
77
  private isVersionSatisfied;
78
78
  private compareSemver;
79
- private forwardComponentEvents;
80
79
  }
81
80
  export declare function createEmbeddedPaymentMethodForm(config: {
82
81
  container: HTMLElement;
@@ -0,0 +1,44 @@
1
+ import { PaymentMethod } from '../model';
2
+ export type PaymentMethodPermission = 'use' | 'single-use';
3
+ /** Public `success` event shape (non-PII fields from create API + `permission` from forget-card checkbox). */
4
+ export type PaymentMethodSuccessPayload = {
5
+ id: string;
6
+ brand?: string;
7
+ type: string;
8
+ subType?: string;
9
+ identity?: string;
10
+ permission: PaymentMethodPermission;
11
+ };
12
+ export type MethodSuccessSource = Omit<Partial<PaymentMethod>, 'type'> & {
13
+ id?: string;
14
+ type?: string;
15
+ brand?: string;
16
+ subType?: string;
17
+ subtype?: string;
18
+ permission?: PaymentMethodPermission;
19
+ forgetCard?: boolean;
20
+ /** Legacy boolean input; mapped to `permission`. */
21
+ use?: boolean;
22
+ data?: Omit<Partial<PaymentMethod>, 'type'> & {
23
+ id?: string;
24
+ type?: string;
25
+ brand?: string;
26
+ subType?: string;
27
+ subtype?: string;
28
+ permission?: PaymentMethodPermission;
29
+ };
30
+ };
31
+ /** Drops empty optional fields from a host-facing success payload. */
32
+ export declare function sanitizePaymentMethodSuccessPayload(payload: PaymentMethodSuccessPayload): PaymentMethodSuccessPayload;
33
+ /**
34
+ * Maps credit-card widget success to the host `success` payload.
35
+ */
36
+ export declare function normalizeCreditCardSuccessPayload(source: MethodSuccessSource | PaymentMethodSuccessPayload | null | undefined): PaymentMethodSuccessPayload;
37
+ /**
38
+ * Maps a payment-methods create API record (or partial child emit) to the host `success` payload.
39
+ */
40
+ export declare function buildPaymentMethodSuccessPayload(source: MethodSuccessSource | PaymentMethodSuccessPayload | string | null | undefined, options: {
41
+ type: string;
42
+ permission?: PaymentMethodPermission;
43
+ permissionFallback?: PaymentMethodPermission;
44
+ }): PaymentMethodSuccessPayload;