@idonatedev/idonate-sdk 1.0.8-dev → 1.0.11-qa
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 +8 -2
- package/dist/apple-pay.js +9 -14
- package/dist/cloudflare-challenge-handler.d.ts +5 -0
- package/dist/cloudflare-challenge-handler.js +107 -0
- package/dist/config-handler.d.ts +14 -8
- package/dist/config-handler.js +10 -4
- package/dist/constants.d.ts +6 -2
- package/dist/constants.js +8 -4
- package/dist/google-pay.js +1 -1
- package/dist/idonate-client.d.ts +7 -10
- package/dist/idonate-client.js +134 -23
- package/dist/index.js +2 -6
- package/dist/shared.js +4 -4
- package/dist/tokenize/cardconnect.js +2 -2
- package/dist/tokenize/iats.js +1 -1
- package/dist/tokenize/spreedly.d.ts +44 -0
- package/dist/tokenize/spreedly.js +107 -7
- package/dist/typeAdapters.d.ts +2 -2
- package/dist/typeAdapters.js +6 -2
- package/dist/types.d.ts +43 -37
- package/dist/types.js +1 -3
- package/dist/util.d.ts +2 -2
- package/dist/util.js +1 -1
- package/package.json +9 -9
- package/umd/idonate-sdk.js +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,12 @@ A rough usage example can be found below the Changelog.
|
|
|
7
7
|
## 1.0.7
|
|
8
8
|
* Add new optional transaction property `show_name_to_fundraiser` for allowing fundraiser to see the name of the anonymous donor in certain scenarios.
|
|
9
9
|
|
|
10
|
+
## 1.0.5
|
|
11
|
+
* Further internal refinements around Spreedly tokenization
|
|
12
|
+
|
|
13
|
+
## 1.0.4
|
|
14
|
+
* Mitigations for Spreedly tokenization outage
|
|
15
|
+
|
|
10
16
|
## 1.0.3
|
|
11
17
|
* Configure `apple_pay_url` from environment and sandbox configuration, fixing Apple Pay sandbox issues introduced
|
|
12
18
|
in 1.0.1
|
|
@@ -33,7 +39,7 @@ A rough usage example can be found below the Changelog.
|
|
|
33
39
|
(`"checking"` or `"savings"`). Before this change, `"personal"` and `"checking"` were assumed.
|
|
34
40
|
* tokenizeCardConnectBankAccount will throw a ClientError on error. The raw result can still be obtained from the error
|
|
35
41
|
payload as `_rawResult`.
|
|
36
|
-
* mark `
|
|
42
|
+
* mark `createTransaction` as deprecated - still supported, but should be replaced with `createDonation`, taking the same
|
|
37
43
|
input but capable of returning schedule data and handling schedules that do not result in an immediate transaction.
|
|
38
44
|
* `createPaymentMethod` and `createDonation` take an additional *required* option: `recaptchaType` - for most Organization
|
|
39
45
|
use cases, the value of `recaptchaType` should be `"organization"`.
|
|
@@ -89,7 +95,7 @@ A rough usage example can be found below the Changelog.
|
|
|
89
95
|
<meta charset="UTF-8" />
|
|
90
96
|
<title>createTransaction demo, with reCaptcha</title>
|
|
91
97
|
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
|
92
|
-
<script src="https://unpkg.com/@idonatedev/idonate-sdk@1.0.
|
|
98
|
+
<script src="https://unpkg.com/@idonatedev/idonate-sdk@1.0.7"></script>
|
|
93
99
|
</head>
|
|
94
100
|
<body>
|
|
95
101
|
<button type="button" onclick="grecaptcha.execute()">Submit</button>
|
package/dist/apple-pay.js
CHANGED
|
@@ -25,20 +25,15 @@ var ApplePay = (function () {
|
|
|
25
25
|
ApplePaySession.supportsVersion(ApplePay.ApplePayApiVersion));
|
|
26
26
|
};
|
|
27
27
|
ApplePay.prototype.begin = function () {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
_this.appleSession = new ApplePaySession(ApplePay.ApplePayApiVersion, _this.paymentRequest);
|
|
35
|
-
_this.appleSession.begin();
|
|
36
|
-
resolve(_this.appleSession);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
28
|
+
if (!ApplePay.isSupported()) {
|
|
29
|
+
return Promise.reject(new Error('Apple Pay Not Supported'));
|
|
30
|
+
}
|
|
31
|
+
this.appleSession = new ApplePaySession(ApplePay.ApplePayApiVersion, this.paymentRequest);
|
|
32
|
+
this.appleSession.begin();
|
|
33
|
+
return Promise.resolve(this.appleSession);
|
|
39
34
|
};
|
|
40
35
|
ApplePay.prototype.createSession = function (payload, embedApiBaseUrl) {
|
|
41
|
-
return fetch(
|
|
36
|
+
return fetch(embedApiBaseUrl + "/payment/create-session", {
|
|
42
37
|
method: 'POST',
|
|
43
38
|
headers: constants_1.CLIENT_HEADERS,
|
|
44
39
|
body: JSON.stringify(payload),
|
|
@@ -52,8 +47,8 @@ var ApplePay = (function () {
|
|
|
52
47
|
var eckey = paymentData.header.ephemeralPublicKey;
|
|
53
48
|
var ectid = paymentData.header.transactionId;
|
|
54
49
|
var ecpublickeyhash = paymentData.header.publicKeyHash;
|
|
55
|
-
var dataString =
|
|
56
|
-
return fetch(
|
|
50
|
+
var dataString = token + "&ectype=" + ectype + "&ecsig=" + ecsig + "&eckey=" + eckey + "&ectid=" + ectid + "&echash=&ecpublickeyhash=" + ecpublickeyhash;
|
|
51
|
+
return fetch(cardConnectBaseUrl + "/cardsecure/api/v1/ccn/tokenize", {
|
|
57
52
|
method: 'POST',
|
|
58
53
|
headers: {
|
|
59
54
|
'Content-Type': 'application/json',
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.handleCFChallenge = void 0;
|
|
40
|
+
var turnstileInstance = null;
|
|
41
|
+
exports.handleCFChallenge = function (challengeResponse, sdkClient) { return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
+
var document_1, challengeWrapper_1, challengeDiv_1, showChallenge_1, cloudflareScript;
|
|
43
|
+
var _a, _b;
|
|
44
|
+
return __generator(this, function (_c) {
|
|
45
|
+
try {
|
|
46
|
+
document_1 = window === null || window === void 0 ? void 0 : window.document;
|
|
47
|
+
if (!document_1 || !window) {
|
|
48
|
+
throw new Error('document is not present on window');
|
|
49
|
+
}
|
|
50
|
+
challengeWrapper_1 = document_1.createElement('div');
|
|
51
|
+
challengeDiv_1 = document_1.createElement('div');
|
|
52
|
+
showChallenge_1 = function (turnstile) {
|
|
53
|
+
var _a;
|
|
54
|
+
(_a = turnstile === null || turnstile === void 0 ? void 0 : turnstile.render) === null || _a === void 0 ? void 0 : _a.call(turnstile, "#iDonateTurnstileBox", {
|
|
55
|
+
sitekey: sdkClient.config.turnstileSiteKey,
|
|
56
|
+
callback: function (token, preClearance) {
|
|
57
|
+
challengeWrapper_1.remove();
|
|
58
|
+
resolve({ token: token, preClearance: preClearance });
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
window.idonateTurnstileLoadedHandler = function () {
|
|
63
|
+
var turnstile = window.turnstile;
|
|
64
|
+
challengeDiv_1.innerHTML = '';
|
|
65
|
+
if (turnstile) {
|
|
66
|
+
turnstileInstance = turnstile;
|
|
67
|
+
}
|
|
68
|
+
showChallenge_1(turnstile);
|
|
69
|
+
};
|
|
70
|
+
challengeWrapper_1.setAttribute('id', 'idonateTurnstileWrapper');
|
|
71
|
+
challengeWrapper_1.style.position = 'fixed';
|
|
72
|
+
challengeWrapper_1.style.top = '0';
|
|
73
|
+
challengeWrapper_1.style.bottom = '0';
|
|
74
|
+
challengeWrapper_1.style.left = '0';
|
|
75
|
+
challengeWrapper_1.style.right = '0';
|
|
76
|
+
challengeWrapper_1.style.backgroundColor = 'rgba(0,0,0,0.9)';
|
|
77
|
+
challengeWrapper_1.style.transition = 'all 400ms';
|
|
78
|
+
challengeWrapper_1.style.display = 'flex';
|
|
79
|
+
challengeWrapper_1.style.flexDirection = 'column';
|
|
80
|
+
challengeWrapper_1.style.padding = '40px 30px';
|
|
81
|
+
challengeWrapper_1.style.opacity = '0';
|
|
82
|
+
challengeWrapper_1.style.color = 'white';
|
|
83
|
+
challengeWrapper_1.style.fontFamily = 'sans-serif';
|
|
84
|
+
challengeWrapper_1.innerHTML = '<h1 id="idonateTurnstileVerificationHeader">Last tiny step before we submit your payment:</h1>';
|
|
85
|
+
challengeDiv_1.setAttribute('id', 'iDonateTurnstileBox');
|
|
86
|
+
challengeWrapper_1.append(challengeDiv_1);
|
|
87
|
+
document_1.body.append(challengeWrapper_1);
|
|
88
|
+
if (turnstileInstance) {
|
|
89
|
+
showChallenge_1(turnstileInstance);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
cloudflareScript = document_1.createElement('script');
|
|
93
|
+
challengeDiv_1.innerHTML = 'loading ...';
|
|
94
|
+
cloudflareScript.src = sdkClient.config.turnstileCdnUrl + '?render=explicit&onload=idonateTurnstileLoadedHandler';
|
|
95
|
+
document_1.body.append(cloudflareScript);
|
|
96
|
+
}
|
|
97
|
+
window.location.hash = 'idonateTurnstileVerificationHeader';
|
|
98
|
+
challengeWrapper_1.style.opacity = '1';
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
(_a = console === null || console === void 0 ? void 0 : console.error) === null || _a === void 0 ? void 0 : _a.call(console, e);
|
|
102
|
+
(_b = console === null || console === void 0 ? void 0 : console.warn) === null || _b === void 0 ? void 0 : _b.call(console, 'iDonate SDK: Could not handle request, please reload the page and try again');
|
|
103
|
+
reject(null);
|
|
104
|
+
}
|
|
105
|
+
return [2];
|
|
106
|
+
});
|
|
107
|
+
}); }); };
|
package/dist/config-handler.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { ClientOptions } from './types';
|
|
2
2
|
export default class ConfigHandler {
|
|
3
|
-
apiBaseUrl: string;
|
|
4
|
-
embedApiBaseUrl: string;
|
|
5
|
-
cardConnectBaseUrl: string;
|
|
6
|
-
cardConnectTokenizerUrl: string;
|
|
7
|
-
authApiBaseUrl: string;
|
|
8
|
-
donorApiBaseUrl: string;
|
|
9
|
-
spreedlyEnvironmentKey: string | undefined;
|
|
10
|
-
applePayUrl: string;
|
|
3
|
+
readonly apiBaseUrl: string;
|
|
4
|
+
readonly embedApiBaseUrl: string;
|
|
5
|
+
readonly cardConnectBaseUrl: string;
|
|
6
|
+
readonly cardConnectTokenizerUrl: string;
|
|
7
|
+
readonly authApiBaseUrl: string;
|
|
8
|
+
readonly donorApiBaseUrl: string;
|
|
9
|
+
readonly spreedlyEnvironmentKey: string | undefined;
|
|
10
|
+
readonly applePayUrl: string;
|
|
11
|
+
readonly pcScriptBase: string;
|
|
12
|
+
readonly pcScriptId: string;
|
|
13
|
+
readonly enableDelay: boolean;
|
|
14
|
+
readonly secondsToDelay: number;
|
|
15
|
+
readonly turnstileCdnUrl: string;
|
|
16
|
+
readonly turnstileSiteKey: string;
|
|
11
17
|
constructor(options: Partial<ClientOptions>);
|
|
12
18
|
}
|
package/dist/config-handler.js
CHANGED
|
@@ -17,18 +17,24 @@ var ConfigHandler = (function () {
|
|
|
17
17
|
this.apiBaseUrl = options.overrideBaseUrl;
|
|
18
18
|
}
|
|
19
19
|
this.authApiBaseUrl =
|
|
20
|
-
options.overrideAuthApiBaseUrl ||
|
|
20
|
+
options.overrideAuthApiBaseUrl || this.apiBaseUrl + "/auth";
|
|
21
21
|
this.donorApiBaseUrl =
|
|
22
|
-
options.overrideDonorApiBaseUrl ||
|
|
22
|
+
options.overrideDonorApiBaseUrl || this.apiBaseUrl + "/donor";
|
|
23
23
|
this.embedApiBaseUrl =
|
|
24
|
-
options.overrideEmbedApiBaseUrl ||
|
|
24
|
+
options.overrideEmbedApiBaseUrl || this.apiBaseUrl + "/embed";
|
|
25
25
|
if (options.overrideApplePayUrl) {
|
|
26
26
|
this.applePayUrl = options.overrideApplePayUrl;
|
|
27
27
|
}
|
|
28
|
+
this.pcScriptBase = options.pcScriptBase || constants_1.FALLBACK_PC_SCRIPT_URL;
|
|
29
|
+
this.pcScriptId = options.pcScriptId || constants_1.FALLBACK_PC_SCRIPT_ID;
|
|
30
|
+
this.turnstileCdnUrl = options.turnstileCdnUrl || constants_1.DEFAULT_CF_TURNSTILE_CDN_EXPLICIT_URL;
|
|
31
|
+
this.turnstileSiteKey = options.turnstileSiteKey || constants_1.FALLBACK_CF_TURNSTILE_SITE_KEY;
|
|
28
32
|
if (options === null || options === void 0 ? void 0 : options.spreedlyEnvironmentKey) {
|
|
29
33
|
this.spreedlyEnvironmentKey = options.spreedlyEnvironmentKey;
|
|
30
34
|
}
|
|
31
|
-
this.
|
|
35
|
+
this.enableDelay = options.enableDelay || false;
|
|
36
|
+
this.secondsToDelay = options.secondsToDelay || 0;
|
|
37
|
+
this.cardConnectTokenizerUrl = this.cardConnectBaseUrl + "/itoke/ajax-tokenizer.html";
|
|
32
38
|
}
|
|
33
39
|
return ConfigHandler;
|
|
34
40
|
}());
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
export declare const PRODUCTION_BASE_URL = "https://api.idonate.com";
|
|
1
|
+
export declare const PRODUCTION_BASE_URL = "https://secure-api.idonate.com";
|
|
2
2
|
export declare const SANDBOX_BASE_URL = "https://staging-api.idonate.com";
|
|
3
3
|
export declare const PRODUCTION_CARD_CONNECT_BASE_URL = "https://boltgw.cardconnect.com:8443";
|
|
4
4
|
export declare const SANDBOX_CARD_CONNECT_BASE_URL = "https://boltgw-uat.cardconnect.com";
|
|
5
|
-
export declare const SPREEDLY_TOKENIZER_URL = "https://core.spreedly.com/v1/payment_methods.json
|
|
5
|
+
export declare const SPREEDLY_TOKENIZER_URL = "https://core.spreedly.com/v1/payment_methods.json";
|
|
6
6
|
export declare const APPLE_PAY_URL = "https://apple-pay-gateway.apple.com/paymentservices/paymentSession";
|
|
7
7
|
export declare const SANDBOX_APPLE_PAY_URL = "https://apple-pay-gateway-cert.apple.com/paymentservices/paymentSession";
|
|
8
|
+
export declare const FALLBACK_PC_SCRIPT_URL = "https://p.idonate.com/r";
|
|
9
|
+
export declare const FALLBACK_PC_SCRIPT_ID = "_3fd4dad26e8c277bc50fb2ddf8233b50bc8d9704";
|
|
10
|
+
export declare const FALLBACK_CF_TURNSTILE_SITE_KEY = "0x4AAAAAAAxuRxNZTvX8shIj";
|
|
11
|
+
export declare const DEFAULT_CF_TURNSTILE_CDN_EXPLICIT_URL = "https://challenges.cloudflare.com/turnstile/v0/api.js";
|
|
8
12
|
export declare const CARD_CONNECT_DEFAULT_STYLE: string;
|
|
9
13
|
export declare const CLIENT_HEADERS: {
|
|
10
14
|
'User-Agent': string;
|
package/dist/constants.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CLIENT_HEADERS = exports.CARD_CONNECT_DEFAULT_STYLE = 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 = void 0;
|
|
4
|
-
exports.PRODUCTION_BASE_URL = 'https://api.idonate.com';
|
|
3
|
+
exports.CLIENT_HEADERS = exports.CARD_CONNECT_DEFAULT_STYLE = 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 = void 0;
|
|
4
|
+
exports.PRODUCTION_BASE_URL = 'https://secure-api.idonate.com';
|
|
5
5
|
exports.SANDBOX_BASE_URL = 'https://staging-api.idonate.com';
|
|
6
6
|
exports.PRODUCTION_CARD_CONNECT_BASE_URL = 'https://boltgw.cardconnect.com:8443';
|
|
7
7
|
exports.SANDBOX_CARD_CONNECT_BASE_URL = 'https://boltgw-uat.cardconnect.com';
|
|
8
|
-
exports.SPREEDLY_TOKENIZER_URL = 'https://core.spreedly.com/v1/payment_methods.json
|
|
8
|
+
exports.SPREEDLY_TOKENIZER_URL = 'https://core.spreedly.com/v1/payment_methods.json';
|
|
9
9
|
exports.APPLE_PAY_URL = 'https://apple-pay-gateway.apple.com/paymentservices/paymentSession';
|
|
10
10
|
exports.SANDBOX_APPLE_PAY_URL = 'https://apple-pay-gateway-cert.apple.com/paymentservices/paymentSession';
|
|
11
|
+
exports.FALLBACK_PC_SCRIPT_URL = 'https://p.idonate.com/r';
|
|
12
|
+
exports.FALLBACK_PC_SCRIPT_ID = '_3fd4dad26e8c277bc50fb2ddf8233b50bc8d9704';
|
|
13
|
+
exports.FALLBACK_CF_TURNSTILE_SITE_KEY = '0x4AAAAAAAxuRxNZTvX8shIj';
|
|
14
|
+
exports.DEFAULT_CF_TURNSTILE_CDN_EXPLICIT_URL = 'https://challenges.cloudflare.com/turnstile/v0/api.js';
|
|
11
15
|
exports.CARD_CONNECT_DEFAULT_STYLE = "\nbody {\n margin: 0;\n}\n\nform {\n display: flex;\n}\n\nlabel#cccardlabel {\n display: none;\n}\n\nbr {\n display: none;\n}\n\nlabel#cccvvlabel {\n display: none;\n}\n\nlabel#ccexpirylabel {\n display: none;\n}\n\ninput {\n padding: 10px;\n}\n\nselect {\n padding: 10px;\n font-size: 14px;\n color: #8b959d;\n}\n\nselect#ccexpirymonth {\n margin-right: -30px;\n border: 1px solid #b6b8ba;\n border-right: 0;\n}\n\ninput#ccnumfield {\n width: 70%;\n border: 1px solid #b6b8ba;\n border-right: 0;\n border-top-left-radius: 3px;\n border-bottom-left-radius: 3px;\n font-size: 14px;\n color: #8b959d;\n}\n\nselect#ccexpiryyear {\n border: 1px solid #b6b8ba;\n border-right: 0;\n}\n\ninput#cccvvfield {\n border: 1px solid #b6b8ba;\n border-top-right-radius: 3px;\n border-bottom-right-radius: 3px;\n font-size: 14px;\n color: #8b959d;\n}\n".replace(/\s+/gi, ' ');
|
|
12
16
|
exports.CLIENT_HEADERS = {
|
|
13
|
-
'User-Agent': navigator.userAgent + ' idonate-sdk@1.0.
|
|
17
|
+
'User-Agent': navigator.userAgent + ' idonate-sdk@1.0.11-qa',
|
|
14
18
|
'Content-Type': 'application/json',
|
|
15
19
|
};
|
package/dist/google-pay.js
CHANGED
|
@@ -138,7 +138,7 @@ var GooglePay = (function () {
|
|
|
138
138
|
});
|
|
139
139
|
};
|
|
140
140
|
GooglePay.prototype.tokenizeWithCardConnect = function (paymentToken, cardConnectBaseUrl) {
|
|
141
|
-
return fetch(
|
|
141
|
+
return fetch(cardConnectBaseUrl + "/cardsecure/api/v1/ccn/tokenize", {
|
|
142
142
|
method: 'POST',
|
|
143
143
|
headers: {
|
|
144
144
|
'Content-Type': 'application/json',
|
package/dist/idonate-client.d.ts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
/// <reference types="applepayjs" />
|
|
2
2
|
import { ACHAccount, Address, ClientOptions, Contact, CreatePaymentMethodRequest, CreatePaymentMethodResult, CreateDonationRequest, CreateDonationResult, CreditCard, TokenizeApplePayResult } from './types';
|
|
3
|
+
import ConfigHandler from './config-handler';
|
|
3
4
|
export default class iDonateClient {
|
|
4
5
|
private readonly clientKey;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
10
|
-
readonly authApiBaseUrl: string;
|
|
11
|
-
readonly donorApiBaseUrl: string;
|
|
12
|
-
private readonly spreedlyEnvironmentKey;
|
|
13
|
-
private readonly options;
|
|
14
|
-
private readonly config;
|
|
6
|
+
private currentOrganizationId;
|
|
7
|
+
private allowTransaction;
|
|
8
|
+
get organizationId(): string;
|
|
9
|
+
readonly options: ClientOptions;
|
|
10
|
+
readonly config: ConfigHandler;
|
|
15
11
|
constructor(clientKey: string, options?: Partial<ClientOptions>);
|
|
16
12
|
createDonation(donation: CreateDonationRequest): Promise<CreateDonationResult>;
|
|
17
13
|
createTransaction(donation: CreateDonationRequest): Promise<{
|
|
@@ -20,6 +16,7 @@ export default class iDonateClient {
|
|
|
20
16
|
}>;
|
|
21
17
|
createPaymentMethod(paymentMethod: CreatePaymentMethodRequest): Promise<CreatePaymentMethodResult>;
|
|
22
18
|
private tokenizeCardConnectBankAccountInternal;
|
|
19
|
+
setOrganizationId(organizationId: string): void;
|
|
23
20
|
tokenizeCardConnectBankAccount(account: ACHAccount): Promise<string>;
|
|
24
21
|
tokenizeSpreedlyCreditCard(data: {
|
|
25
22
|
contact: Contact;
|
package/dist/idonate-client.js
CHANGED
|
@@ -10,6 +10,42 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
13
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
50
|
var types_1 = require("./types");
|
|
15
51
|
var typeAdapters_1 = require("./typeAdapters");
|
|
@@ -20,36 +56,108 @@ var config_handler_1 = require("./config-handler");
|
|
|
20
56
|
var cardconnect = require("./tokenize/cardconnect");
|
|
21
57
|
var spreedly = require("./tokenize/spreedly");
|
|
22
58
|
var shared = require("./shared");
|
|
59
|
+
var uuid_1 = require("uuid");
|
|
60
|
+
var cloudflare_challenge_handler_1 = require("./cloudflare-challenge-handler");
|
|
23
61
|
var clientDefaults = {
|
|
24
62
|
enableSandboxMode: false,
|
|
25
63
|
overrideBaseUrl: undefined,
|
|
64
|
+
enableDelay: false,
|
|
65
|
+
secondsToDelay: 0
|
|
26
66
|
};
|
|
27
67
|
var iDonateClient = (function () {
|
|
28
68
|
function iDonateClient(clientKey, options) {
|
|
69
|
+
var _this = this;
|
|
70
|
+
var _a;
|
|
29
71
|
this.clientKey = clientKey;
|
|
30
72
|
this.options = Object.assign({}, clientDefaults, options);
|
|
31
|
-
this.
|
|
73
|
+
this.allowTransaction = false;
|
|
32
74
|
this.config = new config_handler_1.default(this.options);
|
|
33
|
-
this
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
75
|
+
Object.assign(this, this.config);
|
|
76
|
+
if (this.options.enableDelay && this.options.secondsToDelay) {
|
|
77
|
+
var delay = this.options.secondsToDelay * 1000;
|
|
78
|
+
setTimeout(function () {
|
|
79
|
+
_this.allowTransaction = true;
|
|
80
|
+
}, delay);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this.allowTransaction = true;
|
|
84
|
+
}
|
|
40
85
|
if (this.options.enableSandboxMode && console !== undefined) {
|
|
41
86
|
console.info('[Sandbox] iDonate SDK Configuration:', JSON.parse(JSON.stringify(this)));
|
|
42
87
|
}
|
|
88
|
+
try {
|
|
89
|
+
var _b = this.config, pcScriptBase = _b.pcScriptBase, pcScriptId = _b.pcScriptId;
|
|
90
|
+
if (!pcScriptBase || !pcScriptId) {
|
|
91
|
+
throw new Error('missing config');
|
|
92
|
+
}
|
|
93
|
+
var uuid = uuid_1.v4();
|
|
94
|
+
var script_1 = window.document.createElement('script');
|
|
95
|
+
script_1.setAttribute('src', pcScriptBase + '/' + uuid + '.js');
|
|
96
|
+
script_1.setAttribute('id', pcScriptId);
|
|
97
|
+
var appended_1 = false;
|
|
98
|
+
var appendScript = function () {
|
|
99
|
+
var _a;
|
|
100
|
+
try {
|
|
101
|
+
if (appended_1)
|
|
102
|
+
return;
|
|
103
|
+
window.document.body.append(script_1);
|
|
104
|
+
appended_1 = true;
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
(_a = console === null || console === void 0 ? void 0 : console.warn) === null || _a === void 0 ? void 0 : _a.call(console, 'not appended');
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
appendScript();
|
|
111
|
+
window.addEventListener('DOMContentLoaded', function () {
|
|
112
|
+
window.document.body.append(script_1);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
(_a = console === null || console === void 0 ? void 0 : console.warn) === null || _a === void 0 ? void 0 : _a.call(console, 'Warning, partial initialization: ', String(e));
|
|
117
|
+
}
|
|
118
|
+
if (!this.currentOrganizationId) {
|
|
119
|
+
this.setOrganizationId(this.clientKey);
|
|
120
|
+
}
|
|
43
121
|
}
|
|
122
|
+
Object.defineProperty(iDonateClient.prototype, "organizationId", {
|
|
123
|
+
get: function () {
|
|
124
|
+
if (!this.currentOrganizationId) {
|
|
125
|
+
throw new Error('organizationId undefined');
|
|
126
|
+
}
|
|
127
|
+
return this.currentOrganizationId;
|
|
128
|
+
},
|
|
129
|
+
enumerable: false,
|
|
130
|
+
configurable: true
|
|
131
|
+
});
|
|
44
132
|
iDonateClient.prototype.createDonation = function (donation) {
|
|
45
|
-
var
|
|
46
|
-
|
|
133
|
+
var _this = this;
|
|
134
|
+
if (!this.allowTransaction) {
|
|
135
|
+
throw new Error('Wow, that was fast - try again');
|
|
136
|
+
}
|
|
137
|
+
var payload = typeAdapters_1.buildCashPaymentPayload(this.organizationId, donation);
|
|
138
|
+
var fetchCall = function (clearanceToken) { return fetch(_this.config.embedApiBaseUrl + "/donate/cash-payment", {
|
|
47
139
|
method: 'POST',
|
|
48
|
-
headers: constants_1.CLIENT_HEADERS,
|
|
140
|
+
headers: __assign(__assign({}, constants_1.CLIENT_HEADERS), (clearanceToken ? { 'cf-validation-token': clearanceToken } : {})),
|
|
49
141
|
body: JSON.stringify(payload),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
142
|
+
credentials: 'include',
|
|
143
|
+
}); };
|
|
144
|
+
return fetchCall()
|
|
145
|
+
.then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
146
|
+
var clearance;
|
|
147
|
+
return __generator(this, function (_a) {
|
|
148
|
+
switch (_a.label) {
|
|
149
|
+
case 0:
|
|
150
|
+
if (!(response.headers.get('cf-mitigated') === 'challenge')) return [3, 2];
|
|
151
|
+
return [4, cloudflare_challenge_handler_1.handleCFChallenge(response, this)];
|
|
152
|
+
case 1:
|
|
153
|
+
clearance = _a.sent();
|
|
154
|
+
return [2, fetchCall(clearance === null || clearance === void 0 ? void 0 : clearance.token)];
|
|
155
|
+
case 2: return [2, response];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}); })
|
|
159
|
+
.then(function (response) { return util_1.parseResponse(response, { throwErrors: true }); })
|
|
160
|
+
.then(function (response) { return typeAdapters_1.buildDonationResult(response); });
|
|
53
161
|
};
|
|
54
162
|
iDonateClient.prototype.createTransaction = function (donation) {
|
|
55
163
|
return this.createDonation(donation).then(function (result) {
|
|
@@ -66,6 +174,9 @@ var iDonateClient = (function () {
|
|
|
66
174
|
iDonateClient.prototype.tokenizeCardConnectBankAccountInternal = function (routingNumber, accountNumber) {
|
|
67
175
|
return cardconnect.tokenizeBankAccount(routingNumber, accountNumber, this.config);
|
|
68
176
|
};
|
|
177
|
+
iDonateClient.prototype.setOrganizationId = function (organizationId) {
|
|
178
|
+
this.currentOrganizationId = organizationId;
|
|
179
|
+
};
|
|
69
180
|
iDonateClient.prototype.tokenizeCardConnectBankAccount = function (account) {
|
|
70
181
|
return this.tokenizeCardConnectBankAccountInternal(account.routingNumber, account.accountNumber).then(function (result) {
|
|
71
182
|
if (!result.token || result.errorcode !== 0) {
|
|
@@ -103,7 +214,7 @@ var iDonateClient = (function () {
|
|
|
103
214
|
var paramString = new URLSearchParams(resolvedOptions)
|
|
104
215
|
.toString()
|
|
105
216
|
.replace('+', '%20');
|
|
106
|
-
return
|
|
217
|
+
return this.config.cardConnectTokenizerUrl + "?" + paramString;
|
|
107
218
|
};
|
|
108
219
|
iDonateClient.prototype.waitForDonationResult = function (donationId) {
|
|
109
220
|
var _this = this;
|
|
@@ -114,7 +225,7 @@ var iDonateClient = (function () {
|
|
|
114
225
|
setTimeout(function () {
|
|
115
226
|
var pollHandle;
|
|
116
227
|
pollHandle = setInterval(function () {
|
|
117
|
-
fetch(
|
|
228
|
+
fetch(_this.config.embedApiBaseUrl + "/donate/cash-payment/" + donationId + "/payment_status", {
|
|
118
229
|
method: 'GET',
|
|
119
230
|
headers: {
|
|
120
231
|
'Content-Type': 'application/json',
|
|
@@ -131,7 +242,7 @@ var iDonateClient = (function () {
|
|
|
131
242
|
if (response.error) {
|
|
132
243
|
reject(new types_1.ClientError(response.error));
|
|
133
244
|
}
|
|
134
|
-
resolve(
|
|
245
|
+
resolve(typeAdapters_1.buildDonationResult({
|
|
135
246
|
_raw_response: __assign({ campaign: null, designation: {}, donor: {}, form_data: {}, id: null, schedule: {}, transaction: {} }, response),
|
|
136
247
|
}));
|
|
137
248
|
}
|
|
@@ -144,11 +255,11 @@ var iDonateClient = (function () {
|
|
|
144
255
|
};
|
|
145
256
|
iDonateClient.prototype.tokenizeCardConnectApplePay = function (applePayRequest) {
|
|
146
257
|
var _this = this;
|
|
258
|
+
var applePay = new apple_pay_1.default(applePayRequest);
|
|
259
|
+
var merchantSessionId = '';
|
|
260
|
+
var promiseStart = applePay.begin();
|
|
147
261
|
return new Promise(function (resolve, reject) {
|
|
148
|
-
|
|
149
|
-
var merchantSessionId = '';
|
|
150
|
-
applePay
|
|
151
|
-
.begin()
|
|
262
|
+
promiseStart
|
|
152
263
|
.then(function (session) {
|
|
153
264
|
session.onvalidatemerchant = function (event) {
|
|
154
265
|
var validationPayload = {
|
|
@@ -156,7 +267,7 @@ var iDonateClient = (function () {
|
|
|
156
267
|
organization_id: _this.organizationId,
|
|
157
268
|
};
|
|
158
269
|
applePay
|
|
159
|
-
.createSession(validationPayload, _this.embedApiBaseUrl)
|
|
270
|
+
.createSession(validationPayload, _this.config.embedApiBaseUrl)
|
|
160
271
|
.then(function (merchantSession) {
|
|
161
272
|
merchantSessionId =
|
|
162
273
|
merchantSession.result.merchantSessionIdentifier;
|
|
@@ -165,7 +276,7 @@ var iDonateClient = (function () {
|
|
|
165
276
|
};
|
|
166
277
|
session.onpaymentauthorized = function (event) {
|
|
167
278
|
applePay
|
|
168
|
-
.tokenizeWithCardConnect(event.payment, _this.cardConnectBaseUrl)
|
|
279
|
+
.tokenizeWithCardConnect(event.payment, _this.config.cardConnectBaseUrl)
|
|
169
280
|
.then(function (data) {
|
|
170
281
|
var _a, _b;
|
|
171
282
|
var unifiedContact = __assign(__assign({}, event.payment.billingContact), { email: (_a = event.payment.shippingContact) === null || _a === void 0 ? void 0 : _a.emailAddress, phone: (_b = event.payment.shippingContact) === null || _b === void 0 ? void 0 : _b.phoneNumber });
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
12
8
|
}));
|
|
13
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
15
11
|
};
|
|
16
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
13
|
exports.GooglePay = exports.ApplePay = exports.constants = exports.recaptcha = exports.ConfigHandler = exports.Client = exports.shared = exports.util = exports.tokenize = void 0;
|
package/dist/shared.js
CHANGED
|
@@ -5,13 +5,13 @@ var typeAdapters_1 = require("./typeAdapters");
|
|
|
5
5
|
var constants_1 = require("./constants");
|
|
6
6
|
var util_1 = require("./util");
|
|
7
7
|
function createPaymentMethod(paymentMethod, config) {
|
|
8
|
-
var payload =
|
|
9
|
-
return fetch(
|
|
8
|
+
var payload = typeAdapters_1.buildCreatePaymentMethodPayload(paymentMethod);
|
|
9
|
+
return fetch(config.embedApiBaseUrl + "/payment/payment-methods", {
|
|
10
10
|
method: 'POST',
|
|
11
11
|
headers: constants_1.CLIENT_HEADERS,
|
|
12
12
|
body: JSON.stringify(payload),
|
|
13
13
|
})
|
|
14
|
-
.then(function (response) { return
|
|
15
|
-
.then(function (response) { return
|
|
14
|
+
.then(function (response) { return util_1.parseResponse(response, { throwErrors: true }); })
|
|
15
|
+
.then(function (response) { return typeAdapters_1.buildCreatePaymentMethodResult(response); });
|
|
16
16
|
}
|
|
17
17
|
exports.createPaymentMethod = createPaymentMethod;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tokenizeBankAccount = void 0;
|
|
4
4
|
function tokenizeBankAccount(routingNumber, accountNumber, config) {
|
|
5
|
-
return fetch(
|
|
5
|
+
return fetch(config.cardConnectBaseUrl + "/cardsecure/api/v1/ccn/tokenize", {
|
|
6
6
|
method: 'POST',
|
|
7
7
|
headers: {
|
|
8
8
|
'Content-Type': 'application/json',
|
|
9
9
|
},
|
|
10
10
|
body: JSON.stringify({
|
|
11
|
-
account:
|
|
11
|
+
account: routingNumber + "/" + accountNumber,
|
|
12
12
|
unique: true,
|
|
13
13
|
}),
|
|
14
14
|
}).then(function (response) { return response.json(); });
|
package/dist/tokenize/iats.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.tokenizePaymentCard = exports.tokenizePaymentBankUs = exports.tokenizePaymentBankCanada = void 0;
|
|
4
4
|
var uuid_1 = require("uuid");
|
|
5
5
|
function tokenizePaymentBankCanada(bankNumber, transitNumber, accountNumber, accountType, processId, relayUrl, gatewayId, contact, address) {
|
|
6
|
-
var newPaymentId =
|
|
6
|
+
var newPaymentId = uuid_1.v4();
|
|
7
7
|
var streetAddress = address.address1;
|
|
8
8
|
if (address.address2) {
|
|
9
9
|
streetAddress += '\n' + address.address2;
|