@snap-pay/elements 1.0.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 +20 -0
- package/README.md +87 -0
- package/dist/index.cjs +1337 -0
- package/dist/index.d.cts +299 -0
- package/dist/index.d.ts +299 -0
- package/dist/index.js +1306 -0
- package/package.json +47 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import * as _snap_pay_types from '@snap-pay/types';
|
|
2
|
+
import { SnapElementHandle, ElementType, ElementEventName, ElementEventHandler, ElementEventMap, Appearance, PublicSession, CreateElementOptions, Environment, SnapSelection, BillingAddressValue, CustomerValue, OtpValue } from '@snap-pay/types';
|
|
3
|
+
|
|
4
|
+
declare abstract class BaseElement implements SnapElementHandle {
|
|
5
|
+
abstract readonly type: ElementType;
|
|
6
|
+
private container;
|
|
7
|
+
private mounted;
|
|
8
|
+
private listeners;
|
|
9
|
+
mount(target: string | HTMLElement): void;
|
|
10
|
+
protected deferReadyOnMount: boolean;
|
|
11
|
+
unmount(): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
on<E extends ElementEventName>(event: E, handler: ElementEventHandler<E>): void;
|
|
14
|
+
off<E extends ElementEventName>(event: E, handler: ElementEventHandler<E>): void;
|
|
15
|
+
protected emit<E extends ElementEventName>(event: E, payload: ElementEventMap[E]): void;
|
|
16
|
+
protected abstract render(container: HTMLElement): void;
|
|
17
|
+
getValue(): unknown;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface WalletElementArgs {
|
|
21
|
+
clientSecret: string;
|
|
22
|
+
appearance: Appearance;
|
|
23
|
+
publishableKey: string;
|
|
24
|
+
apiBase: string;
|
|
25
|
+
environment?: _snap_pay_types.Environment;
|
|
26
|
+
cardFrameUrl?: string | undefined;
|
|
27
|
+
registerChild: (getSelection: () => _snap_pay_types.SnapSelection | null) => () => void;
|
|
28
|
+
registerValue: (type: _snap_pay_types.ElementType, getValue: () => unknown | null) => () => void;
|
|
29
|
+
initialSession?: PublicSession;
|
|
30
|
+
options: CreateElementOptions;
|
|
31
|
+
}
|
|
32
|
+
declare class WalletElement extends BaseElement {
|
|
33
|
+
private readonly args;
|
|
34
|
+
readonly type: ElementType;
|
|
35
|
+
private selected;
|
|
36
|
+
private allowed;
|
|
37
|
+
private readonly resolvedAppearance;
|
|
38
|
+
private buttons;
|
|
39
|
+
private renderTarget;
|
|
40
|
+
private readonly unregisterChild;
|
|
41
|
+
constructor(args: WalletElementArgs);
|
|
42
|
+
destroy(): void;
|
|
43
|
+
protected render(container: HTMLElement): void;
|
|
44
|
+
private renderButtons;
|
|
45
|
+
private renderProviderButton;
|
|
46
|
+
private select;
|
|
47
|
+
private buttonStyle;
|
|
48
|
+
}
|
|
49
|
+
declare function createWalletElement(args: WalletElementArgs): WalletElement;
|
|
50
|
+
|
|
51
|
+
interface CardElementArgs {
|
|
52
|
+
clientSecret: string;
|
|
53
|
+
appearance: Appearance;
|
|
54
|
+
publishableKey: string;
|
|
55
|
+
apiBase: string;
|
|
56
|
+
environment: Environment | undefined;
|
|
57
|
+
cardFrameUrl: string | undefined;
|
|
58
|
+
registerChild: (getSelection: () => SnapSelection | null) => () => void;
|
|
59
|
+
registerValue: (type: _snap_pay_types.ElementType, getValue: () => unknown | null) => () => void;
|
|
60
|
+
options: CreateElementOptions;
|
|
61
|
+
}
|
|
62
|
+
declare class CardElement extends BaseElement {
|
|
63
|
+
private readonly args;
|
|
64
|
+
readonly type: ElementType;
|
|
65
|
+
protected deferReadyOnMount: boolean;
|
|
66
|
+
private selection;
|
|
67
|
+
private ready;
|
|
68
|
+
private failedFired;
|
|
69
|
+
private iframe;
|
|
70
|
+
private readonly frameOrigin;
|
|
71
|
+
private readonly unregisterChild;
|
|
72
|
+
private messageHandler;
|
|
73
|
+
private readyTimer;
|
|
74
|
+
constructor(args: CardElementArgs);
|
|
75
|
+
destroy(): void;
|
|
76
|
+
protected render(container: HTMLElement): void;
|
|
77
|
+
private onMessage;
|
|
78
|
+
private sendInit;
|
|
79
|
+
private clearReadyTimer;
|
|
80
|
+
}
|
|
81
|
+
declare function createCardElement(args: CardElementArgs): CardElement;
|
|
82
|
+
|
|
83
|
+
interface PaymentElementArgs {
|
|
84
|
+
clientSecret: string;
|
|
85
|
+
appearance: Appearance;
|
|
86
|
+
publishableKey: string;
|
|
87
|
+
apiBase: string;
|
|
88
|
+
environment: _snap_pay_types.Environment;
|
|
89
|
+
cardFrameUrl: string | undefined;
|
|
90
|
+
registerChild: (getSelection: () => SnapSelection | null) => () => void;
|
|
91
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
92
|
+
options: CreateElementOptions;
|
|
93
|
+
}
|
|
94
|
+
declare class PaymentElement extends BaseElement {
|
|
95
|
+
private readonly args;
|
|
96
|
+
readonly type: ElementType;
|
|
97
|
+
protected deferReadyOnMount: boolean;
|
|
98
|
+
private readonly resolvedAppearance;
|
|
99
|
+
private children;
|
|
100
|
+
constructor(args: PaymentElementArgs);
|
|
101
|
+
destroy(): void;
|
|
102
|
+
protected render(container: HTMLElement): void;
|
|
103
|
+
private mountChildren;
|
|
104
|
+
}
|
|
105
|
+
declare function createPaymentElement(args: PaymentElementArgs): PaymentElement;
|
|
106
|
+
|
|
107
|
+
interface ExpressCheckoutElementArgs {
|
|
108
|
+
clientSecret: string;
|
|
109
|
+
appearance: Appearance;
|
|
110
|
+
publishableKey: string;
|
|
111
|
+
apiBase: string;
|
|
112
|
+
environment?: _snap_pay_types.Environment;
|
|
113
|
+
cardFrameUrl?: string | undefined;
|
|
114
|
+
registerChild: (getSelection: () => SnapSelection | null) => () => void;
|
|
115
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
116
|
+
initialSession?: PublicSession;
|
|
117
|
+
options: CreateElementOptions;
|
|
118
|
+
}
|
|
119
|
+
declare class ExpressCheckoutElement extends BaseElement {
|
|
120
|
+
private readonly args;
|
|
121
|
+
readonly type: ElementType;
|
|
122
|
+
private selected;
|
|
123
|
+
private allowed;
|
|
124
|
+
private readonly resolvedAppearance;
|
|
125
|
+
private readonly unregisterChild;
|
|
126
|
+
constructor(args: ExpressCheckoutElementArgs);
|
|
127
|
+
destroy(): void;
|
|
128
|
+
protected render(container: HTMLElement): void;
|
|
129
|
+
private paint;
|
|
130
|
+
private renderButton;
|
|
131
|
+
}
|
|
132
|
+
declare function createExpressCheckoutElement(args: ExpressCheckoutElementArgs): ExpressCheckoutElement;
|
|
133
|
+
|
|
134
|
+
interface PaymentMethodSelectorArgs {
|
|
135
|
+
clientSecret: string;
|
|
136
|
+
appearance: Appearance;
|
|
137
|
+
publishableKey: string;
|
|
138
|
+
apiBase: string;
|
|
139
|
+
environment: _snap_pay_types.Environment;
|
|
140
|
+
cardFrameUrl: string | undefined;
|
|
141
|
+
registerChild: (getSelection: () => SnapSelection | null) => () => void;
|
|
142
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
143
|
+
options: CreateElementOptions;
|
|
144
|
+
}
|
|
145
|
+
declare class PaymentMethodSelector extends BaseElement {
|
|
146
|
+
private readonly args;
|
|
147
|
+
readonly type: ElementType;
|
|
148
|
+
protected deferReadyOnMount: boolean;
|
|
149
|
+
private readonly resolvedAppearance;
|
|
150
|
+
private walletChild;
|
|
151
|
+
private cardChild;
|
|
152
|
+
private activeTab;
|
|
153
|
+
private walletSlot;
|
|
154
|
+
private cardSlot;
|
|
155
|
+
private tabs;
|
|
156
|
+
private hasWallets;
|
|
157
|
+
private hasCard;
|
|
158
|
+
private session;
|
|
159
|
+
constructor(args: PaymentMethodSelectorArgs);
|
|
160
|
+
destroy(): void;
|
|
161
|
+
protected render(container: HTMLElement): void;
|
|
162
|
+
private mountUi;
|
|
163
|
+
private renderTab;
|
|
164
|
+
private applyTab;
|
|
165
|
+
}
|
|
166
|
+
declare function createPaymentMethodSelector(args: PaymentMethodSelectorArgs): PaymentMethodSelector;
|
|
167
|
+
|
|
168
|
+
interface BillingAddressElementArgs {
|
|
169
|
+
clientSecret: string;
|
|
170
|
+
appearance: Appearance;
|
|
171
|
+
publishableKey: string;
|
|
172
|
+
apiBase: string;
|
|
173
|
+
environment?: _snap_pay_types.Environment;
|
|
174
|
+
cardFrameUrl?: string | undefined;
|
|
175
|
+
registerChild: (getSelection: () => _snap_pay_types.SnapSelection | null) => () => void;
|
|
176
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
177
|
+
options: CreateElementOptions;
|
|
178
|
+
}
|
|
179
|
+
declare class BillingAddressElement extends BaseElement {
|
|
180
|
+
private readonly args;
|
|
181
|
+
readonly type: ElementType;
|
|
182
|
+
private value;
|
|
183
|
+
private readonly resolvedAppearance;
|
|
184
|
+
private readonly unregisterValue;
|
|
185
|
+
constructor(args: BillingAddressElementArgs);
|
|
186
|
+
destroy(): void;
|
|
187
|
+
getValue(): BillingAddressValue;
|
|
188
|
+
protected render(container: HTMLElement): void;
|
|
189
|
+
private renderField;
|
|
190
|
+
private isComplete;
|
|
191
|
+
}
|
|
192
|
+
declare function createBillingAddressElement(args: BillingAddressElementArgs): BillingAddressElement;
|
|
193
|
+
|
|
194
|
+
interface CustomerElementArgs {
|
|
195
|
+
clientSecret: string;
|
|
196
|
+
appearance: Appearance;
|
|
197
|
+
publishableKey: string;
|
|
198
|
+
apiBase: string;
|
|
199
|
+
environment?: _snap_pay_types.Environment;
|
|
200
|
+
cardFrameUrl?: string | undefined;
|
|
201
|
+
registerChild: (getSelection: () => _snap_pay_types.SnapSelection | null) => () => void;
|
|
202
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
203
|
+
options: CreateElementOptions;
|
|
204
|
+
}
|
|
205
|
+
declare class CustomerElement extends BaseElement {
|
|
206
|
+
private readonly args;
|
|
207
|
+
readonly type: ElementType;
|
|
208
|
+
private value;
|
|
209
|
+
private readonly resolvedAppearance;
|
|
210
|
+
private readonly unregisterValue;
|
|
211
|
+
constructor(args: CustomerElementArgs);
|
|
212
|
+
destroy(): void;
|
|
213
|
+
getValue(): CustomerValue;
|
|
214
|
+
protected render(container: HTMLElement): void;
|
|
215
|
+
private renderField;
|
|
216
|
+
private isComplete;
|
|
217
|
+
}
|
|
218
|
+
declare function createCustomerElement(args: CustomerElementArgs): CustomerElement;
|
|
219
|
+
|
|
220
|
+
interface OtpElementArgs {
|
|
221
|
+
clientSecret: string;
|
|
222
|
+
appearance: Appearance;
|
|
223
|
+
publishableKey: string;
|
|
224
|
+
apiBase: string;
|
|
225
|
+
environment?: _snap_pay_types.Environment;
|
|
226
|
+
cardFrameUrl?: string | undefined;
|
|
227
|
+
registerChild: (getSelection: () => _snap_pay_types.SnapSelection | null) => () => void;
|
|
228
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
229
|
+
options: CreateElementOptions;
|
|
230
|
+
}
|
|
231
|
+
declare class OtpElement extends BaseElement {
|
|
232
|
+
private readonly args;
|
|
233
|
+
readonly type: ElementType;
|
|
234
|
+
private digits;
|
|
235
|
+
private inputs;
|
|
236
|
+
private readonly length;
|
|
237
|
+
private readonly resolvedAppearance;
|
|
238
|
+
private readonly unregisterValue;
|
|
239
|
+
constructor(args: OtpElementArgs);
|
|
240
|
+
destroy(): void;
|
|
241
|
+
getValue(): OtpValue;
|
|
242
|
+
protected render(container: HTMLElement): void;
|
|
243
|
+
private onInput;
|
|
244
|
+
private onKeyDown;
|
|
245
|
+
private onPaste;
|
|
246
|
+
private isComplete;
|
|
247
|
+
}
|
|
248
|
+
declare function createOtpElement(args: OtpElementArgs): OtpElement;
|
|
249
|
+
|
|
250
|
+
interface QrElementArgs {
|
|
251
|
+
clientSecret: string;
|
|
252
|
+
appearance: Appearance;
|
|
253
|
+
publishableKey: string;
|
|
254
|
+
apiBase: string;
|
|
255
|
+
environment?: _snap_pay_types.Environment;
|
|
256
|
+
cardFrameUrl?: string | undefined;
|
|
257
|
+
registerChild: (getSelection: () => _snap_pay_types.SnapSelection | null) => () => void;
|
|
258
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
259
|
+
options: CreateElementOptions;
|
|
260
|
+
}
|
|
261
|
+
declare class QrElement extends BaseElement {
|
|
262
|
+
private readonly args;
|
|
263
|
+
readonly type: ElementType;
|
|
264
|
+
protected deferReadyOnMount: boolean;
|
|
265
|
+
private readonly resolvedAppearance;
|
|
266
|
+
constructor(args: QrElementArgs);
|
|
267
|
+
protected render(container: HTMLElement): void;
|
|
268
|
+
}
|
|
269
|
+
declare function createQrElement(args: QrElementArgs): QrElement;
|
|
270
|
+
|
|
271
|
+
interface ResolvedAppearance {
|
|
272
|
+
primaryColor: string;
|
|
273
|
+
borderRadius: string;
|
|
274
|
+
fontFamily: string;
|
|
275
|
+
theme: "light" | "dark";
|
|
276
|
+
background: string;
|
|
277
|
+
foreground: string;
|
|
278
|
+
border: string;
|
|
279
|
+
hoverBackground: string;
|
|
280
|
+
spacingUnit: string;
|
|
281
|
+
labelColor: string;
|
|
282
|
+
errorColor: string;
|
|
283
|
+
mutedColor: string;
|
|
284
|
+
}
|
|
285
|
+
declare function resolveAppearance(input: Appearance, forType?: ElementType): ResolvedAppearance;
|
|
286
|
+
declare function formInputStyle(a: ResolvedAppearance): Partial<CSSStyleDeclaration>;
|
|
287
|
+
declare function formLabelStyle(a: ResolvedAppearance): Partial<CSSStyleDeclaration>;
|
|
288
|
+
|
|
289
|
+
type CardBrand = "visa" | "mastercard" | "amex" | "discover" | "unknown";
|
|
290
|
+
declare function normalizeCardNumber(raw: string): string;
|
|
291
|
+
declare function luhnValid(cardNumber: string): boolean;
|
|
292
|
+
declare function detectBrand(cardNumber: string): CardBrand;
|
|
293
|
+
declare function formatCardNumber(raw: string): string;
|
|
294
|
+
declare function cvcLengthFor(brand: CardBrand): 3 | 4;
|
|
295
|
+
declare function cvcValid(cvc: string, brand: CardBrand): boolean;
|
|
296
|
+
declare function expiryValid(input: string, now?: number): boolean;
|
|
297
|
+
declare function formatExpiry(raw: string): string;
|
|
298
|
+
|
|
299
|
+
export { BaseElement, BillingAddressElement, type CardBrand, CardElement, CustomerElement, ExpressCheckoutElement, OtpElement, PaymentElement, PaymentMethodSelector, QrElement, type ResolvedAppearance, WalletElement, createBillingAddressElement, createCardElement, createCustomerElement, createExpressCheckoutElement, createOtpElement, createPaymentElement, createPaymentMethodSelector, createQrElement, createWalletElement, cvcLengthFor, cvcValid, detectBrand, expiryValid, formInputStyle, formLabelStyle, formatCardNumber, formatExpiry, luhnValid, normalizeCardNumber, resolveAppearance };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import * as _snap_pay_types from '@snap-pay/types';
|
|
2
|
+
import { SnapElementHandle, ElementType, ElementEventName, ElementEventHandler, ElementEventMap, Appearance, PublicSession, CreateElementOptions, Environment, SnapSelection, BillingAddressValue, CustomerValue, OtpValue } from '@snap-pay/types';
|
|
3
|
+
|
|
4
|
+
declare abstract class BaseElement implements SnapElementHandle {
|
|
5
|
+
abstract readonly type: ElementType;
|
|
6
|
+
private container;
|
|
7
|
+
private mounted;
|
|
8
|
+
private listeners;
|
|
9
|
+
mount(target: string | HTMLElement): void;
|
|
10
|
+
protected deferReadyOnMount: boolean;
|
|
11
|
+
unmount(): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
on<E extends ElementEventName>(event: E, handler: ElementEventHandler<E>): void;
|
|
14
|
+
off<E extends ElementEventName>(event: E, handler: ElementEventHandler<E>): void;
|
|
15
|
+
protected emit<E extends ElementEventName>(event: E, payload: ElementEventMap[E]): void;
|
|
16
|
+
protected abstract render(container: HTMLElement): void;
|
|
17
|
+
getValue(): unknown;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface WalletElementArgs {
|
|
21
|
+
clientSecret: string;
|
|
22
|
+
appearance: Appearance;
|
|
23
|
+
publishableKey: string;
|
|
24
|
+
apiBase: string;
|
|
25
|
+
environment?: _snap_pay_types.Environment;
|
|
26
|
+
cardFrameUrl?: string | undefined;
|
|
27
|
+
registerChild: (getSelection: () => _snap_pay_types.SnapSelection | null) => () => void;
|
|
28
|
+
registerValue: (type: _snap_pay_types.ElementType, getValue: () => unknown | null) => () => void;
|
|
29
|
+
initialSession?: PublicSession;
|
|
30
|
+
options: CreateElementOptions;
|
|
31
|
+
}
|
|
32
|
+
declare class WalletElement extends BaseElement {
|
|
33
|
+
private readonly args;
|
|
34
|
+
readonly type: ElementType;
|
|
35
|
+
private selected;
|
|
36
|
+
private allowed;
|
|
37
|
+
private readonly resolvedAppearance;
|
|
38
|
+
private buttons;
|
|
39
|
+
private renderTarget;
|
|
40
|
+
private readonly unregisterChild;
|
|
41
|
+
constructor(args: WalletElementArgs);
|
|
42
|
+
destroy(): void;
|
|
43
|
+
protected render(container: HTMLElement): void;
|
|
44
|
+
private renderButtons;
|
|
45
|
+
private renderProviderButton;
|
|
46
|
+
private select;
|
|
47
|
+
private buttonStyle;
|
|
48
|
+
}
|
|
49
|
+
declare function createWalletElement(args: WalletElementArgs): WalletElement;
|
|
50
|
+
|
|
51
|
+
interface CardElementArgs {
|
|
52
|
+
clientSecret: string;
|
|
53
|
+
appearance: Appearance;
|
|
54
|
+
publishableKey: string;
|
|
55
|
+
apiBase: string;
|
|
56
|
+
environment: Environment | undefined;
|
|
57
|
+
cardFrameUrl: string | undefined;
|
|
58
|
+
registerChild: (getSelection: () => SnapSelection | null) => () => void;
|
|
59
|
+
registerValue: (type: _snap_pay_types.ElementType, getValue: () => unknown | null) => () => void;
|
|
60
|
+
options: CreateElementOptions;
|
|
61
|
+
}
|
|
62
|
+
declare class CardElement extends BaseElement {
|
|
63
|
+
private readonly args;
|
|
64
|
+
readonly type: ElementType;
|
|
65
|
+
protected deferReadyOnMount: boolean;
|
|
66
|
+
private selection;
|
|
67
|
+
private ready;
|
|
68
|
+
private failedFired;
|
|
69
|
+
private iframe;
|
|
70
|
+
private readonly frameOrigin;
|
|
71
|
+
private readonly unregisterChild;
|
|
72
|
+
private messageHandler;
|
|
73
|
+
private readyTimer;
|
|
74
|
+
constructor(args: CardElementArgs);
|
|
75
|
+
destroy(): void;
|
|
76
|
+
protected render(container: HTMLElement): void;
|
|
77
|
+
private onMessage;
|
|
78
|
+
private sendInit;
|
|
79
|
+
private clearReadyTimer;
|
|
80
|
+
}
|
|
81
|
+
declare function createCardElement(args: CardElementArgs): CardElement;
|
|
82
|
+
|
|
83
|
+
interface PaymentElementArgs {
|
|
84
|
+
clientSecret: string;
|
|
85
|
+
appearance: Appearance;
|
|
86
|
+
publishableKey: string;
|
|
87
|
+
apiBase: string;
|
|
88
|
+
environment: _snap_pay_types.Environment;
|
|
89
|
+
cardFrameUrl: string | undefined;
|
|
90
|
+
registerChild: (getSelection: () => SnapSelection | null) => () => void;
|
|
91
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
92
|
+
options: CreateElementOptions;
|
|
93
|
+
}
|
|
94
|
+
declare class PaymentElement extends BaseElement {
|
|
95
|
+
private readonly args;
|
|
96
|
+
readonly type: ElementType;
|
|
97
|
+
protected deferReadyOnMount: boolean;
|
|
98
|
+
private readonly resolvedAppearance;
|
|
99
|
+
private children;
|
|
100
|
+
constructor(args: PaymentElementArgs);
|
|
101
|
+
destroy(): void;
|
|
102
|
+
protected render(container: HTMLElement): void;
|
|
103
|
+
private mountChildren;
|
|
104
|
+
}
|
|
105
|
+
declare function createPaymentElement(args: PaymentElementArgs): PaymentElement;
|
|
106
|
+
|
|
107
|
+
interface ExpressCheckoutElementArgs {
|
|
108
|
+
clientSecret: string;
|
|
109
|
+
appearance: Appearance;
|
|
110
|
+
publishableKey: string;
|
|
111
|
+
apiBase: string;
|
|
112
|
+
environment?: _snap_pay_types.Environment;
|
|
113
|
+
cardFrameUrl?: string | undefined;
|
|
114
|
+
registerChild: (getSelection: () => SnapSelection | null) => () => void;
|
|
115
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
116
|
+
initialSession?: PublicSession;
|
|
117
|
+
options: CreateElementOptions;
|
|
118
|
+
}
|
|
119
|
+
declare class ExpressCheckoutElement extends BaseElement {
|
|
120
|
+
private readonly args;
|
|
121
|
+
readonly type: ElementType;
|
|
122
|
+
private selected;
|
|
123
|
+
private allowed;
|
|
124
|
+
private readonly resolvedAppearance;
|
|
125
|
+
private readonly unregisterChild;
|
|
126
|
+
constructor(args: ExpressCheckoutElementArgs);
|
|
127
|
+
destroy(): void;
|
|
128
|
+
protected render(container: HTMLElement): void;
|
|
129
|
+
private paint;
|
|
130
|
+
private renderButton;
|
|
131
|
+
}
|
|
132
|
+
declare function createExpressCheckoutElement(args: ExpressCheckoutElementArgs): ExpressCheckoutElement;
|
|
133
|
+
|
|
134
|
+
interface PaymentMethodSelectorArgs {
|
|
135
|
+
clientSecret: string;
|
|
136
|
+
appearance: Appearance;
|
|
137
|
+
publishableKey: string;
|
|
138
|
+
apiBase: string;
|
|
139
|
+
environment: _snap_pay_types.Environment;
|
|
140
|
+
cardFrameUrl: string | undefined;
|
|
141
|
+
registerChild: (getSelection: () => SnapSelection | null) => () => void;
|
|
142
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
143
|
+
options: CreateElementOptions;
|
|
144
|
+
}
|
|
145
|
+
declare class PaymentMethodSelector extends BaseElement {
|
|
146
|
+
private readonly args;
|
|
147
|
+
readonly type: ElementType;
|
|
148
|
+
protected deferReadyOnMount: boolean;
|
|
149
|
+
private readonly resolvedAppearance;
|
|
150
|
+
private walletChild;
|
|
151
|
+
private cardChild;
|
|
152
|
+
private activeTab;
|
|
153
|
+
private walletSlot;
|
|
154
|
+
private cardSlot;
|
|
155
|
+
private tabs;
|
|
156
|
+
private hasWallets;
|
|
157
|
+
private hasCard;
|
|
158
|
+
private session;
|
|
159
|
+
constructor(args: PaymentMethodSelectorArgs);
|
|
160
|
+
destroy(): void;
|
|
161
|
+
protected render(container: HTMLElement): void;
|
|
162
|
+
private mountUi;
|
|
163
|
+
private renderTab;
|
|
164
|
+
private applyTab;
|
|
165
|
+
}
|
|
166
|
+
declare function createPaymentMethodSelector(args: PaymentMethodSelectorArgs): PaymentMethodSelector;
|
|
167
|
+
|
|
168
|
+
interface BillingAddressElementArgs {
|
|
169
|
+
clientSecret: string;
|
|
170
|
+
appearance: Appearance;
|
|
171
|
+
publishableKey: string;
|
|
172
|
+
apiBase: string;
|
|
173
|
+
environment?: _snap_pay_types.Environment;
|
|
174
|
+
cardFrameUrl?: string | undefined;
|
|
175
|
+
registerChild: (getSelection: () => _snap_pay_types.SnapSelection | null) => () => void;
|
|
176
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
177
|
+
options: CreateElementOptions;
|
|
178
|
+
}
|
|
179
|
+
declare class BillingAddressElement extends BaseElement {
|
|
180
|
+
private readonly args;
|
|
181
|
+
readonly type: ElementType;
|
|
182
|
+
private value;
|
|
183
|
+
private readonly resolvedAppearance;
|
|
184
|
+
private readonly unregisterValue;
|
|
185
|
+
constructor(args: BillingAddressElementArgs);
|
|
186
|
+
destroy(): void;
|
|
187
|
+
getValue(): BillingAddressValue;
|
|
188
|
+
protected render(container: HTMLElement): void;
|
|
189
|
+
private renderField;
|
|
190
|
+
private isComplete;
|
|
191
|
+
}
|
|
192
|
+
declare function createBillingAddressElement(args: BillingAddressElementArgs): BillingAddressElement;
|
|
193
|
+
|
|
194
|
+
interface CustomerElementArgs {
|
|
195
|
+
clientSecret: string;
|
|
196
|
+
appearance: Appearance;
|
|
197
|
+
publishableKey: string;
|
|
198
|
+
apiBase: string;
|
|
199
|
+
environment?: _snap_pay_types.Environment;
|
|
200
|
+
cardFrameUrl?: string | undefined;
|
|
201
|
+
registerChild: (getSelection: () => _snap_pay_types.SnapSelection | null) => () => void;
|
|
202
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
203
|
+
options: CreateElementOptions;
|
|
204
|
+
}
|
|
205
|
+
declare class CustomerElement extends BaseElement {
|
|
206
|
+
private readonly args;
|
|
207
|
+
readonly type: ElementType;
|
|
208
|
+
private value;
|
|
209
|
+
private readonly resolvedAppearance;
|
|
210
|
+
private readonly unregisterValue;
|
|
211
|
+
constructor(args: CustomerElementArgs);
|
|
212
|
+
destroy(): void;
|
|
213
|
+
getValue(): CustomerValue;
|
|
214
|
+
protected render(container: HTMLElement): void;
|
|
215
|
+
private renderField;
|
|
216
|
+
private isComplete;
|
|
217
|
+
}
|
|
218
|
+
declare function createCustomerElement(args: CustomerElementArgs): CustomerElement;
|
|
219
|
+
|
|
220
|
+
interface OtpElementArgs {
|
|
221
|
+
clientSecret: string;
|
|
222
|
+
appearance: Appearance;
|
|
223
|
+
publishableKey: string;
|
|
224
|
+
apiBase: string;
|
|
225
|
+
environment?: _snap_pay_types.Environment;
|
|
226
|
+
cardFrameUrl?: string | undefined;
|
|
227
|
+
registerChild: (getSelection: () => _snap_pay_types.SnapSelection | null) => () => void;
|
|
228
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
229
|
+
options: CreateElementOptions;
|
|
230
|
+
}
|
|
231
|
+
declare class OtpElement extends BaseElement {
|
|
232
|
+
private readonly args;
|
|
233
|
+
readonly type: ElementType;
|
|
234
|
+
private digits;
|
|
235
|
+
private inputs;
|
|
236
|
+
private readonly length;
|
|
237
|
+
private readonly resolvedAppearance;
|
|
238
|
+
private readonly unregisterValue;
|
|
239
|
+
constructor(args: OtpElementArgs);
|
|
240
|
+
destroy(): void;
|
|
241
|
+
getValue(): OtpValue;
|
|
242
|
+
protected render(container: HTMLElement): void;
|
|
243
|
+
private onInput;
|
|
244
|
+
private onKeyDown;
|
|
245
|
+
private onPaste;
|
|
246
|
+
private isComplete;
|
|
247
|
+
}
|
|
248
|
+
declare function createOtpElement(args: OtpElementArgs): OtpElement;
|
|
249
|
+
|
|
250
|
+
interface QrElementArgs {
|
|
251
|
+
clientSecret: string;
|
|
252
|
+
appearance: Appearance;
|
|
253
|
+
publishableKey: string;
|
|
254
|
+
apiBase: string;
|
|
255
|
+
environment?: _snap_pay_types.Environment;
|
|
256
|
+
cardFrameUrl?: string | undefined;
|
|
257
|
+
registerChild: (getSelection: () => _snap_pay_types.SnapSelection | null) => () => void;
|
|
258
|
+
registerValue: (type: ElementType, getValue: () => unknown | null) => () => void;
|
|
259
|
+
options: CreateElementOptions;
|
|
260
|
+
}
|
|
261
|
+
declare class QrElement extends BaseElement {
|
|
262
|
+
private readonly args;
|
|
263
|
+
readonly type: ElementType;
|
|
264
|
+
protected deferReadyOnMount: boolean;
|
|
265
|
+
private readonly resolvedAppearance;
|
|
266
|
+
constructor(args: QrElementArgs);
|
|
267
|
+
protected render(container: HTMLElement): void;
|
|
268
|
+
}
|
|
269
|
+
declare function createQrElement(args: QrElementArgs): QrElement;
|
|
270
|
+
|
|
271
|
+
interface ResolvedAppearance {
|
|
272
|
+
primaryColor: string;
|
|
273
|
+
borderRadius: string;
|
|
274
|
+
fontFamily: string;
|
|
275
|
+
theme: "light" | "dark";
|
|
276
|
+
background: string;
|
|
277
|
+
foreground: string;
|
|
278
|
+
border: string;
|
|
279
|
+
hoverBackground: string;
|
|
280
|
+
spacingUnit: string;
|
|
281
|
+
labelColor: string;
|
|
282
|
+
errorColor: string;
|
|
283
|
+
mutedColor: string;
|
|
284
|
+
}
|
|
285
|
+
declare function resolveAppearance(input: Appearance, forType?: ElementType): ResolvedAppearance;
|
|
286
|
+
declare function formInputStyle(a: ResolvedAppearance): Partial<CSSStyleDeclaration>;
|
|
287
|
+
declare function formLabelStyle(a: ResolvedAppearance): Partial<CSSStyleDeclaration>;
|
|
288
|
+
|
|
289
|
+
type CardBrand = "visa" | "mastercard" | "amex" | "discover" | "unknown";
|
|
290
|
+
declare function normalizeCardNumber(raw: string): string;
|
|
291
|
+
declare function luhnValid(cardNumber: string): boolean;
|
|
292
|
+
declare function detectBrand(cardNumber: string): CardBrand;
|
|
293
|
+
declare function formatCardNumber(raw: string): string;
|
|
294
|
+
declare function cvcLengthFor(brand: CardBrand): 3 | 4;
|
|
295
|
+
declare function cvcValid(cvc: string, brand: CardBrand): boolean;
|
|
296
|
+
declare function expiryValid(input: string, now?: number): boolean;
|
|
297
|
+
declare function formatExpiry(raw: string): string;
|
|
298
|
+
|
|
299
|
+
export { BaseElement, BillingAddressElement, type CardBrand, CardElement, CustomerElement, ExpressCheckoutElement, OtpElement, PaymentElement, PaymentMethodSelector, QrElement, type ResolvedAppearance, WalletElement, createBillingAddressElement, createCardElement, createCustomerElement, createExpressCheckoutElement, createOtpElement, createPaymentElement, createPaymentMethodSelector, createQrElement, createWalletElement, cvcLengthFor, cvcValid, detectBrand, expiryValid, formInputStyle, formLabelStyle, formatCardNumber, formatExpiry, luhnValid, normalizeCardNumber, resolveAppearance };
|