@flopay/js 1.4.0 → 1.4.2

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.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _flopay_shared from '@flopay/shared';
2
- import { PaymentProviderAdapter, ElementOptions, ElementType, MountedElement, FloPayError, FloPayConfig, CreatePaymentMethodResult, ConfirmCardPaymentParams, ConfirmCardPaymentResult, CardCaptureAdapter, ConfirmPaymentParams, PaymentResult, CheckoutSession, NormalizedCheckoutSession, BillingDetails, CheckoutGateways, VaultCaptureBlock, ProcessPaymentParams, InlineSessionDraft, CardCaptureProviderId, CardCaptureMountOptions, CardCaptureEventType, CardCaptureOutcomeEvent, VaultCardThemeColors, VaultCardFieldKey, CreateSessionParams, CheckoutSessionResult } from '@flopay/shared';
2
+ import { PaymentProviderAdapter, ElementOptions, ElementType, MountedElement, FloPayError, FloPayConfig, CardCaptureAdapter, PayPalPaymentResult, ConfirmPaymentParams, PaymentResult, CheckoutSession, NormalizedCheckoutSession, CheckoutGateways, VaultCaptureBlock, ProcessPaymentParams, CreateSessionIntentRequest, SessionIntent, SessionIntentDeclineRequest, InlineSessionDraft, CardCaptureProviderId, CardCaptureMountOptions, CardCaptureEventType, CardCaptureOutcomeEvent, VaultCardThemeColors, VaultCardFieldKey, CreateSessionParams, CheckoutSessionResult } from '@flopay/shared';
3
3
 
4
4
  /**
5
5
  * Manages the creation and lifecycle of payment elements.
@@ -43,7 +43,6 @@ declare class FloPay {
43
43
  private readonly config;
44
44
  private readonly telemetryReporter?;
45
45
  private currentElements;
46
- private readonly cardThreeDsStartedAt;
47
46
  private now;
48
47
  constructor(provider: PaymentProviderAdapter, config: FloPayConfig);
49
48
  /**
@@ -57,17 +56,9 @@ declare class FloPay {
57
56
  submitElements(): Promise<{
58
57
  error?: _flopay_shared.FloPayError;
59
58
  }>;
60
- /** Create a payment method from the current elements (tokenize card). */
61
- createPaymentMethod(billingDetails?: _flopay_shared.BillingDetails): Promise<CreatePaymentMethodResult>;
62
- /** Confirm a card payment with a known client secret and payment method ID. */
63
- confirmCardPayment(params: ConfirmCardPaymentParams): Promise<ConfirmCardPaymentResult>;
64
- private trackCardThreeDsAttempt;
65
- private takeCardThreeDsAttempt;
66
- private pruneExpiredCardThreeDsAttempts;
67
59
  /**
68
60
  * Create a {@link CardCaptureAdapter} for collecting card details through the
69
- * backend-rendered hosted vault PCI widget instead of provider-owned (Stripe)
70
- * card fields (TeamFloPay/backend#823).
61
+ * backend-rendered hosted vault PCI widget (TeamFloPay/backend#823).
71
62
  *
72
63
  * The returned adapter injects the server-supplied widget HTML (the session's
73
64
  * {@link CheckoutSession.vault} block, or one fetched via
@@ -87,15 +78,14 @@ declare class FloPay {
87
78
  email: string;
88
79
  returnUrl: string;
89
80
  /**
90
- * Session-bound checkout token. Forwarded as `x-checkout-session-token`
91
- * on the internal `POST /v1/checkouts/payments/intents` call so post-#640
92
- * backends don't reject the round-trip with a 401.
81
+ * Session-bound checkout token forwarded to the session-scoped non-card
82
+ * intent contract as `x-checkout-session-token`.
93
83
  */
94
84
  nonce?: string;
95
- }): Promise<ConfirmCardPaymentResult>;
85
+ }): Promise<PayPalPaymentResult>;
96
86
  /** Resume a PayPal payment after redirect return. Returns null if no PayPal params in URL. */
97
- resumePayPalPayment(): Promise<ConfirmCardPaymentResult | null>;
98
- /** Confirms a payment using the mounted elements. */
87
+ resumePayPalPayment(): Promise<PayPalPaymentResult | null>;
88
+ /** Confirms a non-card wallet/APM payment using the mounted PaymentElement. */
99
89
  confirmPayment(params: ConfirmPaymentParams): Promise<PaymentResult>;
100
90
  /**
101
91
  * Retrieves a checkout session by ID via the billing API.
@@ -142,9 +132,9 @@ declare class FloPay {
142
132
  * import { loadFloPay } from '@flopay/js';
143
133
  *
144
134
  * const flopay = await loadFloPay('pk_test_...');
145
- * const elements = flopay.elements();
146
- * const cardElement = await elements.create('card');
147
- * cardElement.mount('#card-container');
135
+ * const elements = flopay.elements({ paymentMethodTypes: ['cashapp', 'ideal'] });
136
+ * const paymentElement = await elements.create('payment');
137
+ * paymentElement.mount('#payment-container');
148
138
  * ```
149
139
  */
150
140
  declare function loadFloPay(publishableKey: string, options?: Omit<FloPayConfig, 'publishableKey'>): Promise<FloPay>;
@@ -159,26 +149,20 @@ declare class StripeAdapter implements PaymentProviderAdapter {
159
149
  readonly name = "stripe";
160
150
  private stripe;
161
151
  private elements;
162
- private readonly pendingCardThreeDsAttempts;
163
- private cardThreeDsAttemptSequence;
164
152
  private appliedAppearanceKey;
153
+ private appliedPaymentMethodTypesKey;
154
+ private appliedClientSecret;
155
+ private verifiedClientSecret;
156
+ private verifiedPaymentMethodTypesKey;
165
157
  initialize(config: FloPayConfig): Promise<void>;
166
158
  /** Lazily creates the Stripe Elements group for the given options. */
167
159
  private getElements;
160
+ private assertClientSecretPaymentMethods;
168
161
  createElement(type: ElementType, options: ElementOptions): Promise<MountedElement>;
169
162
  getElement(type: ElementType): MountedElement | null;
170
163
  submitElements(): Promise<{
171
164
  error?: FloPayError;
172
165
  }>;
173
- createPaymentMethod(billingDetails?: BillingDetails): Promise<CreatePaymentMethodResult>;
174
- confirmCardPayment(params: ConfirmCardPaymentParams): Promise<ConfirmCardPaymentResult>;
175
- /**
176
- * Bind provider-observed 3DS milestones to the exact confirmation context.
177
- * The sensitive client secret/payment method pair stays only in this private,
178
- * in-memory key; callers and telemetry receive an unrelated opaque id.
179
- */
180
- private withCardThreeDsLifecycle;
181
- private pruneExpiredCardThreeDsAttempts;
182
166
  confirmPayment(params: ConfirmPaymentParams): Promise<PaymentResult>;
183
167
  private extractPaymentMethodId;
184
168
  confirmPayPalPayment(params: {
@@ -187,8 +171,8 @@ declare class StripeAdapter implements PaymentProviderAdapter {
187
171
  email: string;
188
172
  returnUrl: string;
189
173
  nonce?: string;
190
- }): Promise<ConfirmCardPaymentResult>;
191
- resumePayPalPayment(): Promise<ConfirmCardPaymentResult | null>;
174
+ }): Promise<PayPalPaymentResult>;
175
+ resumePayPalPayment(): Promise<PayPalPaymentResult | null>;
192
176
  getRawProvider(): unknown;
193
177
  createPayPalElements(options: ElementOptions): unknown;
194
178
  destroy(): void;
@@ -466,39 +450,15 @@ declare class PaymentAPI {
466
450
  signal?: AbortSignal;
467
451
  timeoutMs?: number;
468
452
  }): Promise<void>;
469
- /**
470
- * Create a PaymentIntent on the backend.
471
- *
472
- * Used by the Stripe flow to create a server-side PaymentIntent
473
- * with the client's payment method attached.
474
- *
475
- * Forwards `options.nonce` as `x-checkout-session-token` when supplied — the
476
- * session-bound checkout token returned by session creation. Post-#640
477
- * backends reject this call with a 401 when the header is missing or does
478
- * not match the session's stored nonce.
479
- *
480
- * `paymentMethodType` is optional for the vault card-capture flow
481
- * (TeamFloPay/backend#823): the frontend starts checkout *without* an upfront
482
- * card payment method, so it may be omitted (or `null`). The hosted vault PCI
483
- * form captures the card afterwards and the backend attaches the resulting
484
- * payment method to the PaymentIntent it returns here. Legacy callers keep
485
- * passing the concrete payment method id / type.
486
- */
487
- createPaymentIntent(sessionId: string, email: string, paymentMethodType?: string | null, options?: {
453
+ /** Create a wallet/APM/PayPal intent through the session-scoped contract. */
454
+ createSessionIntent(sessionId: string, nonce: string, request: CreateSessionIntentRequest, options?: {
488
455
  signal?: AbortSignal;
489
- isPaypal?: string;
490
- nonce?: string;
491
- }): Promise<Response>;
492
- /**
493
- * Create a SetupIntent for saving payment methods.
494
- *
495
- * Forwards `options.nonce` as `x-checkout-session-token` when supplied —
496
- * required by post-#640 backends, ignored by earlier versions.
497
- */
498
- createSetupIntent(sessionId: string, email: string, paymentMethodType: 'card' | 'google_pay' | 'apple_pay' | 'paypal_express_checkout', options?: {
456
+ idempotencyKey?: string;
457
+ }): Promise<SessionIntent>;
458
+ /** Record a provider-neutral non-card decline without sensitive identifiers. */
459
+ reportSessionIntentDecline(sessionId: string, nonce: string, request: SessionIntentDeclineRequest, options?: {
499
460
  signal?: AbortSignal;
500
- nonce?: string;
501
- }): Promise<Response>;
461
+ }): Promise<void>;
502
462
  /**
503
463
  * Fetch user's prior payments by email.
504
464
  * Used to determine if saved card UX should be shown.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _flopay_shared from '@flopay/shared';
2
- import { PaymentProviderAdapter, ElementOptions, ElementType, MountedElement, FloPayError, FloPayConfig, CreatePaymentMethodResult, ConfirmCardPaymentParams, ConfirmCardPaymentResult, CardCaptureAdapter, ConfirmPaymentParams, PaymentResult, CheckoutSession, NormalizedCheckoutSession, BillingDetails, CheckoutGateways, VaultCaptureBlock, ProcessPaymentParams, InlineSessionDraft, CardCaptureProviderId, CardCaptureMountOptions, CardCaptureEventType, CardCaptureOutcomeEvent, VaultCardThemeColors, VaultCardFieldKey, CreateSessionParams, CheckoutSessionResult } from '@flopay/shared';
2
+ import { PaymentProviderAdapter, ElementOptions, ElementType, MountedElement, FloPayError, FloPayConfig, CardCaptureAdapter, PayPalPaymentResult, ConfirmPaymentParams, PaymentResult, CheckoutSession, NormalizedCheckoutSession, CheckoutGateways, VaultCaptureBlock, ProcessPaymentParams, CreateSessionIntentRequest, SessionIntent, SessionIntentDeclineRequest, InlineSessionDraft, CardCaptureProviderId, CardCaptureMountOptions, CardCaptureEventType, CardCaptureOutcomeEvent, VaultCardThemeColors, VaultCardFieldKey, CreateSessionParams, CheckoutSessionResult } from '@flopay/shared';
3
3
 
4
4
  /**
5
5
  * Manages the creation and lifecycle of payment elements.
@@ -43,7 +43,6 @@ declare class FloPay {
43
43
  private readonly config;
44
44
  private readonly telemetryReporter?;
45
45
  private currentElements;
46
- private readonly cardThreeDsStartedAt;
47
46
  private now;
48
47
  constructor(provider: PaymentProviderAdapter, config: FloPayConfig);
49
48
  /**
@@ -57,17 +56,9 @@ declare class FloPay {
57
56
  submitElements(): Promise<{
58
57
  error?: _flopay_shared.FloPayError;
59
58
  }>;
60
- /** Create a payment method from the current elements (tokenize card). */
61
- createPaymentMethod(billingDetails?: _flopay_shared.BillingDetails): Promise<CreatePaymentMethodResult>;
62
- /** Confirm a card payment with a known client secret and payment method ID. */
63
- confirmCardPayment(params: ConfirmCardPaymentParams): Promise<ConfirmCardPaymentResult>;
64
- private trackCardThreeDsAttempt;
65
- private takeCardThreeDsAttempt;
66
- private pruneExpiredCardThreeDsAttempts;
67
59
  /**
68
60
  * Create a {@link CardCaptureAdapter} for collecting card details through the
69
- * backend-rendered hosted vault PCI widget instead of provider-owned (Stripe)
70
- * card fields (TeamFloPay/backend#823).
61
+ * backend-rendered hosted vault PCI widget (TeamFloPay/backend#823).
71
62
  *
72
63
  * The returned adapter injects the server-supplied widget HTML (the session's
73
64
  * {@link CheckoutSession.vault} block, or one fetched via
@@ -87,15 +78,14 @@ declare class FloPay {
87
78
  email: string;
88
79
  returnUrl: string;
89
80
  /**
90
- * Session-bound checkout token. Forwarded as `x-checkout-session-token`
91
- * on the internal `POST /v1/checkouts/payments/intents` call so post-#640
92
- * backends don't reject the round-trip with a 401.
81
+ * Session-bound checkout token forwarded to the session-scoped non-card
82
+ * intent contract as `x-checkout-session-token`.
93
83
  */
94
84
  nonce?: string;
95
- }): Promise<ConfirmCardPaymentResult>;
85
+ }): Promise<PayPalPaymentResult>;
96
86
  /** Resume a PayPal payment after redirect return. Returns null if no PayPal params in URL. */
97
- resumePayPalPayment(): Promise<ConfirmCardPaymentResult | null>;
98
- /** Confirms a payment using the mounted elements. */
87
+ resumePayPalPayment(): Promise<PayPalPaymentResult | null>;
88
+ /** Confirms a non-card wallet/APM payment using the mounted PaymentElement. */
99
89
  confirmPayment(params: ConfirmPaymentParams): Promise<PaymentResult>;
100
90
  /**
101
91
  * Retrieves a checkout session by ID via the billing API.
@@ -142,9 +132,9 @@ declare class FloPay {
142
132
  * import { loadFloPay } from '@flopay/js';
143
133
  *
144
134
  * const flopay = await loadFloPay('pk_test_...');
145
- * const elements = flopay.elements();
146
- * const cardElement = await elements.create('card');
147
- * cardElement.mount('#card-container');
135
+ * const elements = flopay.elements({ paymentMethodTypes: ['cashapp', 'ideal'] });
136
+ * const paymentElement = await elements.create('payment');
137
+ * paymentElement.mount('#payment-container');
148
138
  * ```
149
139
  */
150
140
  declare function loadFloPay(publishableKey: string, options?: Omit<FloPayConfig, 'publishableKey'>): Promise<FloPay>;
@@ -159,26 +149,20 @@ declare class StripeAdapter implements PaymentProviderAdapter {
159
149
  readonly name = "stripe";
160
150
  private stripe;
161
151
  private elements;
162
- private readonly pendingCardThreeDsAttempts;
163
- private cardThreeDsAttemptSequence;
164
152
  private appliedAppearanceKey;
153
+ private appliedPaymentMethodTypesKey;
154
+ private appliedClientSecret;
155
+ private verifiedClientSecret;
156
+ private verifiedPaymentMethodTypesKey;
165
157
  initialize(config: FloPayConfig): Promise<void>;
166
158
  /** Lazily creates the Stripe Elements group for the given options. */
167
159
  private getElements;
160
+ private assertClientSecretPaymentMethods;
168
161
  createElement(type: ElementType, options: ElementOptions): Promise<MountedElement>;
169
162
  getElement(type: ElementType): MountedElement | null;
170
163
  submitElements(): Promise<{
171
164
  error?: FloPayError;
172
165
  }>;
173
- createPaymentMethod(billingDetails?: BillingDetails): Promise<CreatePaymentMethodResult>;
174
- confirmCardPayment(params: ConfirmCardPaymentParams): Promise<ConfirmCardPaymentResult>;
175
- /**
176
- * Bind provider-observed 3DS milestones to the exact confirmation context.
177
- * The sensitive client secret/payment method pair stays only in this private,
178
- * in-memory key; callers and telemetry receive an unrelated opaque id.
179
- */
180
- private withCardThreeDsLifecycle;
181
- private pruneExpiredCardThreeDsAttempts;
182
166
  confirmPayment(params: ConfirmPaymentParams): Promise<PaymentResult>;
183
167
  private extractPaymentMethodId;
184
168
  confirmPayPalPayment(params: {
@@ -187,8 +171,8 @@ declare class StripeAdapter implements PaymentProviderAdapter {
187
171
  email: string;
188
172
  returnUrl: string;
189
173
  nonce?: string;
190
- }): Promise<ConfirmCardPaymentResult>;
191
- resumePayPalPayment(): Promise<ConfirmCardPaymentResult | null>;
174
+ }): Promise<PayPalPaymentResult>;
175
+ resumePayPalPayment(): Promise<PayPalPaymentResult | null>;
192
176
  getRawProvider(): unknown;
193
177
  createPayPalElements(options: ElementOptions): unknown;
194
178
  destroy(): void;
@@ -466,39 +450,15 @@ declare class PaymentAPI {
466
450
  signal?: AbortSignal;
467
451
  timeoutMs?: number;
468
452
  }): Promise<void>;
469
- /**
470
- * Create a PaymentIntent on the backend.
471
- *
472
- * Used by the Stripe flow to create a server-side PaymentIntent
473
- * with the client's payment method attached.
474
- *
475
- * Forwards `options.nonce` as `x-checkout-session-token` when supplied — the
476
- * session-bound checkout token returned by session creation. Post-#640
477
- * backends reject this call with a 401 when the header is missing or does
478
- * not match the session's stored nonce.
479
- *
480
- * `paymentMethodType` is optional for the vault card-capture flow
481
- * (TeamFloPay/backend#823): the frontend starts checkout *without* an upfront
482
- * card payment method, so it may be omitted (or `null`). The hosted vault PCI
483
- * form captures the card afterwards and the backend attaches the resulting
484
- * payment method to the PaymentIntent it returns here. Legacy callers keep
485
- * passing the concrete payment method id / type.
486
- */
487
- createPaymentIntent(sessionId: string, email: string, paymentMethodType?: string | null, options?: {
453
+ /** Create a wallet/APM/PayPal intent through the session-scoped contract. */
454
+ createSessionIntent(sessionId: string, nonce: string, request: CreateSessionIntentRequest, options?: {
488
455
  signal?: AbortSignal;
489
- isPaypal?: string;
490
- nonce?: string;
491
- }): Promise<Response>;
492
- /**
493
- * Create a SetupIntent for saving payment methods.
494
- *
495
- * Forwards `options.nonce` as `x-checkout-session-token` when supplied —
496
- * required by post-#640 backends, ignored by earlier versions.
497
- */
498
- createSetupIntent(sessionId: string, email: string, paymentMethodType: 'card' | 'google_pay' | 'apple_pay' | 'paypal_express_checkout', options?: {
456
+ idempotencyKey?: string;
457
+ }): Promise<SessionIntent>;
458
+ /** Record a provider-neutral non-card decline without sensitive identifiers. */
459
+ reportSessionIntentDecline(sessionId: string, nonce: string, request: SessionIntentDeclineRequest, options?: {
499
460
  signal?: AbortSignal;
500
- nonce?: string;
501
- }): Promise<Response>;
461
+ }): Promise<void>;
502
462
  /**
503
463
  * Fetch user's prior payments by email.
504
464
  * Used to determine if saved card UX should be shown.