@flopay/shared 1.4.1 → 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/README.md +10 -9
- package/dist/index.cjs +31 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +115 -69
- package/dist/index.d.ts +115 -69
- package/dist/index.mjs +28 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ throw validationError('Email is required', 'email');
|
|
|
86
86
|
| `ThemeBundleId` | Bundle id: `'modern-light'` / `'modern-dark'` / `'bold-light'` / `'bold-dark'` / `'glass-light'` / `'glass-dark'` |
|
|
87
87
|
| `ThemeId` | Accepted by the React components' `theme` prop: `'classic'` ∪ `ThemeBundleId` |
|
|
88
88
|
| `CheckoutMode` | Checkout mode: `'full'` / `'auto'` / `'confirm'` |
|
|
89
|
-
| `CheckoutSession` | Session object: `id`, `clientSecret`, `mode`, `status`, `amount`, `currency`, `customer?`, `checkoutMode?`, `products?` (unified `CheckoutSessionProduct[]`), `successUrl?`, `cancelUrl?`, `coupons?`, `subtotalAmount?` / `discountAmount?` / `totalAmount?` (cart-currency major units; populated by billing API ≥ v1.1.2), `gateways?` (map keyed by gateway code — `stripe`, `paypal`, …), `accountData?`, `tagsData?` |
|
|
89
|
+
| `CheckoutSession` | Session object: `id`, `clientSecret`, `mode`, `status`, `amount`, `currency`, `customer?`, `checkoutMode?`, `vault?` (hosted card widget), `products?` (unified `CheckoutSessionProduct[]`), `successUrl?`, `cancelUrl?`, `coupons?`, `subtotalAmount?` / `discountAmount?` / `totalAmount?` (cart-currency major units; populated by billing API ≥ v1.1.2), `gateways?` (map keyed by gateway code — `stripe`, `paypal`, …), `accountData?`, `tagsData?` |
|
|
90
90
|
| `CheckoutSessionProduct` | Unified product from session response: `uuid`, `checkoutSessionId`, `type` (`'item'`/`'subscription'`), `code?`, `name?`, `description?`, `quantity`, `totalAmount?`, `overrideAmount?`, `currency?`, `metadata?` |
|
|
91
91
|
| `CheckoutProductType` | `'item'` / `'subscription'` |
|
|
92
92
|
| `CheckoutProduct` | Unified product input for session creation: `type`, `code?`, `name?`, `quantity?`, `totalAmount?`, `overrideAmount?`, `currency?`, `metadata?` |
|
|
@@ -94,14 +94,15 @@ throw validationError('Email is required', 'email');
|
|
|
94
94
|
| `CheckoutGateways` | Map keyed by gateway code (e.g. `stripe`, `paypal`). A session can advertise multiple concurrent gateways. |
|
|
95
95
|
| `GatewayEnvironment` | `'sandbox'` / `'live'` — drives the PayPal JS SDK script and any other environment-scoped behavior |
|
|
96
96
|
| `PaymentResult` | Payment outcome: `status` (`'succeeded'`/`'processing'`/`'requires_action'`/`'failed'`), `paymentIntentId?`, `error?` |
|
|
97
|
-
| `ConfirmPaymentParams` | `clientSecret`, `returnUrl
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
97
|
+
| `ConfirmPaymentParams` | Non-card confirmation: `clientSecret`, `paymentMethodCategory` (`'wallet'`/`'apm'`), `paymentMethodType`, `returnUrl?`, `billingDetails?`; `card` is rejected at runtime. |
|
|
98
|
+
| `PayPalPaymentResult` | Stripe-hosted PayPal outcome: `status`, `paymentIntentId?`, `paymentMethodId?`, `error?` |
|
|
99
|
+
| `CreateSessionIntentRequest` | Discriminated Stripe wallet/APM or PayPal order/subscription intent request. Direct card is not representable. |
|
|
100
|
+
| `SessionIntent` | Matching discriminated response with provider, payment-method category/type/id, intent kind, client secret, and provider object ID kept as separate fields. |
|
|
101
|
+
| `SessionIntentDeclineRequest` | Non-card provider decline classification. Runtime reporting accepts safe classification codes only and rejects messages or identifier-shaped values. |
|
|
102
|
+
| `ElementType` | `'payment'` / `'address'` |
|
|
103
|
+
| `ElementOptions` | Options for creating non-card elements: `appearance?`, `paymentMethodTypes?`, `clientSecret?`, `amount?`, `currency?`, `paymentMethodCreation?`, `layout?`, `defaultValues?`, `readOnly?`, `mode?`. A `payment` element requires a non-empty wallet/APM allowlist. |
|
|
103
104
|
| `MountedElement` | Runtime element: `mount()`, `unmount()`, `update()`, `on()`, `off()`, `destroy()` |
|
|
104
|
-
| `PaymentProviderAdapter` | Provider interface
|
|
105
|
+
| `PaymentProviderAdapter` | Provider interface for non-card elements, confirmations, PayPal, raw-provider access, and lifecycle management. Card collection uses `CardCaptureAdapter`. |
|
|
105
106
|
| `ElementChangeEvent` | Change event: `elementType`, `complete`, `empty`, `error?`, `value?` |
|
|
106
107
|
| `Customer` | `id`, `email`, `firstName?`, `lastName?`, `gender?`, `city?`, `state?`, `country?`, `zip?` |
|
|
107
108
|
| `LineItem` | `price?`, `priceData?`, `quantity` |
|
|
@@ -177,7 +178,7 @@ policy.
|
|
|
177
178
|
| `THEMES` | `Record<ThemeBundleId, ThemeBundle>` — pick `THEMES['glass-dark']` to get `{ appearance, buttonsLayout }` |
|
|
178
179
|
| `resolveTheme(id)` | Resolve a `ThemeId` (`'classic'` ∪ `ThemeBundleId`) to its `ThemeBundle`; `'classic'` and missing ids return `undefined` |
|
|
179
180
|
| `resolveButtonsLayoutTheme(name)` | Map a `ButtonsLayoutTheme` name to its `ButtonsLayoutStyles` preset |
|
|
180
|
-
| `ELEMENT_TYPES` | `['payment', '
|
|
181
|
+
| `ELEMENT_TYPES` | `['payment', 'address']` |
|
|
181
182
|
| `SUPPORTED_CARD_BRANDS` | `['visa', 'mastercard', 'mastercard_debit', 'amex', 'discover']` |
|
|
182
183
|
| `STRIPE_EXPRESS_METHODS` | `['apple_pay', 'google_pay', 'paypal', 'link', 'amazon_pay', 'klarna']` — Stripe method type identifiers supported by `ExpressCheckoutElement` (everything else returned in `gateways.stripe.enabledPaymentMethods` falls into the `PaymentElement` accordion in the React SDK) |
|
|
183
184
|
| `partitionStripeMethods(enabledMethods, { excludePaypal? })` | Split the backend's enabled list into `{ expressMethods, paymentElementMethods }`. Drops `card`; also drops `paypal` when `excludePaypal: true`. |
|
package/dist/index.cjs
CHANGED
|
@@ -79,6 +79,7 @@ __export(index_exports, {
|
|
|
79
79
|
TELEMETRY_SDK_PACKAGES: () => TELEMETRY_SDK_PACKAGES,
|
|
80
80
|
THEMES: () => THEMES,
|
|
81
81
|
US_STATES: () => US_STATES,
|
|
82
|
+
UUID_V4: () => UUID_V42,
|
|
82
83
|
apiError: () => apiError,
|
|
83
84
|
authenticationError: () => authenticationError,
|
|
84
85
|
buildCheckoutDisplayData: () => buildCheckoutDisplayData,
|
|
@@ -110,6 +111,7 @@ __export(index_exports, {
|
|
|
110
111
|
isAVSFieldVisible: () => isAVSFieldVisible,
|
|
111
112
|
isPostalCodeSupported: () => isPostalCodeSupported,
|
|
112
113
|
isSetupIntentClientSecret: () => isSetupIntentClientSecret,
|
|
114
|
+
isUuidV4: () => isUuidV4,
|
|
113
115
|
isValidPostalCode: () => isValidPostalCode,
|
|
114
116
|
isValidPublishableKey: () => isValidPublishableKey,
|
|
115
117
|
isValidSecretKey: () => isValidSecretKey,
|
|
@@ -117,6 +119,7 @@ __export(index_exports, {
|
|
|
117
119
|
networkError: () => networkError,
|
|
118
120
|
normalizeGatewayEnvironment: () => normalizeGatewayEnvironment,
|
|
119
121
|
partitionStripeMethods: () => partitionStripeMethods,
|
|
122
|
+
randomUuidV4: () => randomUuidV4,
|
|
120
123
|
rateLimitError: () => rateLimitError,
|
|
121
124
|
resolveAVSConfig: () => resolveAVSConfig,
|
|
122
125
|
resolveBillingApiUrl: () => resolveBillingApiUrl,
|
|
@@ -1762,10 +1765,6 @@ function partitionStripeMethods(enabledPaymentMethods, options) {
|
|
|
1762
1765
|
}
|
|
1763
1766
|
var ELEMENT_TYPES = [
|
|
1764
1767
|
"payment",
|
|
1765
|
-
"card",
|
|
1766
|
-
"cardNumber",
|
|
1767
|
-
"cardExpiry",
|
|
1768
|
-
"cardCvc",
|
|
1769
1768
|
"address"
|
|
1770
1769
|
];
|
|
1771
1770
|
var SUPPORTED_CARD_BRANDS = [
|
|
@@ -2619,6 +2618,31 @@ function resolveIdempotencyKey(supplied) {
|
|
|
2619
2618
|
}
|
|
2620
2619
|
return supplied;
|
|
2621
2620
|
}
|
|
2621
|
+
|
|
2622
|
+
// src/uuid.ts
|
|
2623
|
+
var UUID_V42 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
2624
|
+
function isUuidV4(value) {
|
|
2625
|
+
return typeof value === "string" && UUID_V42.test(value);
|
|
2626
|
+
}
|
|
2627
|
+
function randomUuidV4() {
|
|
2628
|
+
try {
|
|
2629
|
+
const id = globalThis.crypto.randomUUID();
|
|
2630
|
+
if (UUID_V42.test(id)) return id;
|
|
2631
|
+
} catch {
|
|
2632
|
+
}
|
|
2633
|
+
const bytes = new Uint8Array(16);
|
|
2634
|
+
try {
|
|
2635
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
2636
|
+
} catch {
|
|
2637
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
2638
|
+
bytes[index] = Math.floor(Math.random() * 256);
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
2642
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
2643
|
+
const hex = [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
2644
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
2645
|
+
}
|
|
2622
2646
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2623
2647
|
0 && (module.exports = {
|
|
2624
2648
|
BILLING_API_URL,
|
|
@@ -2670,6 +2694,7 @@ function resolveIdempotencyKey(supplied) {
|
|
|
2670
2694
|
TELEMETRY_SDK_PACKAGES,
|
|
2671
2695
|
THEMES,
|
|
2672
2696
|
US_STATES,
|
|
2697
|
+
UUID_V4,
|
|
2673
2698
|
apiError,
|
|
2674
2699
|
authenticationError,
|
|
2675
2700
|
buildCheckoutDisplayData,
|
|
@@ -2701,6 +2726,7 @@ function resolveIdempotencyKey(supplied) {
|
|
|
2701
2726
|
isAVSFieldVisible,
|
|
2702
2727
|
isPostalCodeSupported,
|
|
2703
2728
|
isSetupIntentClientSecret,
|
|
2729
|
+
isUuidV4,
|
|
2704
2730
|
isValidPostalCode,
|
|
2705
2731
|
isValidPublishableKey,
|
|
2706
2732
|
isValidSecretKey,
|
|
@@ -2708,6 +2734,7 @@ function resolveIdempotencyKey(supplied) {
|
|
|
2708
2734
|
networkError,
|
|
2709
2735
|
normalizeGatewayEnvironment,
|
|
2710
2736
|
partitionStripeMethods,
|
|
2737
|
+
randomUuidV4,
|
|
2711
2738
|
rateLimitError,
|
|
2712
2739
|
resolveAVSConfig,
|
|
2713
2740
|
resolveBillingApiUrl,
|