@idonatedev/idonate-sdk 1.2.0-dev2 → 1.2.0-dev21
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/constants.js +11 -2
- package/dist/esm/constants.js +11 -2
- package/dist/esm/idonate-client.js +18 -8
- package/dist/esm/recaptcha.d.ts +1 -0
- package/dist/esm/recaptcha.js +26 -2
- package/dist/esm/shared.js +9 -1
- package/dist/esm/tokenize/CardConnectTokenizer.d.ts +8 -1
- package/dist/esm/tokenize/CardConnectTokenizer.js +353 -104
- package/dist/esm/tokenize/PayPalTokenizer.d.ts +6 -0
- package/dist/esm/tokenize/PayPalTokenizer.js +66 -16
- package/dist/esm/tokenize/SpreedlyTokenizer.d.ts +23 -1
- package/dist/esm/tokenize/SpreedlyTokenizer.js +330 -151
- package/dist/esm/tokenize/Tokenizer.d.ts +6 -2
- package/dist/esm/tokenize/Tokenizer.js +24 -8
- package/dist/esm/tokenize/gateway-utils.d.ts +2 -0
- package/dist/esm/tokenize/gateway-utils.js +27 -0
- package/dist/esm/tokenize/index.d.ts +3 -2
- package/dist/esm/tokenize/index.js +1 -0
- package/dist/esm/tokenize/spreedly-secure.js +6 -2
- package/dist/esm/tokenize/styles.d.ts +1 -1
- package/dist/esm/tokenize/styles.js +20 -1
- package/dist/esm/tokenize/tokenizer-constants.d.ts +1 -0
- package/dist/esm/tokenize/tokenizer-constants.js +1 -0
- package/dist/esm/tokenize/tokenizer-utils.d.ts +4 -1
- package/dist/esm/tokenize/tokenizer-utils.js +77 -4
- package/dist/esm/tokenize/types.d.ts +33 -8
- package/dist/esm/typeAdapters.js +6 -4
- package/dist/esm/types.d.ts +4 -10
- package/dist/idonate-client.js +18 -8
- package/dist/recaptcha.d.ts +1 -0
- package/dist/recaptcha.js +27 -2
- package/dist/shared.js +9 -1
- package/dist/tokenize/CardConnectTokenizer.d.ts +8 -1
- package/dist/tokenize/CardConnectTokenizer.js +351 -105
- package/dist/tokenize/PayPalTokenizer.d.ts +6 -0
- package/dist/tokenize/PayPalTokenizer.js +66 -16
- package/dist/tokenize/SpreedlyTokenizer.d.ts +23 -1
- package/dist/tokenize/SpreedlyTokenizer.js +327 -148
- package/dist/tokenize/Tokenizer.d.ts +6 -2
- package/dist/tokenize/Tokenizer.js +24 -8
- package/dist/tokenize/gateway-utils.d.ts +2 -0
- package/dist/tokenize/gateway-utils.js +30 -0
- package/dist/tokenize/index.d.ts +3 -2
- package/dist/tokenize/index.js +3 -1
- package/dist/tokenize/spreedly-secure.js +6 -2
- package/dist/tokenize/styles.d.ts +1 -1
- package/dist/tokenize/styles.js +20 -1
- package/dist/tokenize/tokenizer-constants.d.ts +1 -0
- package/dist/tokenize/tokenizer-constants.js +2 -1
- package/dist/tokenize/tokenizer-utils.d.ts +4 -1
- package/dist/tokenize/tokenizer-utils.js +80 -4
- package/dist/tokenize/types.d.ts +33 -8
- package/dist/typeAdapters.js +6 -4
- package/dist/types.d.ts +4 -10
- package/package.json +33 -2
- package/umd/idonate-sdk.js +1 -1
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CLIENT_HEADERS = exports.CARD_CONNECT_DEFAULT_STYLE = exports.DEFAULT_APP_NAME = exports.DEFAULT_CF_TURNSTILE_CDN_EXPLICIT_URL = exports.FALLBACK_CF_TURNSTILE_SITE_KEY = exports.FALLBACK_PC_SCRIPT_ID = exports.FALLBACK_PC_SCRIPT_URL = exports.SANDBOX_APPLE_PAY_URL = exports.APPLE_PAY_URL = exports.SPREEDLY_TOKENIZER_URL = exports.SANDBOX_CARD_CONNECT_BASE_URL = exports.PRODUCTION_CARD_CONNECT_BASE_URL = exports.SANDBOX_BASE_URL = exports.PRODUCTION_BASE_URL = exports.SDK_VERSION = void 0;
|
|
4
|
-
exports.SDK_VERSION = '1.2.0-
|
|
4
|
+
exports.SDK_VERSION = '1.2.0-dev21';
|
|
5
5
|
exports.PRODUCTION_BASE_URL = 'https://secure-api.idonate.com';
|
|
6
6
|
exports.SANDBOX_BASE_URL = 'https://api.qa-idonate.com';
|
|
7
7
|
exports.PRODUCTION_CARD_CONNECT_BASE_URL = 'https://boltgw.cardconnect.com:8443';
|
|
@@ -78,7 +78,16 @@ input#cccvvfield {
|
|
|
78
78
|
color: #8b959d;
|
|
79
79
|
}
|
|
80
80
|
`.replace(/\s+/gi, ' ');
|
|
81
|
+
function getUserAgent() {
|
|
82
|
+
if (typeof navigator !== 'undefined') {
|
|
83
|
+
return navigator.userAgent;
|
|
84
|
+
}
|
|
85
|
+
if (typeof process !== 'undefined' && process.version) {
|
|
86
|
+
return `Node.js/${process.version} (${process.platform})`;
|
|
87
|
+
}
|
|
88
|
+
return 'unknown-runtime';
|
|
89
|
+
}
|
|
81
90
|
exports.CLIENT_HEADERS = {
|
|
82
|
-
'User-Agent':
|
|
91
|
+
'User-Agent': getUserAgent() + ` idonate-sdk@${exports.SDK_VERSION}`,
|
|
83
92
|
'Content-Type': 'application/json',
|
|
84
93
|
};
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const SDK_VERSION = '1.2.0-
|
|
1
|
+
export const SDK_VERSION = '1.2.0-dev21';
|
|
2
2
|
export const PRODUCTION_BASE_URL = 'https://secure-api.idonate.com';
|
|
3
3
|
export const SANDBOX_BASE_URL = 'https://api.qa-idonate.com';
|
|
4
4
|
export const PRODUCTION_CARD_CONNECT_BASE_URL = 'https://boltgw.cardconnect.com:8443';
|
|
@@ -75,7 +75,16 @@ input#cccvvfield {
|
|
|
75
75
|
color: #8b959d;
|
|
76
76
|
}
|
|
77
77
|
`.replace(/\s+/gi, ' ');
|
|
78
|
+
function getUserAgent() {
|
|
79
|
+
if (typeof navigator !== 'undefined') {
|
|
80
|
+
return navigator.userAgent;
|
|
81
|
+
}
|
|
82
|
+
if (typeof process !== 'undefined' && process.version) {
|
|
83
|
+
return `Node.js/${process.version} (${process.platform})`;
|
|
84
|
+
}
|
|
85
|
+
return 'unknown-runtime';
|
|
86
|
+
}
|
|
78
87
|
export const CLIENT_HEADERS = {
|
|
79
|
-
'User-Agent':
|
|
88
|
+
'User-Agent': getUserAgent() + ` idonate-sdk@${SDK_VERSION}`,
|
|
80
89
|
'Content-Type': 'application/json',
|
|
81
90
|
};
|
|
@@ -111,10 +111,10 @@ export default class iDonateClient {
|
|
|
111
111
|
if (!this.allowTransaction) {
|
|
112
112
|
throw new Error('Wow, that was fast - try again');
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
donation
|
|
116
|
-
|
|
117
|
-
const payload = buildCashPaymentPayload(this.organizationId,
|
|
114
|
+
const donationWithEmbed = donation.embedId
|
|
115
|
+
? donation
|
|
116
|
+
: Object.assign(Object.assign({}, donation), { embedId: this.embedId });
|
|
117
|
+
const payload = buildCashPaymentPayload(this.organizationId, donationWithEmbed);
|
|
118
118
|
const fetchCall = (clearanceToken) => fetch(`${this.config.embedApiBaseUrl}/donate/cash-payment`, {
|
|
119
119
|
method: 'POST',
|
|
120
120
|
headers: Object.assign(Object.assign(Object.assign({}, CLIENT_HEADERS), (clearanceToken ? { 'cf-validation-token': clearanceToken } : {})), { 'User-Agent': CLIENT_HEADERS['User-Agent'] + ' source:' + this.config.client }),
|
|
@@ -142,10 +142,10 @@ export default class iDonateClient {
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
createPaymentMethod(paymentMethod) {
|
|
145
|
-
|
|
146
|
-
paymentMethod
|
|
147
|
-
|
|
148
|
-
return shared.createPaymentMethod(
|
|
145
|
+
const pmWithEmbed = paymentMethod.embedId
|
|
146
|
+
? paymentMethod
|
|
147
|
+
: Object.assign(Object.assign({}, paymentMethod), { embedId: this.embedId });
|
|
148
|
+
return shared.createPaymentMethod(pmWithEmbed, this.config);
|
|
149
149
|
}
|
|
150
150
|
setOrganizationId(organizationId) {
|
|
151
151
|
this.currentOrganizationId = organizationId;
|
|
@@ -157,7 +157,16 @@ export default class iDonateClient {
|
|
|
157
157
|
return new Promise((resolve, reject) => {
|
|
158
158
|
setTimeout(() => {
|
|
159
159
|
let pollHandle;
|
|
160
|
+
let attempts = 0;
|
|
161
|
+
const maxAttempts = 90;
|
|
160
162
|
pollHandle = setInterval(() => {
|
|
163
|
+
attempts++;
|
|
164
|
+
if (attempts > maxAttempts) {
|
|
165
|
+
clearInterval(pollHandle);
|
|
166
|
+
pollHandle = null;
|
|
167
|
+
reject(new ClientError('Donation processing timed out. Please check your email for a receipt or contact support.'));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
161
170
|
fetch(`${this.config.embedApiBaseUrl}/donate/cash-payment/${donationId}/payment_status`, {
|
|
162
171
|
method: 'GET',
|
|
163
172
|
headers: {
|
|
@@ -174,6 +183,7 @@ export default class iDonateClient {
|
|
|
174
183
|
}
|
|
175
184
|
if (response.error) {
|
|
176
185
|
reject(new ClientError(response.error));
|
|
186
|
+
return;
|
|
177
187
|
}
|
|
178
188
|
resolve(buildDonationResult({
|
|
179
189
|
_raw_response: Object.assign({ campaign: null, designation: {}, donor: {}, form_data: {}, id: null, schedule: {}, transaction: {} }, response),
|
package/dist/esm/recaptcha.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export declare class RecaptchaElement {
|
|
|
10
10
|
resolveToken(): Promise<string>;
|
|
11
11
|
}
|
|
12
12
|
export declare function wrapElement(container: string, sitekey: string, extraParams?: any): RecaptchaElement;
|
|
13
|
+
export declare function wrapElementWithThrow(container: string, sitekey: string, extraParams?: any): Promise<RecaptchaElement>;
|
package/dist/esm/recaptcha.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
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
|
+
};
|
|
1
10
|
function resolveLib() {
|
|
2
11
|
const startWait = new Date();
|
|
3
12
|
return new Promise((resolve, reject) => {
|
|
@@ -52,9 +61,16 @@ export class RecaptchaElement {
|
|
|
52
61
|
this.widgetId = lib.render(this.container, Object.assign(Object.assign({}, this.params), { callback: (token) => {
|
|
53
62
|
var _a;
|
|
54
63
|
this.resolvedToken = token;
|
|
55
|
-
(_a = this.executeResolveQueue.
|
|
64
|
+
(_a = this.executeResolveQueue.shift()) === null || _a === void 0 ? void 0 : _a.resolve(token);
|
|
56
65
|
}, 'expired-callback': () => {
|
|
57
66
|
this.resolvedToken = undefined;
|
|
67
|
+
}, 'error-callback': () => {
|
|
68
|
+
var _a;
|
|
69
|
+
this.resolvedToken = undefined;
|
|
70
|
+
const error = new Error('reCAPTCHA encountered an error. Please try again.');
|
|
71
|
+
while (this.executeResolveQueue.length > 0) {
|
|
72
|
+
(_a = this.executeResolveQueue.shift()) === null || _a === void 0 ? void 0 : _a.reject(error);
|
|
73
|
+
}
|
|
58
74
|
} }));
|
|
59
75
|
});
|
|
60
76
|
}
|
|
@@ -68,7 +84,7 @@ export class RecaptchaElement {
|
|
|
68
84
|
? resolve(response)
|
|
69
85
|
: reject(new Error('checkbox recaptcha is not checked'));
|
|
70
86
|
}
|
|
71
|
-
this.executeResolveQueue.push(resolve);
|
|
87
|
+
this.executeResolveQueue.push({ resolve, reject });
|
|
72
88
|
if (this.resolvedToken !== undefined) {
|
|
73
89
|
this.resolvedToken = undefined;
|
|
74
90
|
lib.reset(this.widgetId);
|
|
@@ -87,3 +103,11 @@ export function wrapElement(container, sitekey, extraParams) {
|
|
|
87
103
|
captcha.render();
|
|
88
104
|
return captcha;
|
|
89
105
|
}
|
|
106
|
+
export function wrapElementWithThrow(container, sitekey, extraParams) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const params = Object.assign(Object.assign({}, (extraParams || {})), { sitekey });
|
|
109
|
+
const captcha = new RecaptchaElement(container, params);
|
|
110
|
+
yield captcha.render();
|
|
111
|
+
return captcha;
|
|
112
|
+
});
|
|
113
|
+
}
|
package/dist/esm/shared.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { buildCreatePaymentMethodPayload, buildCreatePaymentMethodResult, } from './typeAdapters';
|
|
2
2
|
import { CLIENT_HEADERS } from './constants';
|
|
3
3
|
import { parseResponse } from './util';
|
|
4
|
+
import { normalizeGateway } from './tokenize/gateway-utils';
|
|
4
5
|
export function createPaymentMethod(paymentMethod, config) {
|
|
5
6
|
const payload = buildCreatePaymentMethodPayload(paymentMethod);
|
|
6
7
|
return fetch(`${config.embedApiBaseUrl}/payment/payment-methods`, {
|
|
@@ -17,5 +18,12 @@ export function fetchEmbedConfig(embedId, config) {
|
|
|
17
18
|
headers: CLIENT_HEADERS,
|
|
18
19
|
})
|
|
19
20
|
.then((response) => parseResponse(response, { throwErrors: true }))
|
|
20
|
-
.then((response) =>
|
|
21
|
+
.then((response) => {
|
|
22
|
+
const config = response._raw_response.result;
|
|
23
|
+
if (config.available_gateways) {
|
|
24
|
+
config.available_gateways =
|
|
25
|
+
config.available_gateways.map(normalizeGateway);
|
|
26
|
+
}
|
|
27
|
+
return config;
|
|
28
|
+
});
|
|
21
29
|
}
|
|
@@ -6,6 +6,7 @@ export declare class CardConnectTokenizer extends Tokenizer {
|
|
|
6
6
|
private iframeUrl;
|
|
7
7
|
private containerId;
|
|
8
8
|
private layout;
|
|
9
|
+
private customPlaceholders?;
|
|
9
10
|
private iframe;
|
|
10
11
|
private messageHandler?;
|
|
11
12
|
private expectedOrigin;
|
|
@@ -16,10 +17,13 @@ export declare class CardConnectTokenizer extends Tokenizer {
|
|
|
16
17
|
private accountTypeEl?;
|
|
17
18
|
private enableTestMode;
|
|
18
19
|
private cachedTokenResult?;
|
|
20
|
+
private acceptAutoToken;
|
|
19
21
|
private tokenizationPromise?;
|
|
20
22
|
private tokenizationResolve?;
|
|
21
23
|
private tokenizationReject?;
|
|
22
24
|
private currentCardType?;
|
|
25
|
+
private tokenizationTimeout?;
|
|
26
|
+
private mergedStyles?;
|
|
23
27
|
private constructor();
|
|
24
28
|
static create(gateway: PaymentGateway, container: TokenizerContainer, config: {
|
|
25
29
|
organizationId: string;
|
|
@@ -29,6 +33,8 @@ export declare class CardConnectTokenizer extends Tokenizer {
|
|
|
29
33
|
private createInternalElements;
|
|
30
34
|
private createCreditCardFields;
|
|
31
35
|
private createBankAccountFields;
|
|
36
|
+
private addBankAccountValidationListeners;
|
|
37
|
+
private updateBankAccountValidation;
|
|
32
38
|
private init;
|
|
33
39
|
tokenize(paymentData: PaymentData): Promise<PaymentToken>;
|
|
34
40
|
private tokenizeCardInternal;
|
|
@@ -44,8 +50,9 @@ export declare class CardConnectTokenizer extends Tokenizer {
|
|
|
44
50
|
get tokenizationMode(): 'auto' | 'manual';
|
|
45
51
|
private handleMessage;
|
|
46
52
|
private handleValidationMessage;
|
|
53
|
+
private static measureCvvLabelMarginLeft;
|
|
47
54
|
private static generateIframeUrl;
|
|
48
55
|
private static createIframe;
|
|
49
56
|
private static generateCardConnectCss;
|
|
50
|
-
static tokenizeBankAccount(routingNumber: string, accountNumber: string,
|
|
57
|
+
static tokenizeBankAccount(routingNumber: string, accountNumber: string, configOrBaseUrl: ConfigHandler | string): Promise<TokenizeCardConnectBankAccountResult>;
|
|
51
58
|
}
|