@flopay/js 1.0.3 → 1.1.3

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, ConfirmPaymentParams, PaymentResult, CheckoutSession, NormalizedCheckoutSession, BillingDetails, BillingProvider, ProcessPaymentParams, InlineSessionDraft, CreateSessionParams, CheckoutSessionResult } from '@flopay/shared';
2
+ import { PaymentProviderAdapter, ElementOptions, ElementType, MountedElement, FloPayError, FloPayConfig, CreatePaymentMethodResult, ConfirmCardPaymentParams, ConfirmCardPaymentResult, ConfirmPaymentParams, PaymentResult, CheckoutSession, NormalizedCheckoutSession, BillingDetails, CheckoutGateways, ProcessPaymentParams, InlineSessionDraft, CreateSessionParams, CheckoutSessionResult } from '@flopay/shared';
3
3
 
4
4
  /**
5
5
  * Manages the creation and lifecycle of payment elements.
@@ -106,8 +106,7 @@ declare class FloPay {
106
106
  *
107
107
  * Instances are cached per `publishableKey`, so calling `loadFloPay` twice
108
108
  * with the same key returns the same instance. Different keys produce
109
- * independent instances that can run side-by-side (used for the dedicated
110
- * PayPal Stripe account).
109
+ * independent instances that can run side-by-side.
111
110
  *
112
111
  * @example
113
112
  * ```ts
@@ -168,30 +167,14 @@ declare class StripeAdapter implements PaymentProviderAdapter {
168
167
  * Values from the server response always win — cached values fill in only
169
168
  * where the server returned `null` or `undefined`.
170
169
  */
171
- /** Display-only fields per item that can be cached and merged back later. */
172
- interface SessionDisplayItem {
173
- /** Catalog code (preferred match key). */
170
+ /** Display-only fields per product that can be cached and merged back later. */
171
+ interface SessionDisplayProduct {
172
+ /** Catalog code (match key). */
174
173
  code?: string;
175
- /** @deprecated Match key fallback when `code` is not provided. */
176
- providerItemId?: string;
177
- /** Display-only name for the item. Takes priority over `providerItemName`. */
178
- itemName?: string | null;
179
- /** @deprecated Use `itemName`. */
180
- providerItemName?: string | null;
181
- totalAmount?: number;
182
- overrideAmount?: number | null;
183
- currency?: string;
184
- }
185
- /** Display-only fields per subscription that can be cached and merged back later. */
186
- interface SessionDisplaySubscription {
187
- /** Catalog code (preferred match key). */
188
- code?: string;
189
- /** @deprecated Match key fallback when `code` is not provided. */
190
- providerPlanId?: string;
191
- /** Display-only name for the subscription plan. Takes priority over `providerPlanName`. */
192
- subscriptionName?: string | null;
193
- /** @deprecated Use `subscriptionName`. */
194
- providerPlanName?: string | null;
174
+ /** Whether this product is a one-time item or a recurring subscription. */
175
+ type?: 'item' | 'subscription';
176
+ /** Display-only name for the product. */
177
+ name?: string | null;
195
178
  totalAmount?: number;
196
179
  overrideAmount?: number | null;
197
180
  currency?: string;
@@ -200,8 +183,7 @@ interface SessionDisplaySubscription {
200
183
  interface SessionDisplayCacheData {
201
184
  /** Session-level currency (falls into the response only when the server omits it). */
202
185
  currency?: string;
203
- items?: SessionDisplayItem[];
204
- subscriptions?: SessionDisplaySubscription[];
186
+ products?: SessionDisplayProduct[];
205
187
  }
206
188
  /**
207
189
  * Stash display-only data for a session. Called client-side right after the
@@ -226,71 +208,44 @@ declare function clearSessionDisplayData(sessionId: string): void;
226
208
  interface BillingResponse<T> {
227
209
  data: T;
228
210
  }
229
- /** Raw checkout session from the billing API (includes gateway field). */
211
+ /** Raw checkout session from the billing API. */
230
212
  interface RawCheckoutSession {
231
213
  uuid: string;
232
214
  nonce: string;
233
- gateway?: BillingProvider;
234
215
  status: 'pending' | 'completed' | 'expired';
235
216
  successUrl: string;
236
217
  cancelUrl: string;
237
- /** Session-level currency. Takes precedence over per-item/per-subscription currency. */
218
+ /** Session-level currency. */
238
219
  currency?: string;
239
220
  createdAt?: string;
240
221
  checkoutUrl?: string;
241
- items: Array<{
242
- uuid: string;
243
- checkoutSessionId: string;
244
- /** Preferred catalog code. Falls back to the deprecated `providerItemId`. */
245
- code?: string;
246
- /** @deprecated Use `code`. */
247
- providerItemId?: string;
248
- /** Display-only name. Preferred over `providerItemName`. */
249
- itemName?: string | null;
250
- /** @deprecated Use `itemName`. Mirrored for backward compatibility. */
251
- providerItemName?: string | null;
252
- /** Display-only description from the catalog. */
253
- providerItemDescription?: string | null;
254
- quantity: number;
255
- /** @deprecated Removed from the backend — resolved from the catalog. */
256
- totalAmount?: number;
257
- /** @deprecated Removed from the backend entirely. */
258
- overrideAmount?: number | null;
259
- /** @deprecated Use the session-level `currency`. */
260
- currency?: string;
261
- metadata?: Record<string, unknown> | null;
262
- }>;
263
- subscriptions: Array<{
222
+ /** Unified products list returned by the billing API (post-#760). */
223
+ products?: Array<{
264
224
  uuid: string;
265
225
  checkoutSessionId: string;
266
- /** Preferred catalog code. Falls back to the deprecated `providerPlanId`. */
226
+ /** 'item' or 'subscription'. */
227
+ type: 'item' | 'subscription';
267
228
  code?: string;
268
- /** @deprecated Use `code`. */
269
- providerPlanId?: string;
270
- /** Display-only name. Preferred over `providerPlanName`. */
271
- subscriptionName?: string | null;
272
- /** @deprecated Use `subscriptionName`. Mirrored for backward compatibility. */
273
- providerPlanName?: string | null;
274
- /** Display-only description from the catalog. */
275
- providerPlanDescription?: string | null;
229
+ name?: string | null;
230
+ description?: string | null;
276
231
  quantity: number;
277
- /** @deprecated Removed from the backend — resolved from the catalog. */
278
232
  totalAmount?: number;
279
- /** @deprecated Removed from the backend entirely. */
280
233
  overrideAmount?: number | null;
281
- /** @deprecated Use the session-level `currency`. */
282
234
  currency?: string;
283
- /** @deprecated Removed from the backend. Checkouts only create new subscriptions. */
284
- isUpdate?: boolean;
285
235
  metadata?: Record<string, unknown> | null;
286
236
  }>;
287
237
  coupons?: string[];
238
+ /**
239
+ * Pre-discount total in cart-currency major units. Populated by billing
240
+ * API ≥ v1.1.2; absent on older backends.
241
+ */
242
+ subtotalAmount?: number;
243
+ /** Total reduction from applied coupons (cart-currency major units). */
244
+ discountAmount?: number;
245
+ /** Final charge amount after coupon discount (cart-currency major units). */
246
+ totalAmount?: number;
288
247
  checkoutMode?: 'full' | 'auto' | 'confirm';
289
- gatewayData: {
290
- publishableKey?: string | null;
291
- stripeClientSecret?: string | null;
292
- paypalPublishableKey?: string | null;
293
- };
248
+ gateways?: CheckoutGateways;
294
249
  accountData: {
295
250
  userId: string;
296
251
  firstName: string;
@@ -352,9 +307,9 @@ declare class PaymentAPI {
352
307
  /**
353
308
  * Fetch and normalize a checkout session.
354
309
  *
355
- * Reads the backend's `gateway` field to determine the provider,
356
- * then wraps the session in a `NormalizedCheckoutSession` for
357
- * provider-agnostic consumption.
310
+ * Reads the backend's `gateways` map to enumerate provider-specific data,
311
+ * then wraps the session in a `NormalizedCheckoutSession` for provider-
312
+ * agnostic consumption.
358
313
  */
359
314
  getUnifiedCheckoutSession(checkoutSessionId: string): Promise<NormalizedCheckoutSession>;
360
315
  /**
@@ -362,8 +317,13 @@ declare class PaymentAPI {
362
317
  *
363
318
  * The backend will either succeed, return `type: '3ds_required'`
364
319
  * (with a `threeDSecureToken`), or return `type: 'paypal_redirect_required'`.
320
+ *
321
+ * @param userId Vestigial — backend's GatewayInterceptor routes via session,
322
+ * not headers, so this value is no longer sent on the wire. Kept in the
323
+ * signature for back-compat with existing callers; will be removed in a
324
+ * future major version.
365
325
  */
366
- processPayment(userId: string, data: ProcessPaymentParams, options?: {
326
+ processPayment(_userId: string, data: ProcessPaymentParams, options?: {
367
327
  pollTimeoutMs?: number;
368
328
  }): Promise<Response>;
369
329
  /**
@@ -422,18 +382,15 @@ declare class PaymentAPI {
422
382
  * Stash the display-only fields the consumer passed into a create-session
423
383
  * call. Runs after the backend assigns a UUID so a later GET on the same
424
384
  * session (typically after a redirect) can fill in fields the backend no
425
- * longer persists — `overrideAmount`, `totalAmount`, `itemName`, etc.
385
+ * longer persists — `overrideAmount`, `totalAmount`, `name`, etc.
426
386
  *
427
387
  * No-op when no UUID is available.
428
388
  */
429
389
  private autoCacheDisplayData;
430
390
  /**
431
391
  * Merge cached display-only fields (set by {@link cacheSessionDisplayData})
432
- * into a raw session response and mirror the new/legacy name aliases so
433
- * readers using either field always get a value when one exists.
434
- *
435
- * Server values always win — cache fills in only where the server returned
436
- * `null` / `undefined`.
392
+ * into a raw session response. Server values always win cache fills in
393
+ * only where the server returned `null` / `undefined`.
437
394
  */
438
395
  private mergeCachedDisplayData;
439
396
  }
@@ -479,4 +436,4 @@ declare function createCheckoutSessionWithRetries(options: CreateSessionParams &
479
436
  maxRetries?: number;
480
437
  }): Promise<CheckoutSessionResult>;
481
438
 
482
- export { FloPay, FloPayElements, PaymentAPI, type SessionDisplayCacheData, type SessionDisplayItem, type SessionDisplaySubscription, StripeAdapter, cacheSessionDisplayData, clearSessionDisplayData, createCheckoutSession, createCheckoutSessionWithRetries, getSessionDisplayData, loadFloPay };
439
+ export { FloPay, FloPayElements, PaymentAPI, type SessionDisplayCacheData, type SessionDisplayProduct, StripeAdapter, cacheSessionDisplayData, clearSessionDisplayData, createCheckoutSession, createCheckoutSessionWithRetries, getSessionDisplayData, loadFloPay };
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, ConfirmPaymentParams, PaymentResult, CheckoutSession, NormalizedCheckoutSession, BillingDetails, BillingProvider, ProcessPaymentParams, InlineSessionDraft, CreateSessionParams, CheckoutSessionResult } from '@flopay/shared';
2
+ import { PaymentProviderAdapter, ElementOptions, ElementType, MountedElement, FloPayError, FloPayConfig, CreatePaymentMethodResult, ConfirmCardPaymentParams, ConfirmCardPaymentResult, ConfirmPaymentParams, PaymentResult, CheckoutSession, NormalizedCheckoutSession, BillingDetails, CheckoutGateways, ProcessPaymentParams, InlineSessionDraft, CreateSessionParams, CheckoutSessionResult } from '@flopay/shared';
3
3
 
4
4
  /**
5
5
  * Manages the creation and lifecycle of payment elements.
@@ -106,8 +106,7 @@ declare class FloPay {
106
106
  *
107
107
  * Instances are cached per `publishableKey`, so calling `loadFloPay` twice
108
108
  * with the same key returns the same instance. Different keys produce
109
- * independent instances that can run side-by-side (used for the dedicated
110
- * PayPal Stripe account).
109
+ * independent instances that can run side-by-side.
111
110
  *
112
111
  * @example
113
112
  * ```ts
@@ -168,30 +167,14 @@ declare class StripeAdapter implements PaymentProviderAdapter {
168
167
  * Values from the server response always win — cached values fill in only
169
168
  * where the server returned `null` or `undefined`.
170
169
  */
171
- /** Display-only fields per item that can be cached and merged back later. */
172
- interface SessionDisplayItem {
173
- /** Catalog code (preferred match key). */
170
+ /** Display-only fields per product that can be cached and merged back later. */
171
+ interface SessionDisplayProduct {
172
+ /** Catalog code (match key). */
174
173
  code?: string;
175
- /** @deprecated Match key fallback when `code` is not provided. */
176
- providerItemId?: string;
177
- /** Display-only name for the item. Takes priority over `providerItemName`. */
178
- itemName?: string | null;
179
- /** @deprecated Use `itemName`. */
180
- providerItemName?: string | null;
181
- totalAmount?: number;
182
- overrideAmount?: number | null;
183
- currency?: string;
184
- }
185
- /** Display-only fields per subscription that can be cached and merged back later. */
186
- interface SessionDisplaySubscription {
187
- /** Catalog code (preferred match key). */
188
- code?: string;
189
- /** @deprecated Match key fallback when `code` is not provided. */
190
- providerPlanId?: string;
191
- /** Display-only name for the subscription plan. Takes priority over `providerPlanName`. */
192
- subscriptionName?: string | null;
193
- /** @deprecated Use `subscriptionName`. */
194
- providerPlanName?: string | null;
174
+ /** Whether this product is a one-time item or a recurring subscription. */
175
+ type?: 'item' | 'subscription';
176
+ /** Display-only name for the product. */
177
+ name?: string | null;
195
178
  totalAmount?: number;
196
179
  overrideAmount?: number | null;
197
180
  currency?: string;
@@ -200,8 +183,7 @@ interface SessionDisplaySubscription {
200
183
  interface SessionDisplayCacheData {
201
184
  /** Session-level currency (falls into the response only when the server omits it). */
202
185
  currency?: string;
203
- items?: SessionDisplayItem[];
204
- subscriptions?: SessionDisplaySubscription[];
186
+ products?: SessionDisplayProduct[];
205
187
  }
206
188
  /**
207
189
  * Stash display-only data for a session. Called client-side right after the
@@ -226,71 +208,44 @@ declare function clearSessionDisplayData(sessionId: string): void;
226
208
  interface BillingResponse<T> {
227
209
  data: T;
228
210
  }
229
- /** Raw checkout session from the billing API (includes gateway field). */
211
+ /** Raw checkout session from the billing API. */
230
212
  interface RawCheckoutSession {
231
213
  uuid: string;
232
214
  nonce: string;
233
- gateway?: BillingProvider;
234
215
  status: 'pending' | 'completed' | 'expired';
235
216
  successUrl: string;
236
217
  cancelUrl: string;
237
- /** Session-level currency. Takes precedence over per-item/per-subscription currency. */
218
+ /** Session-level currency. */
238
219
  currency?: string;
239
220
  createdAt?: string;
240
221
  checkoutUrl?: string;
241
- items: Array<{
242
- uuid: string;
243
- checkoutSessionId: string;
244
- /** Preferred catalog code. Falls back to the deprecated `providerItemId`. */
245
- code?: string;
246
- /** @deprecated Use `code`. */
247
- providerItemId?: string;
248
- /** Display-only name. Preferred over `providerItemName`. */
249
- itemName?: string | null;
250
- /** @deprecated Use `itemName`. Mirrored for backward compatibility. */
251
- providerItemName?: string | null;
252
- /** Display-only description from the catalog. */
253
- providerItemDescription?: string | null;
254
- quantity: number;
255
- /** @deprecated Removed from the backend — resolved from the catalog. */
256
- totalAmount?: number;
257
- /** @deprecated Removed from the backend entirely. */
258
- overrideAmount?: number | null;
259
- /** @deprecated Use the session-level `currency`. */
260
- currency?: string;
261
- metadata?: Record<string, unknown> | null;
262
- }>;
263
- subscriptions: Array<{
222
+ /** Unified products list returned by the billing API (post-#760). */
223
+ products?: Array<{
264
224
  uuid: string;
265
225
  checkoutSessionId: string;
266
- /** Preferred catalog code. Falls back to the deprecated `providerPlanId`. */
226
+ /** 'item' or 'subscription'. */
227
+ type: 'item' | 'subscription';
267
228
  code?: string;
268
- /** @deprecated Use `code`. */
269
- providerPlanId?: string;
270
- /** Display-only name. Preferred over `providerPlanName`. */
271
- subscriptionName?: string | null;
272
- /** @deprecated Use `subscriptionName`. Mirrored for backward compatibility. */
273
- providerPlanName?: string | null;
274
- /** Display-only description from the catalog. */
275
- providerPlanDescription?: string | null;
229
+ name?: string | null;
230
+ description?: string | null;
276
231
  quantity: number;
277
- /** @deprecated Removed from the backend — resolved from the catalog. */
278
232
  totalAmount?: number;
279
- /** @deprecated Removed from the backend entirely. */
280
233
  overrideAmount?: number | null;
281
- /** @deprecated Use the session-level `currency`. */
282
234
  currency?: string;
283
- /** @deprecated Removed from the backend. Checkouts only create new subscriptions. */
284
- isUpdate?: boolean;
285
235
  metadata?: Record<string, unknown> | null;
286
236
  }>;
287
237
  coupons?: string[];
238
+ /**
239
+ * Pre-discount total in cart-currency major units. Populated by billing
240
+ * API ≥ v1.1.2; absent on older backends.
241
+ */
242
+ subtotalAmount?: number;
243
+ /** Total reduction from applied coupons (cart-currency major units). */
244
+ discountAmount?: number;
245
+ /** Final charge amount after coupon discount (cart-currency major units). */
246
+ totalAmount?: number;
288
247
  checkoutMode?: 'full' | 'auto' | 'confirm';
289
- gatewayData: {
290
- publishableKey?: string | null;
291
- stripeClientSecret?: string | null;
292
- paypalPublishableKey?: string | null;
293
- };
248
+ gateways?: CheckoutGateways;
294
249
  accountData: {
295
250
  userId: string;
296
251
  firstName: string;
@@ -352,9 +307,9 @@ declare class PaymentAPI {
352
307
  /**
353
308
  * Fetch and normalize a checkout session.
354
309
  *
355
- * Reads the backend's `gateway` field to determine the provider,
356
- * then wraps the session in a `NormalizedCheckoutSession` for
357
- * provider-agnostic consumption.
310
+ * Reads the backend's `gateways` map to enumerate provider-specific data,
311
+ * then wraps the session in a `NormalizedCheckoutSession` for provider-
312
+ * agnostic consumption.
358
313
  */
359
314
  getUnifiedCheckoutSession(checkoutSessionId: string): Promise<NormalizedCheckoutSession>;
360
315
  /**
@@ -362,8 +317,13 @@ declare class PaymentAPI {
362
317
  *
363
318
  * The backend will either succeed, return `type: '3ds_required'`
364
319
  * (with a `threeDSecureToken`), or return `type: 'paypal_redirect_required'`.
320
+ *
321
+ * @param userId Vestigial — backend's GatewayInterceptor routes via session,
322
+ * not headers, so this value is no longer sent on the wire. Kept in the
323
+ * signature for back-compat with existing callers; will be removed in a
324
+ * future major version.
365
325
  */
366
- processPayment(userId: string, data: ProcessPaymentParams, options?: {
326
+ processPayment(_userId: string, data: ProcessPaymentParams, options?: {
367
327
  pollTimeoutMs?: number;
368
328
  }): Promise<Response>;
369
329
  /**
@@ -422,18 +382,15 @@ declare class PaymentAPI {
422
382
  * Stash the display-only fields the consumer passed into a create-session
423
383
  * call. Runs after the backend assigns a UUID so a later GET on the same
424
384
  * session (typically after a redirect) can fill in fields the backend no
425
- * longer persists — `overrideAmount`, `totalAmount`, `itemName`, etc.
385
+ * longer persists — `overrideAmount`, `totalAmount`, `name`, etc.
426
386
  *
427
387
  * No-op when no UUID is available.
428
388
  */
429
389
  private autoCacheDisplayData;
430
390
  /**
431
391
  * Merge cached display-only fields (set by {@link cacheSessionDisplayData})
432
- * into a raw session response and mirror the new/legacy name aliases so
433
- * readers using either field always get a value when one exists.
434
- *
435
- * Server values always win — cache fills in only where the server returned
436
- * `null` / `undefined`.
392
+ * into a raw session response. Server values always win cache fills in
393
+ * only where the server returned `null` / `undefined`.
437
394
  */
438
395
  private mergeCachedDisplayData;
439
396
  }
@@ -479,4 +436,4 @@ declare function createCheckoutSessionWithRetries(options: CreateSessionParams &
479
436
  maxRetries?: number;
480
437
  }): Promise<CheckoutSessionResult>;
481
438
 
482
- export { FloPay, FloPayElements, PaymentAPI, type SessionDisplayCacheData, type SessionDisplayItem, type SessionDisplaySubscription, StripeAdapter, cacheSessionDisplayData, clearSessionDisplayData, createCheckoutSession, createCheckoutSessionWithRetries, getSessionDisplayData, loadFloPay };
439
+ export { FloPay, FloPayElements, PaymentAPI, type SessionDisplayCacheData, type SessionDisplayProduct, StripeAdapter, cacheSessionDisplayData, clearSessionDisplayData, createCheckoutSession, createCheckoutSessionWithRetries, getSessionDisplayData, loadFloPay };