@primer-io/primer-js 0.8.1 → 0.9.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/CHANGELOG.md +12 -0
- package/dist/custom-elements.json +1037 -925
- package/dist/jsx/index.d.ts +8 -8
- package/dist/primer-loader.d.ts +306 -136
- package/dist/primer-loader.js +4 -4
- package/dist/vscode.html-custom-data.json +7 -7
- package/dist/web-types.json +18 -12
- package/package.json +1 -1
package/dist/jsx/index.d.ts
CHANGED
|
@@ -461,7 +461,7 @@ export type ShowOtherPaymentsComponentProps = {
|
|
|
461
461
|
/** Consume the events context for external control */
|
|
462
462
|
contextEventsController?: EventsContextType;
|
|
463
463
|
/** */
|
|
464
|
-
"
|
|
464
|
+
"onprimer:show-other-payments-toggled"?: (e: CustomEvent<CustomEvent>) => void;
|
|
465
465
|
};
|
|
466
466
|
|
|
467
467
|
export type VaultManagerComponentProps = {
|
|
@@ -657,8 +657,6 @@ export type VaultDeleteConfirmationComponentProps = {
|
|
|
657
657
|
vaultManager?: VaultManagerContextType;
|
|
658
658
|
};
|
|
659
659
|
|
|
660
|
-
export type VaultEmptyStateComponentProps = {};
|
|
661
|
-
|
|
662
660
|
export type VaultErrorMessageComponentProps = {
|
|
663
661
|
/** The error message to display */
|
|
664
662
|
errorMessage?: string;
|
|
@@ -676,6 +674,8 @@ export type VaultErrorMessageComponentProps = {
|
|
|
676
674
|
) => void;
|
|
677
675
|
};
|
|
678
676
|
|
|
677
|
+
export type VaultEmptyStateComponentProps = {};
|
|
678
|
+
|
|
679
679
|
export type VaultManagerHeaderComponentProps = {
|
|
680
680
|
/** Whether we're in edit mode */
|
|
681
681
|
isEditMode?: boolean;
|
|
@@ -1067,7 +1067,7 @@ export type CustomElements = {
|
|
|
1067
1067
|
*
|
|
1068
1068
|
*
|
|
1069
1069
|
* ### **Events:**
|
|
1070
|
-
* - **show-other-payments-toggled**
|
|
1070
|
+
* - **primer:show-other-payments-toggled**
|
|
1071
1071
|
*
|
|
1072
1072
|
* ### **Methods:**
|
|
1073
1073
|
* - **expand(): _void_** - Public API: Expand the accordion programmatically
|
|
@@ -1236,18 +1236,18 @@ export type CustomElements = {
|
|
|
1236
1236
|
"primer-vault-delete-confirmation": Partial<VaultDeleteConfirmationComponentProps & BaseProps & BaseEvents>;
|
|
1237
1237
|
|
|
1238
1238
|
/**
|
|
1239
|
-
*
|
|
1239
|
+
* VaultErrorMessageComponent - displays error messages with improved visuals
|
|
1240
1240
|
* ---
|
|
1241
1241
|
*
|
|
1242
1242
|
*/
|
|
1243
|
-
"primer-vault-
|
|
1243
|
+
"primer-vault-error-message": Partial<VaultErrorMessageComponentProps & BaseProps & BaseEvents>;
|
|
1244
1244
|
|
|
1245
1245
|
/**
|
|
1246
|
-
*
|
|
1246
|
+
* VaultEmptyStateComponent - displays when no payment methods are available
|
|
1247
1247
|
* ---
|
|
1248
1248
|
*
|
|
1249
1249
|
*/
|
|
1250
|
-
"primer-vault-
|
|
1250
|
+
"primer-vault-empty-state": Partial<VaultEmptyStateComponentProps & BaseProps & BaseEvents>;
|
|
1251
1251
|
|
|
1252
1252
|
/**
|
|
1253
1253
|
* VaultManagerHeaderComponent - displays the header for the vault manager
|
package/dist/primer-loader.d.ts
CHANGED
|
@@ -190,6 +190,8 @@ declare const PaymentMethodType: {
|
|
|
190
190
|
readonly ATOME: "ATOME";
|
|
191
191
|
readonly DLOCAL_PIX: "DLOCAL_PIX";
|
|
192
192
|
readonly ALMA: "ALMA";
|
|
193
|
+
readonly ADYEN_CASHAPP: "ADYEN_CASHAPP";
|
|
194
|
+
readonly ADYEN_AFFIRM: "ADYEN_AFFIRM";
|
|
193
195
|
};
|
|
194
196
|
export type PaymentMethodType = (typeof PaymentMethodType)[keyof typeof PaymentMethodType];
|
|
195
197
|
declare const PaymentMethodType$1 = {
|
|
@@ -1418,6 +1420,44 @@ export interface PrimerCheckoutOptions {
|
|
|
1418
1420
|
* @default false
|
|
1419
1421
|
*/
|
|
1420
1422
|
showEmptyState?: boolean;
|
|
1423
|
+
/**
|
|
1424
|
+
* Whether to hide vault UI components while keeping vault functionality active.
|
|
1425
|
+
*
|
|
1426
|
+
* When true:
|
|
1427
|
+
* - Vault UI components do not render
|
|
1428
|
+
* - Vault functionality remains active (onVaultedMethodsUpdate callback, APIs)
|
|
1429
|
+
* - Card form and other payment methods display normally
|
|
1430
|
+
* - Enables headless vault implementation patterns
|
|
1431
|
+
*
|
|
1432
|
+
* When false or undefined:
|
|
1433
|
+
* - Vault UI components render normally (default behavior)
|
|
1434
|
+
*
|
|
1435
|
+
* Use this for custom vault UI implementations where you want to:
|
|
1436
|
+
* - Build your own vault item display using onVaultedMethodsUpdate callback
|
|
1437
|
+
* - Create custom CVV inputs programmatically
|
|
1438
|
+
* - Start vaulted payments through PrimerJS API
|
|
1439
|
+
*
|
|
1440
|
+
* @default false
|
|
1441
|
+
* @example
|
|
1442
|
+
* ```typescript
|
|
1443
|
+
* // Headless vault mode - no vault UI
|
|
1444
|
+
* {
|
|
1445
|
+
* vault: {
|
|
1446
|
+
* enabled: true,
|
|
1447
|
+
* headless: true
|
|
1448
|
+
* }
|
|
1449
|
+
* }
|
|
1450
|
+
*
|
|
1451
|
+
* // Standard vault mode - shows vault UI
|
|
1452
|
+
* {
|
|
1453
|
+
* vault: {
|
|
1454
|
+
* enabled: true,
|
|
1455
|
+
* headless: false
|
|
1456
|
+
* }
|
|
1457
|
+
* }
|
|
1458
|
+
* ```
|
|
1459
|
+
*/
|
|
1460
|
+
headless?: boolean;
|
|
1421
1461
|
};
|
|
1422
1462
|
/**
|
|
1423
1463
|
* Configuration options for Stripe ACH payment method.
|
|
@@ -1724,6 +1764,149 @@ export declare class InitializedVaultedPayments {
|
|
|
1724
1764
|
*/
|
|
1725
1765
|
size(): number;
|
|
1726
1766
|
}
|
|
1767
|
+
export type ReducerCallbacks<State, _Action extends {
|
|
1768
|
+
type: string;
|
|
1769
|
+
}> = {
|
|
1770
|
+
[K in keyof State]?: State[K] extends (...args: unknown[]) => unknown ? State[K] : never;
|
|
1771
|
+
};
|
|
1772
|
+
export type TypedReducer<State, Action extends {
|
|
1773
|
+
type: string;
|
|
1774
|
+
}, Callbacks> = (state: State, action: Action, callbacks: Callbacks) => State;
|
|
1775
|
+
declare abstract class ReactiveStateController<Host extends ReactiveControllerHost, State, Action extends {
|
|
1776
|
+
type: string;
|
|
1777
|
+
}, Callbacks = ReducerCallbacks<State, Action> | null> implements ReactiveController {
|
|
1778
|
+
protected host: Host;
|
|
1779
|
+
protected stateHandler: (state: State) => void;
|
|
1780
|
+
private _dispatcher;
|
|
1781
|
+
constructor(host: Host, initialState: State, reducer: TypedReducer<State, Action, Callbacks>, initialCallbacks: Callbacks, stateHandler?: (state: State) => void);
|
|
1782
|
+
get currentState(): Readonly<State>;
|
|
1783
|
+
protected dispatch(action: Action): void;
|
|
1784
|
+
protected setCallbacks(callbacks: Partial<Callbacks>): void;
|
|
1785
|
+
hostConnected(): void;
|
|
1786
|
+
hostDisconnected(): void;
|
|
1787
|
+
}
|
|
1788
|
+
declare class CompositeStateController<Host extends ReactiveControllerHost> implements ReactiveController {
|
|
1789
|
+
protected host: Host;
|
|
1790
|
+
private _controllers;
|
|
1791
|
+
constructor(host: Host);
|
|
1792
|
+
addController<State, Action extends {
|
|
1793
|
+
type: string;
|
|
1794
|
+
}, Callbacks = ReducerCallbacks<State, Action> | null>(controller: ReactiveStateController<Host, State, Action, Callbacks>): void;
|
|
1795
|
+
hostConnected(): void;
|
|
1796
|
+
hostDisconnected(): void;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Options for initializing the Vault Manager
|
|
1800
|
+
*/
|
|
1801
|
+
export interface VaultManagerInitOptions {
|
|
1802
|
+
vaultEnabled?: boolean;
|
|
1803
|
+
captureVaultedCardCvv?: boolean;
|
|
1804
|
+
showEmptyState?: boolean;
|
|
1805
|
+
headless?: boolean;
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* Core state interface for vault manager
|
|
1809
|
+
* Contains properties related to vault functionality that don't change frequently
|
|
1810
|
+
*/
|
|
1811
|
+
export interface VaultManagerState {
|
|
1812
|
+
enabled: boolean;
|
|
1813
|
+
isLoading: boolean;
|
|
1814
|
+
isUpdating: boolean;
|
|
1815
|
+
vaultedPaymentMethods: VaultedPaymentMethod[];
|
|
1816
|
+
cvvRecapture: boolean;
|
|
1817
|
+
showEmptyState: boolean;
|
|
1818
|
+
headless: boolean;
|
|
1819
|
+
createCvvInput: ((options: CardSecurityCodeInputOptions) => Promise<CvvInput | null>) | null;
|
|
1820
|
+
deleteVaultedPaymentMethod: (paymentMethodId: string) => Promise<void>;
|
|
1821
|
+
startVaultedPaymentFlow: (options?: {
|
|
1822
|
+
cvv?: string;
|
|
1823
|
+
}) => Promise<void>;
|
|
1824
|
+
}
|
|
1825
|
+
/**
|
|
1826
|
+
* CVV-specific state interface
|
|
1827
|
+
* Contains properties specifically related to CVV input functionality
|
|
1828
|
+
*/
|
|
1829
|
+
export interface VaultManagerItemState {
|
|
1830
|
+
formIsDirty: boolean;
|
|
1831
|
+
cvvInput: CvvInput | null;
|
|
1832
|
+
setCvvInput: (metadata: CvvInput | null) => void;
|
|
1833
|
+
selectedVaultedPaymentMethod: VaultedPaymentMethod | null;
|
|
1834
|
+
setSelectedVaultedPaymentMethod: (paymentMethod: VaultedPaymentMethod | null) => void;
|
|
1835
|
+
}
|
|
1836
|
+
declare class VaultManagerController extends CompositeStateController<PrimerCheckoutType> {
|
|
1837
|
+
private coreController;
|
|
1838
|
+
private itemController;
|
|
1839
|
+
private _vaultManager;
|
|
1840
|
+
private _options;
|
|
1841
|
+
private createVaultManagerFn;
|
|
1842
|
+
constructor(host: PrimerCheckoutType);
|
|
1843
|
+
/**
|
|
1844
|
+
* Initialize the vault manager with a factory function and options
|
|
1845
|
+
* @param createVaultManagerFn - Bound function to create vault manager when needed
|
|
1846
|
+
* @param options - Vault configuration options
|
|
1847
|
+
*/
|
|
1848
|
+
initializeVaultManager(createVaultManagerFn: PrimerHeadlessCheckout["createVaultManager"] | null, options?: VaultManagerInitOptions): void;
|
|
1849
|
+
get vaultManager(): HeadlessVaultManager | null;
|
|
1850
|
+
set vaultManager(vaultManager: HeadlessVaultManager | null);
|
|
1851
|
+
get options(): VaultManagerInitOptions | null;
|
|
1852
|
+
set options(options: VaultManagerInitOptions | null);
|
|
1853
|
+
get vaultManagerState(): Readonly<VaultManagerState>;
|
|
1854
|
+
get vaultItemState(): Readonly<VaultManagerItemState>;
|
|
1855
|
+
/**
|
|
1856
|
+
* Lifecycle method called when the host disconnects
|
|
1857
|
+
*/
|
|
1858
|
+
hostDisconnected(): void;
|
|
1859
|
+
/**
|
|
1860
|
+
* Transform raw vault data into filtered, event-ready format.
|
|
1861
|
+
* Applies PII filtering to all vaulted payment methods.
|
|
1862
|
+
*
|
|
1863
|
+
* @param vaultedPaymentMethods - Raw vaulted payment methods from API
|
|
1864
|
+
* @returns InitializedVaultedPayments wrapper with filtered data
|
|
1865
|
+
*/
|
|
1866
|
+
private createVaultedPaymentsWrapper;
|
|
1867
|
+
/**
|
|
1868
|
+
* Update vaulted payment methods and dispatch events/callbacks.
|
|
1869
|
+
* This method:
|
|
1870
|
+
* 1. Updates internal state via core controller
|
|
1871
|
+
* 2. Creates filtered wrapper for external APIs
|
|
1872
|
+
* 3. Dispatches event to listeners
|
|
1873
|
+
* 4. Invokes callback if defined
|
|
1874
|
+
*
|
|
1875
|
+
* @param methods - Raw vaulted payment methods from API
|
|
1876
|
+
*/
|
|
1877
|
+
private updatePaymentMethodsWithEvents;
|
|
1878
|
+
/**
|
|
1879
|
+
* Fetch vaulted payment methods from the server
|
|
1880
|
+
*/
|
|
1881
|
+
fetchVaultedPaymentMethods(initialLoad?: boolean): Promise<VaultedPaymentMethod[]>;
|
|
1882
|
+
createCvvInput: (options: CardSecurityCodeInputOptions) => Promise<CvvInput | null>;
|
|
1883
|
+
/**
|
|
1884
|
+
* Delete a vaulted payment method by ID
|
|
1885
|
+
*/
|
|
1886
|
+
deleteVaultedPaymentMethod: (paymentMethodId: string) => Promise<void>;
|
|
1887
|
+
/**
|
|
1888
|
+
* Set the CVV metadata - updates CVV state only
|
|
1889
|
+
* Moved to the separate CVV context
|
|
1890
|
+
*/
|
|
1891
|
+
setCvvInput: (metadata: CvvInput | null) => void;
|
|
1892
|
+
/**
|
|
1893
|
+
* Start the vaulted payment flow
|
|
1894
|
+
* Verifies form state validity before processing
|
|
1895
|
+
*/
|
|
1896
|
+
startVaultedPaymentFlow: () => Promise<void>;
|
|
1897
|
+
/**
|
|
1898
|
+
* Set the selected vaulted payment method - updates form state only
|
|
1899
|
+
*/
|
|
1900
|
+
setSelectedVaultedPaymentMethod: (paymentMethod: VaultedPaymentMethod | null) => void;
|
|
1901
|
+
/**
|
|
1902
|
+
* Start vaulted payment flow by payment method ID
|
|
1903
|
+
* @param paymentMethodId - The ID of the vaulted payment method
|
|
1904
|
+
* @param options - Optional payment options including CVV token
|
|
1905
|
+
*/
|
|
1906
|
+
startVaultPaymentById: (paymentMethodId: string, options?: {
|
|
1907
|
+
cvv?: string;
|
|
1908
|
+
}) => Promise<void>;
|
|
1909
|
+
}
|
|
1727
1910
|
/**
|
|
1728
1911
|
* Payment prepare callback data.
|
|
1729
1912
|
* Includes payment method type for validation or abort control flow.
|
|
@@ -1774,6 +1957,8 @@ export interface PaymentFailureData {
|
|
|
1774
1957
|
export interface VaultedMethodsUpdateData {
|
|
1775
1958
|
/** Wrapper containing filtered vaulted payment methods */
|
|
1776
1959
|
vaultedPayments: InitializedVaultedPayments;
|
|
1960
|
+
/** Indicates if CVV recapture is required for vaulted payments */
|
|
1961
|
+
cvvRecapture: boolean;
|
|
1777
1962
|
/** Unix timestamp in seconds */
|
|
1778
1963
|
timestamp: number;
|
|
1779
1964
|
}
|
|
@@ -1785,6 +1970,7 @@ export declare class PrimerJS {
|
|
|
1785
1970
|
private headlessInstance;
|
|
1786
1971
|
private paymentMethods;
|
|
1787
1972
|
private paymentManagers;
|
|
1973
|
+
private vaultController;
|
|
1788
1974
|
/**
|
|
1789
1975
|
* Called when payment flow begins.
|
|
1790
1976
|
* Use for analytics tracking or UI updates (e.g., disable form).
|
|
@@ -1879,10 +2065,11 @@ export declare class PrimerJS {
|
|
|
1879
2065
|
*
|
|
1880
2066
|
* Use for:
|
|
1881
2067
|
* - Building custom vault UI
|
|
2068
|
+
* - Determining if CVV recapture is required (check cvvRecapture flag)
|
|
1882
2069
|
* - Analytics tracking for vault usage
|
|
1883
2070
|
* - Syncing vault state with backend
|
|
1884
2071
|
*
|
|
1885
|
-
* @param data - Vault methods update data with filtered payment methods
|
|
2072
|
+
* @param data - Vault methods update data with filtered payment methods and cvvRecapture flag
|
|
1886
2073
|
*
|
|
1887
2074
|
* @example
|
|
1888
2075
|
* ```typescript
|
|
@@ -1914,6 +2101,98 @@ export declare class PrimerJS {
|
|
|
1914
2101
|
* @internal - This is only used internally by the SDK
|
|
1915
2102
|
*/
|
|
1916
2103
|
setPaymentManagers(managers: InitializedManagersMap): void;
|
|
2104
|
+
/**
|
|
2105
|
+
* Internal method to set the vault controller reference.
|
|
2106
|
+
* Called during vault initialization.
|
|
2107
|
+
* @internal
|
|
2108
|
+
*/
|
|
2109
|
+
setVaultController(controller: VaultManagerController | null): void;
|
|
2110
|
+
/**
|
|
2111
|
+
* Creates a CVV input for vaulted payment method CVV recapture.
|
|
2112
|
+
*
|
|
2113
|
+
* ⚠️ Requires vault to be initialized. Check vault availability via
|
|
2114
|
+
* the onVaultedMethodsUpdate callback before calling.
|
|
2115
|
+
*
|
|
2116
|
+
* @param options - CVV input configuration
|
|
2117
|
+
* @returns Promise resolving to CvvInput or null if vault unavailable
|
|
2118
|
+
*
|
|
2119
|
+
* @example
|
|
2120
|
+
* ```typescript
|
|
2121
|
+
* const method = vaultedPayments.get(selectedId);
|
|
2122
|
+
* const cvvInput = await primerJS.createCvvInput({
|
|
2123
|
+
* cardNetwork: method.paymentInstrumentData.network,
|
|
2124
|
+
* container: "#cvv-container",
|
|
2125
|
+
* placeholder: "123"
|
|
2126
|
+
* });
|
|
2127
|
+
*
|
|
2128
|
+
* if (cvvInput.metadata.error) {
|
|
2129
|
+
* // Handle validation error
|
|
2130
|
+
* }
|
|
2131
|
+
* ```
|
|
2132
|
+
*/
|
|
2133
|
+
createCvvInput(options: CardSecurityCodeInputOptions): Promise<CvvInput | null>;
|
|
2134
|
+
/**
|
|
2135
|
+
* Initiates payment using a vaulted payment method.
|
|
2136
|
+
*
|
|
2137
|
+
* Enables headless vault flows where merchants build custom vault UIs.
|
|
2138
|
+
* Mirrors the legacy SDK's vaultManager.startPaymentFlow().
|
|
2139
|
+
*
|
|
2140
|
+
* @param paymentMethodId - The ID of the vaulted payment method
|
|
2141
|
+
* @param options - Optional payment options
|
|
2142
|
+
* @param options.cvv - CVV value token (required if cvvRecapture is true)
|
|
2143
|
+
* @returns Promise that resolves when payment flow starts
|
|
2144
|
+
* @throws Error if vault not initialized or payment method not found
|
|
2145
|
+
*
|
|
2146
|
+
* @example
|
|
2147
|
+
* ```typescript
|
|
2148
|
+
* // Complete headless vault flow
|
|
2149
|
+
* let vaultedMethods;
|
|
2150
|
+
* let needsCvv = false;
|
|
2151
|
+
*
|
|
2152
|
+
* primerJS.onVaultedMethodsUpdate = ({ vaultedPayments, cvvRecapture }) => {
|
|
2153
|
+
* vaultedMethods = vaultedPayments.toArray();
|
|
2154
|
+
* needsCvv = cvvRecapture;
|
|
2155
|
+
*
|
|
2156
|
+
* // Build custom vault UI
|
|
2157
|
+
* vaultedMethods.forEach(method => {
|
|
2158
|
+
* displayVaultItem({
|
|
2159
|
+
* id: method.id,
|
|
2160
|
+
* last4: method.paymentInstrumentData?.last4Digits,
|
|
2161
|
+
* network: method.paymentInstrumentData?.network
|
|
2162
|
+
* });
|
|
2163
|
+
* });
|
|
2164
|
+
* };
|
|
2165
|
+
*
|
|
2166
|
+
* // When user submits payment
|
|
2167
|
+
* async function handlePayment(selectedMethodId) {
|
|
2168
|
+
* try {
|
|
2169
|
+
* if (needsCvv) {
|
|
2170
|
+
* const method = vaultedMethods.find(m => m.id === selectedMethodId);
|
|
2171
|
+
* const cvvInput = await primerJS.createCvvInput({
|
|
2172
|
+
* cardNetwork: method.paymentInstrumentData.network,
|
|
2173
|
+
* container: "#cvv-container"
|
|
2174
|
+
* });
|
|
2175
|
+
*
|
|
2176
|
+
* if (cvvInput.metadata.error) {
|
|
2177
|
+
* showError("Invalid CVV");
|
|
2178
|
+
* return;
|
|
2179
|
+
* }
|
|
2180
|
+
*
|
|
2181
|
+
* await primerJS.startVaultPayment(selectedMethodId, {
|
|
2182
|
+
* cvv: cvvInput.valueToken
|
|
2183
|
+
* });
|
|
2184
|
+
* } else {
|
|
2185
|
+
* await primerJS.startVaultPayment(selectedMethodId);
|
|
2186
|
+
* }
|
|
2187
|
+
* } catch (error) {
|
|
2188
|
+
* console.error("Payment failed:", error);
|
|
2189
|
+
* }
|
|
2190
|
+
* }
|
|
2191
|
+
* ```
|
|
2192
|
+
*/
|
|
2193
|
+
startVaultPayment(paymentMethodId: string, options?: {
|
|
2194
|
+
cvv?: string;
|
|
2195
|
+
}): Promise<void>;
|
|
1917
2196
|
/**
|
|
1918
2197
|
* Refetches a new client session from merchant backend.
|
|
1919
2198
|
*/
|
|
@@ -1941,7 +2220,7 @@ export declare class PrimerJS {
|
|
|
1941
2220
|
* Internal method to handle the onVaultedMethodsUpdate callback
|
|
1942
2221
|
* @internal - This is only used internally by the SDK
|
|
1943
2222
|
*/
|
|
1944
|
-
handleVaultedMethodsUpdate(vaultedPayments: InitializedVaultedPayments): void;
|
|
2223
|
+
handleVaultedMethodsUpdate(vaultedPayments: InitializedVaultedPayments, cvvRecapture: boolean): void;
|
|
1945
2224
|
/**
|
|
1946
2225
|
* Sets the cardholder name value in the card payment form.
|
|
1947
2226
|
*
|
|
@@ -1987,6 +2266,9 @@ export interface ShowOtherPaymentsTogglePayload {
|
|
|
1987
2266
|
action?: "toggle" | "expand" | "collapse";
|
|
1988
2267
|
source?: string;
|
|
1989
2268
|
}
|
|
2269
|
+
export interface ShowOtherPaymentsToggledPayload {
|
|
2270
|
+
expanded: boolean;
|
|
2271
|
+
}
|
|
1990
2272
|
export interface PrimerEvents {
|
|
1991
2273
|
"primer:state-change": CustomEvent<SdkStateContextType>;
|
|
1992
2274
|
"primer:methods-update": CustomEvent<InitializedPayments>;
|
|
@@ -2020,8 +2302,13 @@ export interface PrimerEvents {
|
|
|
2020
2302
|
vaultedPayments: InitializedVaultedPayments;
|
|
2021
2303
|
timestamp: number;
|
|
2022
2304
|
}>;
|
|
2305
|
+
"primer:vault:selection-change": CustomEvent<{
|
|
2306
|
+
paymentMethodId: string | null;
|
|
2307
|
+
timestamp: number;
|
|
2308
|
+
}>;
|
|
2023
2309
|
"primer:vault-submit": CustomEvent<VaultSubmitPayload>;
|
|
2024
2310
|
"primer:show-other-payments-toggle": CustomEvent<ShowOtherPaymentsTogglePayload>;
|
|
2311
|
+
"primer:show-other-payments-toggled": CustomEvent<ShowOtherPaymentsToggledPayload>;
|
|
2025
2312
|
}
|
|
2026
2313
|
declare class PrimerEventsController implements ReactiveController {
|
|
2027
2314
|
host: ReactiveControllerHost & LitElement;
|
|
@@ -2077,6 +2364,13 @@ declare class PrimerEventsController implements ReactiveController {
|
|
|
2077
2364
|
* @param vaultedPayments - Wrapper containing filtered vaulted payment methods
|
|
2078
2365
|
*/
|
|
2079
2366
|
dispatchVaultMethodsUpdate(vaultedPayments: InitializedVaultedPayments): void;
|
|
2367
|
+
/**
|
|
2368
|
+
* Dispatch vault selection change event.
|
|
2369
|
+
* Called when a vaulted payment method is selected or deselected.
|
|
2370
|
+
*
|
|
2371
|
+
* @param paymentMethodId - ID of the selected payment method, or null if deselected
|
|
2372
|
+
*/
|
|
2373
|
+
dispatchVaultSelectionChange(paymentMethodId: string | null): void;
|
|
2080
2374
|
/**
|
|
2081
2375
|
* Dispatch vault submit event.
|
|
2082
2376
|
* Called when a vault payment submission is triggered.
|
|
@@ -2103,6 +2397,13 @@ declare class PrimerEventsController implements ReactiveController {
|
|
|
2103
2397
|
* @param eventDetails - The event details to forward, including action and source information
|
|
2104
2398
|
*/
|
|
2105
2399
|
handleExternalShowOtherPaymentsToggle(eventDetails: ShowOtherPaymentsTogglePayload): void;
|
|
2400
|
+
/**
|
|
2401
|
+
* Dispatch show other payments toggled event.
|
|
2402
|
+
* Called when the "Show other ways to pay" accordion state changes.
|
|
2403
|
+
*
|
|
2404
|
+
* @param expanded - Whether the accordion is now expanded
|
|
2405
|
+
*/
|
|
2406
|
+
dispatchShowOtherPaymentsToggled(expanded: boolean): void;
|
|
2106
2407
|
}
|
|
2107
2408
|
export type AnalyticsContextType = AnalyticsUtils | null;
|
|
2108
2409
|
export type EventsContextType = PrimerEventsController | null;
|
|
@@ -2112,139 +2413,6 @@ export type KlarnaCategoriesContextType = {
|
|
|
2112
2413
|
categories: KlarnaPaymentMethodCategory[];
|
|
2113
2414
|
isLoading: boolean;
|
|
2114
2415
|
};
|
|
2115
|
-
export type ReducerCallbacks<State, _Action extends {
|
|
2116
|
-
type: string;
|
|
2117
|
-
}> = {
|
|
2118
|
-
[K in keyof State]?: State[K] extends (...args: unknown[]) => unknown ? State[K] : never;
|
|
2119
|
-
};
|
|
2120
|
-
export type TypedReducer<State, Action extends {
|
|
2121
|
-
type: string;
|
|
2122
|
-
}, Callbacks> = (state: State, action: Action, callbacks: Callbacks) => State;
|
|
2123
|
-
declare abstract class ReactiveStateController<Host extends ReactiveControllerHost, State, Action extends {
|
|
2124
|
-
type: string;
|
|
2125
|
-
}, Callbacks = ReducerCallbacks<State, Action> | null> implements ReactiveController {
|
|
2126
|
-
protected host: Host;
|
|
2127
|
-
protected stateHandler: (state: State) => void;
|
|
2128
|
-
private _dispatcher;
|
|
2129
|
-
constructor(host: Host, initialState: State, reducer: TypedReducer<State, Action, Callbacks>, initialCallbacks: Callbacks, stateHandler?: (state: State) => void);
|
|
2130
|
-
get currentState(): Readonly<State>;
|
|
2131
|
-
protected dispatch(action: Action): void;
|
|
2132
|
-
protected setCallbacks(callbacks: Partial<Callbacks>): void;
|
|
2133
|
-
hostConnected(): void;
|
|
2134
|
-
hostDisconnected(): void;
|
|
2135
|
-
}
|
|
2136
|
-
declare class CompositeStateController<Host extends ReactiveControllerHost> implements ReactiveController {
|
|
2137
|
-
protected host: Host;
|
|
2138
|
-
private _controllers;
|
|
2139
|
-
constructor(host: Host);
|
|
2140
|
-
addController<State, Action extends {
|
|
2141
|
-
type: string;
|
|
2142
|
-
}, Callbacks = ReducerCallbacks<State, Action> | null>(controller: ReactiveStateController<Host, State, Action, Callbacks>): void;
|
|
2143
|
-
hostConnected(): void;
|
|
2144
|
-
hostDisconnected(): void;
|
|
2145
|
-
}
|
|
2146
|
-
/**
|
|
2147
|
-
* Options for initializing the Vault Manager
|
|
2148
|
-
*/
|
|
2149
|
-
export interface VaultManagerInitOptions {
|
|
2150
|
-
vaultEnabled?: boolean;
|
|
2151
|
-
captureVaultedCardCvv?: boolean;
|
|
2152
|
-
showEmptyState?: boolean;
|
|
2153
|
-
}
|
|
2154
|
-
/**
|
|
2155
|
-
* Core state interface for vault manager
|
|
2156
|
-
* Contains properties related to vault functionality that don't change frequently
|
|
2157
|
-
*/
|
|
2158
|
-
export interface VaultManagerState {
|
|
2159
|
-
enabled: boolean;
|
|
2160
|
-
isLoading: boolean;
|
|
2161
|
-
isUpdating: boolean;
|
|
2162
|
-
vaultedPaymentMethods: VaultedPaymentMethod[];
|
|
2163
|
-
cvvRecapture: boolean;
|
|
2164
|
-
showEmptyState: boolean;
|
|
2165
|
-
createCvvInput: ((options: CardSecurityCodeInputOptions) => Promise<CvvInput | null>) | null;
|
|
2166
|
-
deleteVaultedPaymentMethod: (paymentMethodId: string) => Promise<void>;
|
|
2167
|
-
startVaultedPaymentFlow: (options?: {
|
|
2168
|
-
cvv?: string;
|
|
2169
|
-
}) => Promise<void>;
|
|
2170
|
-
}
|
|
2171
|
-
/**
|
|
2172
|
-
* CVV-specific state interface
|
|
2173
|
-
* Contains properties specifically related to CVV input functionality
|
|
2174
|
-
*/
|
|
2175
|
-
export interface VaultManagerItemState {
|
|
2176
|
-
formIsDirty: boolean;
|
|
2177
|
-
cvvInput: CvvInput | null;
|
|
2178
|
-
setCvvInput: (metadata: CvvInput | null) => void;
|
|
2179
|
-
selectedVaultedPaymentMethod: VaultedPaymentMethod | null;
|
|
2180
|
-
setSelectedVaultedPaymentMethod: (paymentMethod: VaultedPaymentMethod | null) => void;
|
|
2181
|
-
}
|
|
2182
|
-
declare class VaultManagerController extends CompositeStateController<PrimerCheckoutType> {
|
|
2183
|
-
private coreController;
|
|
2184
|
-
private itemController;
|
|
2185
|
-
private _vaultManager;
|
|
2186
|
-
private _options;
|
|
2187
|
-
private createVaultManagerFn;
|
|
2188
|
-
constructor(host: PrimerCheckoutType);
|
|
2189
|
-
/**
|
|
2190
|
-
* Initialize the vault manager with a factory function and options
|
|
2191
|
-
* @param createVaultManagerFn - Bound function to create vault manager when needed
|
|
2192
|
-
* @param options - Vault configuration options
|
|
2193
|
-
*/
|
|
2194
|
-
initializeVaultManager(createVaultManagerFn: PrimerHeadlessCheckout["createVaultManager"] | null, options?: VaultManagerInitOptions): void;
|
|
2195
|
-
get vaultManager(): HeadlessVaultManager | null;
|
|
2196
|
-
set vaultManager(vaultManager: HeadlessVaultManager | null);
|
|
2197
|
-
get options(): VaultManagerInitOptions | null;
|
|
2198
|
-
set options(options: VaultManagerInitOptions | null);
|
|
2199
|
-
get vaultManagerState(): Readonly<VaultManagerState>;
|
|
2200
|
-
get vaultItemState(): Readonly<VaultManagerItemState>;
|
|
2201
|
-
/**
|
|
2202
|
-
* Lifecycle method called when the host disconnects
|
|
2203
|
-
*/
|
|
2204
|
-
hostDisconnected(): void;
|
|
2205
|
-
/**
|
|
2206
|
-
* Transform raw vault data into filtered, event-ready format.
|
|
2207
|
-
* Applies PII filtering to all vaulted payment methods.
|
|
2208
|
-
*
|
|
2209
|
-
* @param vaultedPaymentMethods - Raw vaulted payment methods from API
|
|
2210
|
-
* @returns InitializedVaultedPayments wrapper with filtered data
|
|
2211
|
-
*/
|
|
2212
|
-
private createVaultedPaymentsWrapper;
|
|
2213
|
-
/**
|
|
2214
|
-
* Update vaulted payment methods and dispatch events/callbacks.
|
|
2215
|
-
* This method:
|
|
2216
|
-
* 1. Updates internal state via core controller
|
|
2217
|
-
* 2. Creates filtered wrapper for external APIs
|
|
2218
|
-
* 3. Dispatches event to listeners
|
|
2219
|
-
* 4. Invokes callback if defined
|
|
2220
|
-
*
|
|
2221
|
-
* @param methods - Raw vaulted payment methods from API
|
|
2222
|
-
*/
|
|
2223
|
-
private updatePaymentMethodsWithEvents;
|
|
2224
|
-
/**
|
|
2225
|
-
* Fetch vaulted payment methods from the server
|
|
2226
|
-
*/
|
|
2227
|
-
fetchVaultedPaymentMethods(initialLoad?: boolean): Promise<VaultedPaymentMethod[]>;
|
|
2228
|
-
createCvvInput: (options: CardSecurityCodeInputOptions) => Promise<CvvInput | null>;
|
|
2229
|
-
/**
|
|
2230
|
-
* Delete a vaulted payment method by ID
|
|
2231
|
-
*/
|
|
2232
|
-
deleteVaultedPaymentMethod: (paymentMethodId: string) => Promise<void>;
|
|
2233
|
-
/**
|
|
2234
|
-
* Set the CVV metadata - updates CVV state only
|
|
2235
|
-
* Moved to the separate CVV context
|
|
2236
|
-
*/
|
|
2237
|
-
setCvvInput: (metadata: CvvInput | null) => void;
|
|
2238
|
-
/**
|
|
2239
|
-
* Start the vaulted payment flow
|
|
2240
|
-
* Verifies form state validity before processing
|
|
2241
|
-
*/
|
|
2242
|
-
startVaultedPaymentFlow: () => Promise<void>;
|
|
2243
|
-
/**
|
|
2244
|
-
* Set the selected vaulted payment method - updates form state only
|
|
2245
|
-
*/
|
|
2246
|
-
setSelectedVaultedPaymentMethod: (paymentMethod: VaultedPaymentMethod | null) => void;
|
|
2247
|
-
}
|
|
2248
2416
|
/**
|
|
2249
2417
|
* Context for core vault manager functionality
|
|
2250
2418
|
* Contains properties that don't change frequently and relate to vault functionality
|
|
@@ -4904,7 +5072,9 @@ declare class ShowOtherPaymentsComponent extends LitElement {
|
|
|
4904
5072
|
*/
|
|
4905
5073
|
private handleToggleSlotChange;
|
|
4906
5074
|
/**
|
|
4907
|
-
* Determines if a button is a toggle button based on its
|
|
5075
|
+
* Determines if a button is a toggle button based on its slot assignment
|
|
5076
|
+
* Only buttons in the 'show-other-payments-toggle-button' slot are toggle buttons
|
|
5077
|
+
* This prevents accidentally capturing other buttons like submit buttons
|
|
4908
5078
|
*/
|
|
4909
5079
|
private isToggleButton;
|
|
4910
5080
|
/**
|