@idonatedev/idonate-sdk 1.1.0-dev8 → 1.2.0-dev0
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 +308 -7
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +2 -6
- package/dist/esm/apple-pay.d.ts +12 -0
- package/dist/esm/apple-pay.js +74 -0
- package/dist/esm/cloudflare-challenge-handler.d.ts +5 -0
- package/dist/esm/cloudflare-challenge-handler.js +77 -0
- package/dist/esm/config-handler.d.ts +22 -0
- package/dist/esm/config-handler.js +47 -0
- package/dist/esm/constants.d.ts +18 -0
- package/dist/esm/constants.js +81 -0
- package/dist/esm/google-pay.d.ts +18 -0
- package/dist/esm/google-pay.js +140 -0
- package/dist/esm/idonate-client.d.ts +32 -0
- package/dist/esm/idonate-client.js +294 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/recaptcha.d.ts +12 -0
- package/dist/esm/recaptcha.js +89 -0
- package/dist/esm/shared.d.ts +4 -0
- package/dist/esm/shared.js +21 -0
- package/dist/esm/test-utils.d.ts +81 -0
- package/dist/esm/test-utils.js +94 -0
- package/dist/esm/tokenize/CardConnectTokenizer.d.ts +51 -0
- package/dist/esm/tokenize/CardConnectTokenizer.js +712 -0
- package/dist/esm/tokenize/PayPalTokenizer.d.ts +77 -0
- package/dist/esm/tokenize/PayPalTokenizer.js +268 -0
- package/dist/esm/tokenize/SpreedlyTokenizer.d.ts +92 -0
- package/dist/esm/tokenize/SpreedlyTokenizer.js +1140 -0
- package/dist/esm/tokenize/Tokenizer.d.ts +37 -0
- package/dist/esm/tokenize/Tokenizer.js +150 -0
- package/dist/esm/tokenize/iats.d.ts +3 -0
- package/dist/esm/tokenize/iats.js +48 -0
- package/dist/esm/tokenize/index.d.ts +7 -0
- package/dist/esm/tokenize/index.js +7 -0
- package/dist/esm/tokenize/spreedly-secure.d.ts +8 -0
- package/dist/esm/tokenize/spreedly-secure.js +40 -0
- package/dist/esm/tokenize/styles.d.ts +4 -0
- package/dist/esm/tokenize/styles.js +46 -0
- package/dist/esm/tokenize/tokenizer-constants.d.ts +62 -0
- package/dist/esm/tokenize/tokenizer-constants.js +62 -0
- package/dist/esm/tokenize/tokenizer-utils.d.ts +19 -0
- package/dist/esm/tokenize/tokenizer-utils.js +139 -0
- package/dist/esm/tokenize/types.d.ts +146 -0
- package/dist/esm/tokenize/types.js +26 -0
- package/dist/esm/typeAdapters.d.ts +29 -0
- package/dist/esm/typeAdapters.js +189 -0
- package/dist/esm/types.d.ts +378 -0
- package/dist/esm/types.js +14 -0
- package/dist/esm/util.d.ts +17 -0
- package/dist/esm/util.js +113 -0
- package/dist/idonate-client.d.ts +6 -2
- package/dist/idonate-client.js +40 -2
- package/dist/shared.d.ts +2 -1
- package/dist/shared.js +9 -0
- package/dist/tokenize/CardConnectTokenizer.d.ts +1 -0
- package/dist/tokenize/CardConnectTokenizer.js +127 -104
- package/dist/tokenize/PayPalTokenizer.d.ts +77 -0
- package/dist/tokenize/PayPalTokenizer.js +272 -0
- package/dist/tokenize/SpreedlyTokenizer.d.ts +1 -0
- package/dist/tokenize/SpreedlyTokenizer.js +276 -135
- package/dist/tokenize/Tokenizer.js +6 -2
- package/dist/tokenize/index.d.ts +1 -0
- package/dist/tokenize/index.js +3 -1
- package/dist/tokenize/styles.d.ts +1 -0
- package/dist/tokenize/styles.js +9 -0
- package/dist/tokenize/tokenizer-utils.js +1 -1
- package/dist/tokenize/types.d.ts +6 -7
- package/dist/typeAdapters.js +3 -2
- package/dist/types.d.ts +16 -5
- package/package.json +14 -3
- package/umd/idonate-sdk.js +1 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Tokenizer } from './Tokenizer';
|
|
2
|
+
import { PaymentData, PaymentToken, ValidationResult, PaymentGateway, TokenizerContainer } from './types';
|
|
3
|
+
import ConfigHandler from '../config-handler';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
paypal?: {
|
|
7
|
+
Buttons: (options: PayPalButtonOptions) => PayPalButtonsInstance;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
interface PayPalButtonOptions {
|
|
12
|
+
fundingSource?: string;
|
|
13
|
+
createOrder: () => Promise<string>;
|
|
14
|
+
onApprove: (data: PayPalApproveData) => Promise<void>;
|
|
15
|
+
onCancel?: (data: any) => void;
|
|
16
|
+
onError?: (err: any) => void;
|
|
17
|
+
style?: {
|
|
18
|
+
layout?: 'vertical' | 'horizontal';
|
|
19
|
+
color?: 'gold' | 'blue' | 'silver' | 'white' | 'black';
|
|
20
|
+
shape?: 'rect' | 'pill';
|
|
21
|
+
label?: 'paypal' | 'checkout' | 'buynow' | 'pay';
|
|
22
|
+
height?: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
interface PayPalButtonsInstance {
|
|
26
|
+
render: (selector: string | HTMLElement) => Promise<void>;
|
|
27
|
+
close: () => void;
|
|
28
|
+
}
|
|
29
|
+
interface PayPalApproveData {
|
|
30
|
+
orderID: string;
|
|
31
|
+
payerID?: string;
|
|
32
|
+
facilitatorAccessToken?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare class PayPalTokenizer extends Tokenizer {
|
|
35
|
+
private gateway;
|
|
36
|
+
private containerId;
|
|
37
|
+
private configContext;
|
|
38
|
+
private isReady;
|
|
39
|
+
private containerEl?;
|
|
40
|
+
private paypalButtonContainer?;
|
|
41
|
+
private cachedToken?;
|
|
42
|
+
private currency;
|
|
43
|
+
private amount?;
|
|
44
|
+
private enableVenmo;
|
|
45
|
+
private locale;
|
|
46
|
+
private clientId;
|
|
47
|
+
private sandboxMode;
|
|
48
|
+
private organizationId;
|
|
49
|
+
private embedId;
|
|
50
|
+
private clientConfig;
|
|
51
|
+
private paymentTransactionId?;
|
|
52
|
+
private paymentMethodId?;
|
|
53
|
+
private constructor();
|
|
54
|
+
static create(gateway: PaymentGateway, container: TokenizerContainer, config: {
|
|
55
|
+
organizationId: string;
|
|
56
|
+
embedId: string;
|
|
57
|
+
clientConfig: ConfigHandler;
|
|
58
|
+
}): Promise<PayPalTokenizer>;
|
|
59
|
+
private init;
|
|
60
|
+
private loadPayPalSDK;
|
|
61
|
+
private waitForPayPalGlobal;
|
|
62
|
+
private renderButtons;
|
|
63
|
+
private renderPayPalButtons;
|
|
64
|
+
private createOrder;
|
|
65
|
+
private handleApprove;
|
|
66
|
+
private handleCancel;
|
|
67
|
+
private handleError;
|
|
68
|
+
tokenize(paymentData: PaymentData): Promise<PaymentToken>;
|
|
69
|
+
validate(): Promise<ValidationResult>;
|
|
70
|
+
clear(): void;
|
|
71
|
+
focus(field: 'cardNumber' | 'cvv' | 'expiry' | 'routingNumber' | 'accountNumber'): void;
|
|
72
|
+
destroy(): void;
|
|
73
|
+
hasToken(): boolean;
|
|
74
|
+
getToken(): PaymentToken | null;
|
|
75
|
+
get tokenizationMode(): 'auto' | 'manual';
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Tokenizer } from './Tokenizer';
|
|
11
|
+
import { TokenizationError, } from './types';
|
|
12
|
+
const PAYPAL_SDK_URL = 'https://www.paypal.com/sdk/js';
|
|
13
|
+
const PAYPAL_SCRIPT_ID = 'paypal-sdk-script';
|
|
14
|
+
const INIT_TIMEOUT = 10000;
|
|
15
|
+
export class PayPalTokenizer extends Tokenizer {
|
|
16
|
+
constructor(gateway, containerId, config, configContext) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
super();
|
|
19
|
+
this.gateway = gateway;
|
|
20
|
+
this.containerId = containerId;
|
|
21
|
+
this.configContext = configContext;
|
|
22
|
+
this.isReady = false;
|
|
23
|
+
this.mode = 'credit_card';
|
|
24
|
+
const gatewayConfig = gateway.config;
|
|
25
|
+
if (!(gatewayConfig === null || gatewayConfig === void 0 ? void 0 : gatewayConfig.client_id)) {
|
|
26
|
+
throw new Error('PayPal gateway configuration missing client_id');
|
|
27
|
+
}
|
|
28
|
+
this.clientId = gatewayConfig.client_id;
|
|
29
|
+
this.sandboxMode = (_a = gatewayConfig.sandbox_mode) !== null && _a !== void 0 ? _a : false;
|
|
30
|
+
this.currency = config.currency || 'USD';
|
|
31
|
+
this.amount = config.amount;
|
|
32
|
+
this.enableVenmo = (_b = config.enableVenmo) !== null && _b !== void 0 ? _b : true;
|
|
33
|
+
this.locale = config.locale || 'en_US';
|
|
34
|
+
this.organizationId = configContext.organizationId;
|
|
35
|
+
this.embedId = configContext.embedId;
|
|
36
|
+
this.clientConfig = configContext.clientConfig;
|
|
37
|
+
}
|
|
38
|
+
static create(gateway, container, config) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const tokenizer = new PayPalTokenizer(gateway, container.containerId, container, config);
|
|
41
|
+
yield tokenizer.init();
|
|
42
|
+
return tokenizer;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
init() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
this.containerEl = document.getElementById(this.containerId);
|
|
48
|
+
if (!this.containerEl) {
|
|
49
|
+
throw new Error(`Container element not found: ${this.containerId}`);
|
|
50
|
+
}
|
|
51
|
+
this.containerEl.innerHTML = '';
|
|
52
|
+
Object.assign(this.containerEl.style, {
|
|
53
|
+
display: 'flex',
|
|
54
|
+
flexDirection: 'column',
|
|
55
|
+
gap: '0.5rem',
|
|
56
|
+
alignItems: 'stretch',
|
|
57
|
+
});
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const timeout = setTimeout(() => {
|
|
60
|
+
reject(new Error('PayPal SDK initialization timeout'));
|
|
61
|
+
}, INIT_TIMEOUT);
|
|
62
|
+
this.loadPayPalSDK()
|
|
63
|
+
.then(() => {
|
|
64
|
+
clearTimeout(timeout);
|
|
65
|
+
return this.renderButtons();
|
|
66
|
+
})
|
|
67
|
+
.then(() => {
|
|
68
|
+
this.isReady = true;
|
|
69
|
+
this.emit('ready');
|
|
70
|
+
resolve();
|
|
71
|
+
})
|
|
72
|
+
.catch((error) => {
|
|
73
|
+
clearTimeout(timeout);
|
|
74
|
+
this.emit('error', {
|
|
75
|
+
message: 'Failed to initialize PayPal',
|
|
76
|
+
code: 'INIT_FAILED',
|
|
77
|
+
details: error,
|
|
78
|
+
});
|
|
79
|
+
reject(error);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
loadPayPalSDK() {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
if (window.paypal) {
|
|
87
|
+
return Promise.resolve();
|
|
88
|
+
}
|
|
89
|
+
if (document.getElementById(PAYPAL_SCRIPT_ID)) {
|
|
90
|
+
return this.waitForPayPalGlobal();
|
|
91
|
+
}
|
|
92
|
+
const params = new URLSearchParams({
|
|
93
|
+
'client-id': this.clientId,
|
|
94
|
+
currency: this.currency,
|
|
95
|
+
intent: 'capture',
|
|
96
|
+
});
|
|
97
|
+
const disabledFunding = ['card', 'paylater'];
|
|
98
|
+
if (this.enableVenmo) {
|
|
99
|
+
params.set('enable-funding', 'venmo');
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
disabledFunding.push('venmo');
|
|
103
|
+
}
|
|
104
|
+
params.set('disable-funding', disabledFunding.join(','));
|
|
105
|
+
const script = document.createElement('script');
|
|
106
|
+
script.id = PAYPAL_SCRIPT_ID;
|
|
107
|
+
script.src = `${PAYPAL_SDK_URL}?${params.toString()}`;
|
|
108
|
+
script.async = true;
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
script.onload = () => {
|
|
111
|
+
this.waitForPayPalGlobal().then(resolve).catch(reject);
|
|
112
|
+
};
|
|
113
|
+
script.onerror = () => {
|
|
114
|
+
reject(new Error('Failed to load PayPal SDK'));
|
|
115
|
+
};
|
|
116
|
+
document.head.appendChild(script);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
waitForPayPalGlobal() {
|
|
121
|
+
return __awaiter(this, arguments, void 0, function* (timeout = 5000) {
|
|
122
|
+
const startTime = Date.now();
|
|
123
|
+
while (Date.now() - startTime < timeout) {
|
|
124
|
+
if (window.paypal) {
|
|
125
|
+
return Promise.resolve();
|
|
126
|
+
}
|
|
127
|
+
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
128
|
+
}
|
|
129
|
+
throw new Error('Timeout waiting for PayPal SDK to load');
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
renderButtons() {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
if (!window.paypal) {
|
|
135
|
+
throw new Error('PayPal SDK not loaded');
|
|
136
|
+
}
|
|
137
|
+
if (!this.containerEl) {
|
|
138
|
+
throw new Error('Container element not found');
|
|
139
|
+
}
|
|
140
|
+
this.paypalButtonContainer = document.createElement('div');
|
|
141
|
+
this.paypalButtonContainer.id = `${this.containerId}-buttons`;
|
|
142
|
+
this.paypalButtonContainer.style.minHeight = '40px';
|
|
143
|
+
this.containerEl.appendChild(this.paypalButtonContainer);
|
|
144
|
+
yield this.renderPayPalButtons();
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
renderPayPalButtons() {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
if (!window.paypal || !this.paypalButtonContainer) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const button = window.paypal.Buttons({
|
|
153
|
+
createOrder: () => this.createOrder(),
|
|
154
|
+
onApprove: (data) => this.handleApprove(data),
|
|
155
|
+
onCancel: (data) => this.handleCancel(data),
|
|
156
|
+
onError: (err) => this.handleError(err, 'PayPal error'),
|
|
157
|
+
style: {
|
|
158
|
+
layout: 'vertical',
|
|
159
|
+
shape: 'rect',
|
|
160
|
+
height: 40,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
yield button.render(this.paypalButtonContainer);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
createOrder() {
|
|
167
|
+
const endpoint = `${this.clientConfig.embedApiBaseUrl}/payment/paypal/create-order`;
|
|
168
|
+
const requestBody = {
|
|
169
|
+
payment_gateway_id: this.gateway.id,
|
|
170
|
+
currency: this.currency,
|
|
171
|
+
};
|
|
172
|
+
if (this.amount !== undefined) {
|
|
173
|
+
requestBody.amount = this.amount;
|
|
174
|
+
}
|
|
175
|
+
return fetch(endpoint, {
|
|
176
|
+
method: 'POST',
|
|
177
|
+
headers: {
|
|
178
|
+
'Content-Type': 'application/json',
|
|
179
|
+
},
|
|
180
|
+
body: JSON.stringify(requestBody),
|
|
181
|
+
})
|
|
182
|
+
.then((response) => {
|
|
183
|
+
if (!response.ok) {
|
|
184
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
185
|
+
}
|
|
186
|
+
return response.json();
|
|
187
|
+
})
|
|
188
|
+
.then((data) => {
|
|
189
|
+
if (!data.orderId) {
|
|
190
|
+
throw new Error('Order creation failed: missing orderId');
|
|
191
|
+
}
|
|
192
|
+
this.paymentTransactionId = data.payment_transaction_id;
|
|
193
|
+
this.paymentMethodId = data.payment_method_id;
|
|
194
|
+
return data.orderId;
|
|
195
|
+
})
|
|
196
|
+
.catch((error) => {
|
|
197
|
+
this.handleError(error, 'Order creation failed');
|
|
198
|
+
throw error;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
handleApprove(data) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
const token = {
|
|
204
|
+
token: data.orderID,
|
|
205
|
+
lastFour: data.orderID.slice(-4),
|
|
206
|
+
provider: 'paypal_checkout',
|
|
207
|
+
paymentMethodId: this.paymentMethodId,
|
|
208
|
+
paymentTransactionId: this.paymentTransactionId,
|
|
209
|
+
};
|
|
210
|
+
this.cachedToken = token;
|
|
211
|
+
this.emit('tokenReady', token);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
handleCancel(data) {
|
|
215
|
+
this.emit('error', {
|
|
216
|
+
message: 'Payment cancelled by user',
|
|
217
|
+
code: 'USER_CANCELLED',
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
handleError(error, context) {
|
|
221
|
+
const errorMessage = (error === null || error === void 0 ? void 0 : error.message) || (error === null || error === void 0 ? void 0 : error.toString()) || 'Unknown error';
|
|
222
|
+
this.emit('error', {
|
|
223
|
+
message: `${context}: ${errorMessage}`,
|
|
224
|
+
code: (error === null || error === void 0 ? void 0 : error.code) || 'PAYPAL_ERROR',
|
|
225
|
+
details: error,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
tokenize(paymentData) {
|
|
229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
if (!this.isReady) {
|
|
231
|
+
throw new Error('Tokenizer not initialized');
|
|
232
|
+
}
|
|
233
|
+
if (this.cachedToken) {
|
|
234
|
+
return this.cachedToken;
|
|
235
|
+
}
|
|
236
|
+
throw new TokenizationError('No PayPal order approved. User must click PayPal or Venmo button to complete payment.', 'NO_TOKEN');
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
validate() {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
return {
|
|
242
|
+
isValid: true,
|
|
243
|
+
errors: [],
|
|
244
|
+
};
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
clear() {
|
|
248
|
+
this.cachedToken = undefined;
|
|
249
|
+
}
|
|
250
|
+
focus(field) {
|
|
251
|
+
}
|
|
252
|
+
destroy() {
|
|
253
|
+
if (this.containerEl) {
|
|
254
|
+
this.containerEl.innerHTML = '';
|
|
255
|
+
}
|
|
256
|
+
this.eventHandlers.clear();
|
|
257
|
+
this.cachedToken = undefined;
|
|
258
|
+
}
|
|
259
|
+
hasToken() {
|
|
260
|
+
return !!this.cachedToken;
|
|
261
|
+
}
|
|
262
|
+
getToken() {
|
|
263
|
+
return this.cachedToken || null;
|
|
264
|
+
}
|
|
265
|
+
get tokenizationMode() {
|
|
266
|
+
return 'auto';
|
|
267
|
+
}
|
|
268
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Tokenizer } from './Tokenizer';
|
|
2
|
+
import { PaymentData, PaymentToken, ValidationResult, PaymentGateway, TokenizerContainer } from './types';
|
|
3
|
+
import { ACHAccount, Address, Contact, CreditCard, SpreedlyInstance } from '../types';
|
|
4
|
+
import ConfigHandler from '../config-handler';
|
|
5
|
+
export declare class SpreedlyTokenizer extends Tokenizer {
|
|
6
|
+
private environmentKey;
|
|
7
|
+
private containerId;
|
|
8
|
+
private layout;
|
|
9
|
+
private spreedly;
|
|
10
|
+
private isReady;
|
|
11
|
+
private currentValidationState;
|
|
12
|
+
private mergedStyles;
|
|
13
|
+
private expiryEl?;
|
|
14
|
+
private numberEl;
|
|
15
|
+
private cvvEl;
|
|
16
|
+
private expiryId;
|
|
17
|
+
private containerEl?;
|
|
18
|
+
private organizationId;
|
|
19
|
+
private embedId;
|
|
20
|
+
private clientConfig;
|
|
21
|
+
private bankCountry;
|
|
22
|
+
private routingNumberEl?;
|
|
23
|
+
private accountNumberEl?;
|
|
24
|
+
private accountTypeEl?;
|
|
25
|
+
private institutionNumberEl?;
|
|
26
|
+
private transitNumberEl?;
|
|
27
|
+
private enableTestMode;
|
|
28
|
+
private constructor();
|
|
29
|
+
static create(gateway: PaymentGateway, container: TokenizerContainer, config: {
|
|
30
|
+
organizationId: string;
|
|
31
|
+
embedId: string;
|
|
32
|
+
clientConfig: ConfigHandler;
|
|
33
|
+
}): Promise<SpreedlyTokenizer>;
|
|
34
|
+
private init;
|
|
35
|
+
tokenize(paymentData: PaymentData): Promise<PaymentToken>;
|
|
36
|
+
private tokenizeCardInternal;
|
|
37
|
+
private createCanadianBankAccountFields;
|
|
38
|
+
private tokenizeBankAccountInternal;
|
|
39
|
+
validate(): Promise<ValidationResult>;
|
|
40
|
+
private validateCardInternal;
|
|
41
|
+
private validateBankAccountInternal;
|
|
42
|
+
private applyUnifiedStyles;
|
|
43
|
+
private stylesToCssString;
|
|
44
|
+
clear(): void;
|
|
45
|
+
focus(field: 'cardNumber' | 'cvv' | 'expiry' | 'routingNumber' | 'accountNumber'): void;
|
|
46
|
+
destroy(): void;
|
|
47
|
+
hasToken(): boolean;
|
|
48
|
+
getToken(): PaymentToken | null;
|
|
49
|
+
get tokenizationMode(): 'auto' | 'manual';
|
|
50
|
+
private updateOverallValidation;
|
|
51
|
+
private handleFieldEvent;
|
|
52
|
+
private createInternalElements;
|
|
53
|
+
private createCreditCardFields;
|
|
54
|
+
private createBankAccountFields;
|
|
55
|
+
private createUSBankAccountFields;
|
|
56
|
+
private updateBankAccountValidation;
|
|
57
|
+
private validateExpiry;
|
|
58
|
+
private applyErrorStyles;
|
|
59
|
+
private static ensureSpreedlyLoaded;
|
|
60
|
+
private static loadScript;
|
|
61
|
+
private static waitForGlobal;
|
|
62
|
+
static tokenizeBankAccount(data: {
|
|
63
|
+
contact: Partial<Contact> & ({
|
|
64
|
+
firstName: string;
|
|
65
|
+
lastName: string;
|
|
66
|
+
} | {
|
|
67
|
+
fullName: string;
|
|
68
|
+
});
|
|
69
|
+
address: Partial<Address>;
|
|
70
|
+
account: Partial<ACHAccount> & Pick<ACHAccount, 'accountNumber' | 'routingNumber'>;
|
|
71
|
+
}, config: ConfigHandler): Promise<string>;
|
|
72
|
+
static tokenizeCreditCard(data: {
|
|
73
|
+
contact: Partial<Contact> & ({
|
|
74
|
+
firstName: string;
|
|
75
|
+
lastName: string;
|
|
76
|
+
} | {
|
|
77
|
+
fullName: string;
|
|
78
|
+
});
|
|
79
|
+
address: Partial<Address>;
|
|
80
|
+
card: CreditCard;
|
|
81
|
+
}, config: ConfigHandler): Promise<string>;
|
|
82
|
+
static tokenizePayPal(data: {
|
|
83
|
+
contact: Contact;
|
|
84
|
+
address: Address;
|
|
85
|
+
}, config: ConfigHandler): Promise<string>;
|
|
86
|
+
}
|
|
87
|
+
declare global {
|
|
88
|
+
interface Window {
|
|
89
|
+
Spreedly: SpreedlyInstance;
|
|
90
|
+
SpreedlyPaymentFrame: new () => SpreedlyInstance;
|
|
91
|
+
}
|
|
92
|
+
}
|