@idonatedev/idonate-sdk 1.0.7 → 1.0.10-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 CHANGED
@@ -4,6 +4,15 @@ Javascript libraries for integrating with iDonate services.
4
4
  A rough usage example can be found below the Changelog.
5
5
 
6
6
  # Changes
7
+ ## 1.0.7
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
+
10
+ ## 1.0.5
11
+ * Further internal refinements around Spreedly tokenization
12
+
13
+ ## 1.0.4
14
+ * Mitigations for Spreedly tokenization outage
15
+
7
16
  ## 1.0.3
8
17
  * Configure `apple_pay_url` from environment and sandbox configuration, fixing Apple Pay sandbox issues introduced
9
18
  in 1.0.1
@@ -30,7 +39,7 @@ A rough usage example can be found below the Changelog.
30
39
  (`"checking"` or `"savings"`). Before this change, `"personal"` and `"checking"` were assumed.
31
40
  * tokenizeCardConnectBankAccount will throw a ClientError on error. The raw result can still be obtained from the error
32
41
  payload as `_rawResult`.
33
- * mark `createTansaction` as deprecated - still supported, but should be replaced with `createDonation`, taking the same
42
+ * mark `createTransaction` as deprecated - still supported, but should be replaced with `createDonation`, taking the same
34
43
  input but capable of returning schedule data and handling schedules that do not result in an immediate transaction.
35
44
  * `createPaymentMethod` and `createDonation` take an additional *required* option: `recaptchaType` - for most Organization
36
45
  use cases, the value of `recaptchaType` should be `"organization"`.
@@ -86,7 +95,7 @@ A rough usage example can be found below the Changelog.
86
95
  <meta charset="UTF-8" />
87
96
  <title>createTransaction demo, with reCaptcha</title>
88
97
  <script src="https://www.google.com/recaptcha/api.js" async defer></script>
89
- <script src="https://unpkg.com/@idonatedev/idonate-sdk@1.0.0"></script>
98
+ <script src="https://unpkg.com/@idonatedev/idonate-sdk@1.0.7"></script>
90
99
  </head>
91
100
  <body>
92
101
  <button type="button" onclick="grecaptcha.execute()">Submit</button>
package/dist/apple-pay.js CHANGED
@@ -25,17 +25,12 @@ var ApplePay = (function () {
25
25
  ApplePaySession.supportsVersion(ApplePay.ApplePayApiVersion));
26
26
  };
27
27
  ApplePay.prototype.begin = function () {
28
- var _this = this;
29
- return new Promise(function (resolve, reject) {
30
- if (!ApplePay.isSupported()) {
31
- reject(new Error('Apple Pay Not Supported'));
32
- }
33
- else {
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
36
  return fetch(embedApiBaseUrl + "/payment/create-session", {
@@ -1,12 +1,14 @@
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;
11
13
  constructor(options: Partial<ClientOptions>);
12
14
  }
@@ -25,6 +25,8 @@ var ConfigHandler = (function () {
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;
28
30
  if (options === null || options === void 0 ? void 0 : options.spreedlyEnvironmentKey) {
29
31
  this.spreedlyEnvironmentKey = options.spreedlyEnvironmentKey;
30
32
  }
@@ -2,9 +2,11 @@ export declare const PRODUCTION_BASE_URL = "https://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";
8
10
  export declare const CARD_CONNECT_DEFAULT_STYLE: string;
9
11
  export declare const CLIENT_HEADERS: {
10
12
  'User-Agent': string;
package/dist/constants.js CHANGED
@@ -1,15 +1,17 @@
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;
3
+ exports.CLIENT_HEADERS = exports.CARD_CONNECT_DEFAULT_STYLE = 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
4
  exports.PRODUCTION_BASE_URL = 'https://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';
11
13
  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
14
  exports.CLIENT_HEADERS = {
13
- 'User-Agent': navigator.userAgent + ' idonate-sdk@1.0.1-alpha.4',
15
+ 'User-Agent': navigator.userAgent + ' idonate-sdk@1.0.7',
14
16
  'Content-Type': 'application/json',
15
17
  };
@@ -1,17 +1,12 @@
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
- readonly organizationId: string;
6
- readonly apiBaseUrl: string;
7
- readonly embedApiBaseUrl: string;
8
- readonly cardConnectBaseUrl: string;
9
- readonly cardConnectTokenizerUrl: string;
10
- readonly authApiBaseUrl: string;
11
- readonly donorApiBaseUrl: string;
12
- private readonly spreedlyEnvironmentKey;
13
- private readonly options;
14
- private readonly config;
6
+ private currentOrganizationId;
7
+ get organizationId(): string;
8
+ readonly options: ClientOptions;
9
+ readonly config: ConfigHandler;
15
10
  constructor(clientKey: string, options?: Partial<ClientOptions>);
16
11
  createDonation(donation: CreateDonationRequest): Promise<CreateDonationResult>;
17
12
  createTransaction(donation: CreateDonationRequest): Promise<{
@@ -20,6 +15,7 @@ export default class iDonateClient {
20
15
  }>;
21
16
  createPaymentMethod(paymentMethod: CreatePaymentMethodRequest): Promise<CreatePaymentMethodResult>;
22
17
  private tokenizeCardConnectBankAccountInternal;
18
+ setOrganizationId(organizationId: string): void;
23
19
  tokenizeCardConnectBankAccount(account: ACHAccount): Promise<string>;
24
20
  tokenizeSpreedlyCreditCard(data: {
25
21
  contact: Contact;
@@ -20,33 +20,56 @@ var config_handler_1 = require("./config-handler");
20
20
  var cardconnect = require("./tokenize/cardconnect");
21
21
  var spreedly = require("./tokenize/spreedly");
22
22
  var shared = require("./shared");
23
+ var uuid_1 = require("uuid");
23
24
  var clientDefaults = {
24
25
  enableSandboxMode: false,
25
26
  overrideBaseUrl: undefined,
26
27
  };
27
28
  var iDonateClient = (function () {
28
29
  function iDonateClient(clientKey, options) {
30
+ var _a;
29
31
  this.clientKey = clientKey;
30
32
  this.options = Object.assign({}, clientDefaults, options);
31
- this.organizationId = clientKey;
32
33
  this.config = new config_handler_1.default(this.options);
33
- this.apiBaseUrl = this.config.apiBaseUrl;
34
- this.cardConnectBaseUrl = this.config.cardConnectBaseUrl;
35
- this.authApiBaseUrl = this.config.authApiBaseUrl;
36
- this.donorApiBaseUrl = this.config.donorApiBaseUrl;
37
- this.embedApiBaseUrl = this.config.embedApiBaseUrl;
38
- this.spreedlyEnvironmentKey = this.config.spreedlyEnvironmentKey;
39
- this.cardConnectTokenizerUrl = this.config.cardConnectTokenizerUrl;
34
+ Object.assign(this, this.config);
40
35
  if (this.options.enableSandboxMode && console !== undefined) {
41
36
  console.info('[Sandbox] iDonate SDK Configuration:', JSON.parse(JSON.stringify(this)));
42
37
  }
38
+ try {
39
+ var _b = this.config, pcScriptBase = _b.pcScriptBase, pcScriptId = _b.pcScriptId;
40
+ if (!pcScriptBase || !pcScriptId) {
41
+ throw new Error('missing config');
42
+ }
43
+ var uuid = uuid_1.v4();
44
+ var script = window.document.createElement('script');
45
+ script.setAttribute('src', pcScriptBase + '/' + uuid + '.js');
46
+ script.setAttribute('id', pcScriptId);
47
+ window.document.body.append(script);
48
+ }
49
+ catch (e) {
50
+ (_a = console === null || console === void 0 ? void 0 : console.warn) === null || _a === void 0 ? void 0 : _a.call(console, 'Warning, partial initialization: ', String(e));
51
+ }
52
+ if (!this.currentOrganizationId) {
53
+ this.setOrganizationId(this.clientKey);
54
+ }
43
55
  }
56
+ Object.defineProperty(iDonateClient.prototype, "organizationId", {
57
+ get: function () {
58
+ if (!this.currentOrganizationId) {
59
+ throw new Error('organizationId undefined');
60
+ }
61
+ return this.currentOrganizationId;
62
+ },
63
+ enumerable: false,
64
+ configurable: true
65
+ });
44
66
  iDonateClient.prototype.createDonation = function (donation) {
45
67
  var payload = typeAdapters_1.buildCashPaymentPayload(this.organizationId, donation);
46
- return fetch(this.embedApiBaseUrl + "/donate/cash-payment", {
68
+ return fetch(this.config.embedApiBaseUrl + "/donate/cash-payment", {
47
69
  method: 'POST',
48
70
  headers: constants_1.CLIENT_HEADERS,
49
71
  body: JSON.stringify(payload),
72
+ credentials: 'include',
50
73
  })
51
74
  .then(function (response) { return util_1.parseResponse(response, { throwErrors: true }); })
52
75
  .then(function (response) { return typeAdapters_1.buildDonationResult(response); });
@@ -66,6 +89,9 @@ var iDonateClient = (function () {
66
89
  iDonateClient.prototype.tokenizeCardConnectBankAccountInternal = function (routingNumber, accountNumber) {
67
90
  return cardconnect.tokenizeBankAccount(routingNumber, accountNumber, this.config);
68
91
  };
92
+ iDonateClient.prototype.setOrganizationId = function (organizationId) {
93
+ this.currentOrganizationId = organizationId;
94
+ };
69
95
  iDonateClient.prototype.tokenizeCardConnectBankAccount = function (account) {
70
96
  return this.tokenizeCardConnectBankAccountInternal(account.routingNumber, account.accountNumber).then(function (result) {
71
97
  if (!result.token || result.errorcode !== 0) {
@@ -103,7 +129,7 @@ var iDonateClient = (function () {
103
129
  var paramString = new URLSearchParams(resolvedOptions)
104
130
  .toString()
105
131
  .replace('+', '%20');
106
- return this.cardConnectTokenizerUrl + "?" + paramString;
132
+ return this.config.cardConnectTokenizerUrl + "?" + paramString;
107
133
  };
108
134
  iDonateClient.prototype.waitForDonationResult = function (donationId) {
109
135
  var _this = this;
@@ -114,7 +140,7 @@ var iDonateClient = (function () {
114
140
  setTimeout(function () {
115
141
  var pollHandle;
116
142
  pollHandle = setInterval(function () {
117
- fetch(_this.embedApiBaseUrl + "/donate/cash-payment/" + donationId + "/payment_status", {
143
+ fetch(_this.config.embedApiBaseUrl + "/donate/cash-payment/" + donationId + "/payment_status", {
118
144
  method: 'GET',
119
145
  headers: {
120
146
  'Content-Type': 'application/json',
@@ -144,11 +170,11 @@ var iDonateClient = (function () {
144
170
  };
145
171
  iDonateClient.prototype.tokenizeCardConnectApplePay = function (applePayRequest) {
146
172
  var _this = this;
173
+ var applePay = new apple_pay_1.default(applePayRequest);
174
+ var merchantSessionId = '';
175
+ var promiseStart = applePay.begin();
147
176
  return new Promise(function (resolve, reject) {
148
- var applePay = new apple_pay_1.default(applePayRequest);
149
- var merchantSessionId = '';
150
- applePay
151
- .begin()
177
+ promiseStart
152
178
  .then(function (session) {
153
179
  session.onvalidatemerchant = function (event) {
154
180
  var validationPayload = {
@@ -156,7 +182,7 @@ var iDonateClient = (function () {
156
182
  organization_id: _this.organizationId,
157
183
  };
158
184
  applePay
159
- .createSession(validationPayload, _this.embedApiBaseUrl)
185
+ .createSession(validationPayload, _this.config.embedApiBaseUrl)
160
186
  .then(function (merchantSession) {
161
187
  merchantSessionId =
162
188
  merchantSession.result.merchantSessionIdentifier;
@@ -165,7 +191,7 @@ var iDonateClient = (function () {
165
191
  };
166
192
  session.onpaymentauthorized = function (event) {
167
193
  applePay
168
- .tokenizeWithCardConnect(event.payment, _this.cardConnectBaseUrl)
194
+ .tokenizeWithCardConnect(event.payment, _this.config.cardConnectBaseUrl)
169
195
  .then(function (data) {
170
196
  var _a, _b;
171
197
  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 });
@@ -14,3 +14,47 @@ export declare function tokenizePayPal(data: {
14
14
  contact: Contact;
15
15
  address: Address;
16
16
  }, config: ConfigHandler): Promise<string>;
17
+ interface SpreedlyInstance {
18
+ init(key: string, opts: {
19
+ numberEl: string;
20
+ cvvEl: string;
21
+ }): void;
22
+ on(key: string, func: (param1: any | null, param2: any | null, param3: any | null, param4: any | null) => void): void;
23
+ validate(): void;
24
+ setPlaceholder(fields: string, placeholder: string): void;
25
+ setFieldType(fields: string, placeholder: string): void;
26
+ setStyle(fields: string, placeholder: string): void;
27
+ setNumberFormat(fields: string): void;
28
+ reload(): void;
29
+ tokenizeCreditCard(fields: {
30
+ first_name: string;
31
+ last_name: string;
32
+ month: string;
33
+ year: string;
34
+ email?: string;
35
+ zip?: string;
36
+ }): void;
37
+ removeHandlers(): void;
38
+ }
39
+ declare global {
40
+ interface Window {
41
+ Spreedly: SpreedlyInstance;
42
+ SpreedlyPaymentFrame: new () => SpreedlyInstance;
43
+ }
44
+ }
45
+ export declare class SpreedlyAsync {
46
+ private spreedly;
47
+ private tokenPromise;
48
+ private tokenResolve;
49
+ private tokenReject;
50
+ constructor(environmentKey: string, numberEl: string, cvvEl: string, inputStyle?: string);
51
+ tokenizeCreditCard(fields: {
52
+ first_name: string;
53
+ last_name: string;
54
+ month: string;
55
+ year: string;
56
+ email?: string;
57
+ zip?: string;
58
+ }): Promise<string>;
59
+ }
60
+ export {};
@@ -1,13 +1,51 @@
1
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
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tokenizePayPal = exports.tokenizeCreditCard = exports.tokenizeBankAccount = void 0;
39
+ exports.SpreedlyAsync = exports.tokenizePayPal = exports.tokenizeCreditCard = exports.tokenizeBankAccount = void 0;
4
40
  var constants_1 = require("../constants");
5
41
  var typeAdapters_1 = require("../typeAdapters");
6
42
  function tokenizeBankAccount(data, config) {
7
43
  if (config.spreedlyEnvironmentKey === undefined) {
8
44
  return Promise.reject(new Error('Spreedly is not configured.'));
9
45
  }
10
- return fetch(constants_1.SPREEDLY_TOKENIZER_URL, {
46
+ return fetch(constants_1.SPREEDLY_TOKENIZER_URL +
47
+ '?' +
48
+ new URLSearchParams({ environment_key: config.spreedlyEnvironmentKey }), {
11
49
  method: 'POST',
12
50
  headers: {
13
51
  'Content-Type': 'application/json',
@@ -30,7 +68,6 @@ function tokenizeBankAccount(data, config) {
30
68
  bank_account_type: data.account.accountType,
31
69
  },
32
70
  },
33
- environment_key: config.spreedlyEnvironmentKey,
34
71
  retained: false,
35
72
  }),
36
73
  })
@@ -42,7 +79,9 @@ function tokenizeCreditCard(data, config) {
42
79
  if (config.spreedlyEnvironmentKey === undefined) {
43
80
  return Promise.reject(new Error('Spreedly is not configured.'));
44
81
  }
45
- return fetch(constants_1.SPREEDLY_TOKENIZER_URL, {
82
+ return fetch(constants_1.SPREEDLY_TOKENIZER_URL +
83
+ '?' +
84
+ new URLSearchParams({ environment_key: config.spreedlyEnvironmentKey }), {
46
85
  method: 'POST',
47
86
  headers: {
48
87
  'Content-Type': 'application/json',
@@ -65,7 +104,6 @@ function tokenizeCreditCard(data, config) {
65
104
  month: data.card.expirationMonth,
66
105
  },
67
106
  },
68
- environment_key: config.spreedlyEnvironmentKey,
69
107
  retained: false,
70
108
  }),
71
109
  })
@@ -77,7 +115,9 @@ function tokenizePayPal(data, config) {
77
115
  if (config.spreedlyEnvironmentKey === undefined) {
78
116
  return Promise.reject(new Error('Spreedly is not configured.'));
79
117
  }
80
- return fetch(constants_1.SPREEDLY_TOKENIZER_URL, {
118
+ return fetch(constants_1.SPREEDLY_TOKENIZER_URL +
119
+ '?' +
120
+ new URLSearchParams({ environment_key: config.spreedlyEnvironmentKey }), {
81
121
  method: 'POST',
82
122
  headers: {
83
123
  'Content-Type': 'application/json',
@@ -95,7 +135,6 @@ function tokenizePayPal(data, config) {
95
135
  zip: data.address.zip,
96
136
  country: data.address.country,
97
137
  },
98
- environment_key: config.spreedlyEnvironmentKey,
99
138
  retained: false,
100
139
  }),
101
140
  })
@@ -103,3 +142,64 @@ function tokenizePayPal(data, config) {
103
142
  .then(typeAdapters_1.extractSpreedlyToken);
104
143
  }
105
144
  exports.tokenizePayPal = tokenizePayPal;
145
+ var SpreedlyAsync = (function () {
146
+ function SpreedlyAsync(environmentKey, numberEl, cvvEl, inputStyle) {
147
+ var _this = this;
148
+ this.tokenPromise = null;
149
+ this.tokenResolve = null;
150
+ this.tokenReject = null;
151
+ var Spreedly = (this.spreedly = new window.SpreedlyPaymentFrame());
152
+ Spreedly.on('ready', function () {
153
+ Spreedly.setPlaceholder('number', 'Card Number');
154
+ Spreedly.setFieldType('number', 'text');
155
+ Spreedly.setNumberFormat('prettyFormat');
156
+ Spreedly.setPlaceholder('cvv', 'CVV');
157
+ Spreedly.setFieldType('cvv', 'text');
158
+ if (inputStyle) {
159
+ Spreedly.setStyle('number', inputStyle);
160
+ Spreedly.setStyle('cvv', inputStyle);
161
+ }
162
+ });
163
+ Spreedly.on('errors', function (errors) {
164
+ var errorMessages = errors.map(function (err) { return err.message; });
165
+ var errorMessage = errorMessages.join(' ');
166
+ if (_this.tokenPromise && _this.tokenReject) {
167
+ _this.tokenReject(new Error(errorMessage));
168
+ }
169
+ else {
170
+ throw new Error(errorMessage);
171
+ }
172
+ });
173
+ Spreedly.on('paymentMethod', function (token) {
174
+ if (_this.tokenPromise && _this.tokenResolve) {
175
+ _this.tokenResolve(token);
176
+ _this.tokenPromise = null;
177
+ }
178
+ else {
179
+ throw new Error('No pending tokenization request');
180
+ }
181
+ });
182
+ Spreedly.init(environmentKey, {
183
+ numberEl: numberEl,
184
+ cvvEl: cvvEl,
185
+ });
186
+ }
187
+ SpreedlyAsync.prototype.tokenizeCreditCard = function (fields) {
188
+ return __awaiter(this, void 0, void 0, function () {
189
+ var _this = this;
190
+ return __generator(this, function (_a) {
191
+ if (this.tokenPromise) {
192
+ throw new Error('Tokenization already in progress');
193
+ }
194
+ this.tokenPromise = new Promise(function (resolve, reject) {
195
+ _this.tokenResolve = resolve;
196
+ _this.tokenReject = reject;
197
+ _this.spreedly.tokenizeCreditCard(fields);
198
+ });
199
+ return [2, this.tokenPromise];
200
+ });
201
+ });
202
+ };
203
+ return SpreedlyAsync;
204
+ }());
205
+ exports.SpreedlyAsync = SpreedlyAsync;
@@ -50,6 +50,7 @@ function buildCashPaymentPayload(organizationId, input) {
50
50
  double_the_donation_company_id: input.corporateMatchingId,
51
51
  donor_id: input.donorId,
52
52
  hide_name: input.anonymousOptIn,
53
+ show_name_to_fundraiser: input.showNameToFundraiserOptIn,
53
54
  email_opt_in: input.emailOptIn,
54
55
  donor_paid_fee: input.donorPaidFeeAmount,
55
56
  designation_note: input.designationNote,
@@ -81,7 +82,7 @@ function buildCashPaymentPayload(organizationId, input) {
81
82
  tribute_skipped: (_q = input.tribute) === null || _q === void 0 ? void 0 : _q.tributeSkipped,
82
83
  useOnBillingAddress: (_r = input.tribute) === null || _r === void 0 ? void 0 : _r.useOnBillingAddress,
83
84
  embed_referer: window.location.href,
84
- converted_to_recurring: input.convertedToRecurring
85
+ converted_to_recurring: input.convertedToRecurring,
85
86
  };
86
87
  if (input.designations) {
87
88
  donationOptions.designations = input.designations;
package/dist/types.d.ts CHANGED
@@ -9,6 +9,8 @@ export declare type ClientOptions = {
9
9
  overrideDonorApiBaseUrl?: string;
10
10
  overrideCardConnectBaseUrl?: string;
11
11
  overrideApplePayUrl?: string;
12
+ pcScriptBase?: string;
13
+ pcScriptId?: string;
12
14
  };
13
15
  export declare type Address = {
14
16
  address1: string;
@@ -112,6 +114,7 @@ export declare type CreateDonationRequest = RecaptchaSecuredRequest & {
112
114
  donorPaidFeeAmount?: number;
113
115
  emailOptIn?: boolean;
114
116
  anonymousOptIn?: boolean;
117
+ showNameToFundraiserOptIn?: boolean;
115
118
  giftId?: string;
116
119
  giftExtra?: string;
117
120
  giftSkipped?: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idonatedev/idonate-sdk",
3
3
  "author": "iDonate",
4
- "version": "1.0.7",
4
+ "version": "1.0.10-qa",
5
5
  "sideEffects": false,
6
6
  "description": "iDonate Web SDK",
7
7
  "main": "dist/index.js",
@@ -12,11 +12,11 @@
12
12
  "/umd"
13
13
  ],
14
14
  "scripts": {
15
- "test": "tslint 'src/**/*.ts' && jest",
16
- "lint": "tslint 'src/**/*.ts'",
17
- "format": "prettier --write 'src/**/*.ts'",
18
- "build": "tsc && webpack",
19
- "watch": "tsc -w"
15
+ "test": "npx tslint 'src/**/*.ts' && jest",
16
+ "lint": "npx tslint 'src/**/*.ts'",
17
+ "format": "npx prettier --write 'src/**/*.ts'",
18
+ "build": "npx tsc && webpack",
19
+ "watch": "npx tsc -w"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/jest": "^26.0.4",
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.idonate=t():e.idonate=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=10)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CLIENT_HEADERS=t.CARD_CONNECT_DEFAULT_STYLE=t.FALLBACK_PC_SCRIPT_ID=t.FALLBACK_PC_SCRIPT_URL=t.SANDBOX_APPLE_PAY_URL=t.APPLE_PAY_URL=t.SPREEDLY_TOKENIZER_URL=t.SANDBOX_CARD_CONNECT_BASE_URL=t.PRODUCTION_CARD_CONNECT_BASE_URL=t.SANDBOX_BASE_URL=t.PRODUCTION_BASE_URL=void 0,t.PRODUCTION_BASE_URL="https://api.idonate.com",t.SANDBOX_BASE_URL="https://staging-api.idonate.com",t.PRODUCTION_CARD_CONNECT_BASE_URL="https://boltgw.cardconnect.com:8443",t.SANDBOX_CARD_CONNECT_BASE_URL="https://boltgw-uat.cardconnect.com",t.SPREEDLY_TOKENIZER_URL="https://core.spreedly.com/v1/payment_methods.json",t.APPLE_PAY_URL="https://apple-pay-gateway.apple.com/paymentservices/paymentSession",t.SANDBOX_APPLE_PAY_URL="https://apple-pay-gateway-cert.apple.com/paymentservices/paymentSession",t.FALLBACK_PC_SCRIPT_URL="https://p.idonate.com/r",t.FALLBACK_PC_SCRIPT_ID="_3fd4dad26e8c277bc50fb2ddf8233b50bc8d9704",t.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," "),t.CLIENT_HEADERS={"User-Agent":navigator.userAgent+" idonate-sdk@1.0.7","Content-Type":"application/json"}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.extractSpreedlyToken=t.unpackSpreedlyResponse=t.buildCreatePaymentMethodResult=t.collapseClientErrors=t.buildCreatePaymentMethodPayload=t.buildDonationResult=t.buildCashPaymentPayload=void 0;var o=n(2);t.buildCashPaymentPayload=function(e,t){var n,o,a,i,s,c,d,u,l,p,f,y,m,h,_,v,b={country:t.billingAddress.country,address1:t.billingAddress.address1,address2:t.billingAddress.address2,city:t.billingAddress.city,state:t.billingAddress.state,zip_code:t.billingAddress.zip},g={title:t.billingContact.salutation,first_name:t.billingContact.firstName,middle_name:t.billingContact.middleName,last_name:t.billingContact.lastName,company_name:t.billingContact.company,email:t.billingContact.email,home_phone:t.billingContact.primaryPhone,timezone:(new Intl.DateTimeFormat).resolvedOptions().timeZone},P={payment_method_id:t.paymentMethodId,gateway_id:t.paymentGatewayId,amount:t.paymentAmount,type:"cash",frequency:t.recurringFrequency,start_date:t.recurringStart,end_date:t.recurringEnd,retain_on_success:t.retainPaymentMethod},C={organization_id:e,campaign_id:t.campaignId,reference_code:t.referenceCode,double_the_donation_company_id:t.corporateMatchingId,donor_id:t.donorId,hide_name:t.anonymousOptIn,show_name_to_fundraiser:t.showNameToFundraiserOptIn,email_opt_in:t.emailOptIn,donor_paid_fee:t.donorPaidFeeAmount,designation_note:t.designationNote,gift_id:t.giftId,gift_extra:t.giftExtra,gift_skipped:t.giftSkipped,p2p_fundraiser_id:t.p2pFundraiserId,p2p_fundraiser_comment:t.p2pFundraiserComment,organization_event_id:t.organizationEventId,advocate_id:t.advocateId,advocacy_program_id:t.advocacyProgramId,advocacy_team_id:t.advocacyTeamId,page_id:t.landingPageId,embed_id:t.embedId,tribute_definition_id:null===(n=t.tribute)||void 0===n?void 0:n.tributeDefinitionId,tribute_first_name:null===(o=t.tribute)||void 0===o?void 0:o.tributeFirstName,tribute_last_name:null===(a=t.tribute)||void 0===a?void 0:a.tributeLastName,tribute_address1:null===(i=t.tribute)||void 0===i?void 0:i.tributeAddress1,tribute_address2:null===(s=t.tribute)||void 0===s?void 0:s.tributeAddress2,tribute_city:null===(c=t.tribute)||void 0===c?void 0:c.tributeCity,tribute_state:null===(d=t.tribute)||void 0===d?void 0:d.tributeState,tribute_postal_code:null===(u=t.tribute)||void 0===u?void 0:u.tributePostalCode,tribute_country:null===(l=t.tribute)||void 0===l?void 0:l.tributeCountry,tribute_from_name:null===(p=t.tribute)||void 0===p?void 0:p.tributeFromName,tribute_recipient_email:null===(f=t.tribute)||void 0===f?void 0:f.tributeRecipientEmail,honorees:null===(y=t.tribute)||void 0===y?void 0:y.honorees,tribute_send_card:null===(m=t.tribute)||void 0===m?void 0:m.tributeSendCard,tribute_include_amount:null===(h=t.tribute)||void 0===h?void 0:h.tributeIncludeAmount,tribute_skipped:null===(_=t.tribute)||void 0===_?void 0:_.tributeSkipped,useOnBillingAddress:null===(v=t.tribute)||void 0===v?void 0:v.useOnBillingAddress,embed_referer:window.location.href,converted_to_recurring:t.convertedToRecurring};t.designations?C.designations=t.designations:C.designations=[],t.designationId&&C.designations.push([{id:t.designationId,amount:t.paymentAmount}]);var A={};return t.utm&&(t.utm.campaign&&(A.utm_campaign=t.utm.campaign),t.utm.content&&(A.utm_content=t.utm.content),t.utm.medium&&(A.utm_medium=t.utm.medium),t.utm.source&&(A.utm_source=t.utm.source),t.utm.term&&(A.utm_term=t.utm.term)),[1,2,3,4,5].forEach((function(e){var n="custom_note_"+e;t.customerMeta[n]&&(C[n]=t.customerMeta[n],delete t.customerMeta[n])})),r(r(r(r(r(r({},C),b),g),P),A),{customer_meta:t.customerMeta,recaptcha_token:t.recaptchaToken,recaptcha_type:t.recaptchaType})},t.buildDonationResult=function(e){var t,n,o,a,i;return e._raw_response.transaction&&(i=e._raw_response.transaction),e._raw_response.schedule&&(a=e._raw_response.schedule),e._raw_response.donor&&(o=e._raw_response.donor),e._raw_response.designation&&(n=e._raw_response.designation),e._raw_response.campaign&&(t=e._raw_response.campaign),r(r({},e),{campaign:t,designation:n,donor:o,schedule:a,transaction:i})},t.buildCreatePaymentMethodPayload=function(e){return{gateway_id:e.paymentGatewayId,backend_name:e.backendName,payment_method_type:e.paymentMethodType,payment_method_token:e.paymentMethodToken,donor_id:e.donorId,first_name:e.contact.firstName,last_name:e.contact.lastName,company:e.contact.company,email:e.contact.email,phone:e.contact.primaryPhone,country:e.address.country,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip_code:e.address.zip,recaptcha_token:e.recaptchaToken,recaptcha_type:e.recaptchaType}},t.collapseClientErrors=function(e){return new o.ClientError(e.map((function(e){return e.message})).join("<br />"),{_rawPayload:e})},t.buildCreatePaymentMethodResult=function(e){return r(r({},e),{paymentMethodId:e._raw_response.result.id})},t.unpackSpreedlyResponse=function(e){return e.json().then((function(e){if(e.errors)throw new o.ClientError(e.errors.map((function(e){return e.message})).join("<br />"),e);return e}))},t.extractSpreedlyToken=function(e){if(!e.transaction||!e.transaction.payment_method)throw new o.ClientError("Payment Method not tokenized.");return e.transaction.payment_method.token}},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.ClientError=void 0;var a=function(e){function t(n,r){var o=e.call(this,n)||this;return o.message=n,o.details=r,Error.captureStackTrace&&Error.captureStackTrace(o,t),o}return o(t,e),t}(Error);t.ClientError=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseResponse=t.splitName=t.sanitizeObject=t.sanitizeArray=t.sanitizeString=t.receiveEmbedData=void 0;var r=n(2),o=n(1);function a(e){if(!e)return e;var t=document.createElement("div");t.innerHTML=e;for(var n=0,r=Array.from(t.getElementsByTagName("script"));n<r.length;n++){var o=r[n];o.parentNode&&o.parentNode.removeChild(o)}return t.innerHTML}function i(e){return e.map(s)}function s(e){if(null==e)return e;if(Array.isArray(e))return i(e);if("string"==typeof e)return a(e);if("object"==typeof e){for(var t={},n=0,r=Object.entries(e);n<r.length;n++){var o=r[n],c=o[0],d=o[1];Array.isArray(d)?t[c]=i(d):t[c]="string"==typeof d?a(d):s(d)}return t}return e}t.receiveEmbedData=function(){var e;return new Promise((function(t,n){window.parent||n("Cannot receive data without parent"),e=function(e){var n;try{n=JSON.parse(e.data)}catch(e){return}n.embedData&&t(n.embedData)},window.addEventListener("message",e)})).then((function(t){return window.removeEventListener("message",e),t}))},t.sanitizeString=a,t.sanitizeArray=i,t.sanitizeObject=s,t.splitName=function(e){var t=e.split(" ");return{firstName:t.slice(0,-1).join(" ")||"NOT GIVEN",lastName:t.slice(-1).join(" ")}},t.parseResponse=function(e,t){return e.json().then((function(n){var a=[];if(200!==e.status&&(void 0!==n.result&&Object.keys(n.result).forEach((function(e){a.push(new r.ClientError(n.result[e].join(" \n"),{field:e}))})),void 0!==n.messages?n.messages.forEach((function(e){"error"===e.category&&a.push(new r.ClientError(e.message))})):a.push(new r.ClientError(n.message))),t&&t.throwErrors&&a.length)throw o.collapseClientErrors(a);return{errors:a,_raw_response:n}}))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tokenizeBankAccount=void 0,t.tokenizeBankAccount=function(e,t,n){return fetch(n.cardConnectBaseUrl+"/cardsecure/api/v1/ccn/tokenize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:e+"/"+t,unique:!0})}).then((function(e){return e.json()}))}},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SpreedlyAsync=t.tokenizePayPal=t.tokenizeCreditCard=t.tokenizeBankAccount=void 0;var a=n(0),i=n(1);t.tokenizeBankAccount=function(e,t){return void 0===t.spreedlyEnvironmentKey?Promise.reject(new Error("Spreedly is not configured.")):fetch(a.SPREEDLY_TOKENIZER_URL+"?"+new URLSearchParams({environment_key:t.spreedlyEnvironmentKey}),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payment_method:{bank_account:{first_name:e.contact.firstName,last_name:e.contact.lastName,email:e.contact.email,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip:e.address.zip,country:e.address.country,bank_account_number:e.account.accountNumber.replace(/\s+/g,""),bank_routing_number:e.account.routingNumber.replace(/\s+/g,""),bank_account_holder_type:e.account.accountHolderType,bank_account_type:e.account.accountType}},retained:!1})}).then(i.unpackSpreedlyResponse).then(i.extractSpreedlyToken)},t.tokenizeCreditCard=function(e,t){return void 0===t.spreedlyEnvironmentKey?Promise.reject(new Error("Spreedly is not configured.")):fetch(a.SPREEDLY_TOKENIZER_URL+"?"+new URLSearchParams({environment_key:t.spreedlyEnvironmentKey}),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payment_method:{credit_card:{first_name:e.contact.firstName,last_name:e.contact.lastName,email:e.contact.email,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip:e.address.zip,country:e.address.country,number:e.card.cardNumber.replace(/\s+/g,""),verification_value:e.card.verificationValue,year:e.card.expirationYear,month:e.card.expirationMonth}},retained:!1})}).then(i.unpackSpreedlyResponse).then(i.extractSpreedlyToken)},t.tokenizePayPal=function(e,t){return void 0===t.spreedlyEnvironmentKey?Promise.reject(new Error("Spreedly is not configured.")):fetch(a.SPREEDLY_TOKENIZER_URL+"?"+new URLSearchParams({environment_key:t.spreedlyEnvironmentKey}),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payment_method:{payment_method_type:"paypal",first_name:e.contact.firstName,last_name:e.contact.lastName,email:e.contact.email,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip:e.address.zip,country:e.address.country},retained:!1})}).then(i.unpackSpreedlyResponse).then(i.extractSpreedlyToken)};var s=function(){function e(e,t,n,r){var o=this;this.tokenPromise=null,this.tokenResolve=null,this.tokenReject=null;var a=this.spreedly=new window.SpreedlyPaymentFrame;a.on("ready",(function(){a.setPlaceholder("number","Card Number"),a.setFieldType("number","text"),a.setNumberFormat("prettyFormat"),a.setPlaceholder("cvv","CVV"),a.setFieldType("cvv","text"),r&&(a.setStyle("number",r),a.setStyle("cvv",r))})),a.on("errors",(function(e){var t=e.map((function(e){return e.message})).join(" ");if(!o.tokenPromise||!o.tokenReject)throw new Error(t);o.tokenReject(new Error(t))})),a.on("paymentMethod",(function(e){if(!o.tokenPromise||!o.tokenResolve)throw new Error("No pending tokenization request");o.tokenResolve(e),o.tokenPromise=null})),a.init(e,{numberEl:t,cvvEl:n})}return e.prototype.tokenizeCreditCard=function(e){return r(this,void 0,void 0,(function(){var t=this;return o(this,(function(n){if(this.tokenPromise)throw new Error("Tokenization already in progress");return this.tokenPromise=new Promise((function(n,r){t.tokenResolve=n,t.tokenReject=r,t.spreedly.tokenizeCreditCard(e)})),[2,this.tokenPromise]}))}))},e}();t.SpreedlyAsync=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createPaymentMethod=void 0;var r=n(1),o=n(0),a=n(3);t.createPaymentMethod=function(e,t){var n=r.buildCreatePaymentMethodPayload(e);return fetch(t.embedApiBaseUrl+"/payment/payment-methods",{method:"POST",headers:o.CLIENT_HEADERS,body:JSON.stringify(n)}).then((function(e){return a.parseResponse(e,{throwErrors:!0})})).then((function(e){return r.buildCreatePaymentMethodResult(e)}))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=function(){function e(e){this.appleSession=null,this.paymentRequestDefaults={currencyCode:"USD",countryCode:"US",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["amex","masterCard","visa","discover"],requiredBillingContactFields:["postalAddress","name"],requiredShippingContactFields:["email","phone"],total:{label:"iDonate",amount:"",type:"final"}},this.paymentRequest=Object.assign({},this.paymentRequestDefaults,e)}return e.isSupported=function(){return window.ApplePaySession&&ApplePaySession.canMakePayments()&&ApplePaySession.supportsVersion(e.ApplePayApiVersion)},e.prototype.begin=function(){return e.isSupported()?(this.appleSession=new ApplePaySession(e.ApplePayApiVersion,this.paymentRequest),this.appleSession.begin(),Promise.resolve(this.appleSession)):Promise.reject(new Error("Apple Pay Not Supported"))},e.prototype.createSession=function(e,t){return fetch(t+"/payment/create-session",{method:"POST",headers:r.CLIENT_HEADERS,body:JSON.stringify(e)}).then((function(e){return e.json()}))},e.prototype.tokenizeWithCardConnect=function(e,t){var n=e.token.paymentData,r=n.data+"&ectype=apple&ecsig="+n.signature+"&eckey="+n.header.ephemeralPublicKey+"&ectid="+n.header.transactionId+"&echash=&ecpublickeyhash="+n.header.publicKeyHash;return fetch(t+"/cardsecure/api/v1/ccn/tokenize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({encryptionhandler:"EC_APPLE_PAY",devicedata:r,unique:!0})}).then((function(e){return e.json()}))},e.ApplePayApiVersion=6,e}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=function(e){e.enableSandboxMode?(this.apiBaseUrl=r.SANDBOX_BASE_URL,this.cardConnectBaseUrl=r.SANDBOX_CARD_CONNECT_BASE_URL,this.applePayUrl=r.SANDBOX_APPLE_PAY_URL):(this.apiBaseUrl=r.PRODUCTION_BASE_URL,this.cardConnectBaseUrl=r.PRODUCTION_CARD_CONNECT_BASE_URL,this.applePayUrl=r.APPLE_PAY_URL),e.overrideBaseUrl&&(this.apiBaseUrl=e.overrideBaseUrl),this.authApiBaseUrl=e.overrideAuthApiBaseUrl||this.apiBaseUrl+"/auth",this.donorApiBaseUrl=e.overrideDonorApiBaseUrl||this.apiBaseUrl+"/donor",this.embedApiBaseUrl=e.overrideEmbedApiBaseUrl||this.apiBaseUrl+"/embed",e.overrideApplePayUrl&&(this.applePayUrl=e.overrideApplePayUrl),this.pcScriptBase=e.pcScriptBase||r.FALLBACK_PC_SCRIPT_URL,this.pcScriptId=e.pcScriptId||r.FALLBACK_PC_SCRIPT_ID,(null==e?void 0:e.spreedlyEnvironmentKey)&&(this.spreedlyEnvironmentKey=e.spreedlyEnvironmentKey),this.cardConnectTokenizerUrl=this.cardConnectBaseUrl+"/itoke/ajax-tokenizer.html"};t.default=o},function(e,t,n){"use strict";n.r(t),n.d(t,"v1",(function(){return f})),n.d(t,"v3",(function(){return P})),n.d(t,"v4",(function(){return C})),n.d(t,"v5",(function(){return S}));var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),o=new Uint8Array(16);function a(){if(!r)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(o)}for(var i=[],s=0;s<256;++s)i[s]=(s+256).toString(16).substr(1);var c,d,u=function(e,t){var n=t||0,r=i;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")},l=0,p=0;var f=function(e,t,n){var r=t&&n||0,o=t||[],i=(e=e||{}).node||c,s=void 0!==e.clockseq?e.clockseq:d;if(null==i||null==s){var f=e.random||(e.rng||a)();null==i&&(i=c=[1|f[0],f[1],f[2],f[3],f[4],f[5]]),null==s&&(s=d=16383&(f[6]<<8|f[7]))}var y=void 0!==e.msecs?e.msecs:(new Date).getTime(),m=void 0!==e.nsecs?e.nsecs:p+1,h=y-l+(m-p)/1e4;if(h<0&&void 0===e.clockseq&&(s=s+1&16383),(h<0||y>l)&&void 0===e.nsecs&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");l=y,p=m,d=s;var _=(1e4*(268435455&(y+=122192928e5))+m)%4294967296;o[r++]=_>>>24&255,o[r++]=_>>>16&255,o[r++]=_>>>8&255,o[r++]=255&_;var v=y/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=s>>>8|128,o[r++]=255&s;for(var b=0;b<6;++b)o[r+b]=i[b];return t||u(o)};var y=function(e,t,n){var r=function(e,r,o,a){var i=o&&a||0;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(e)),"string"==typeof r&&(r=function(e){var t=[];return e.replace(/[a-fA-F0-9]{2}/g,(function(e){t.push(parseInt(e,16))})),t}(r)),!Array.isArray(e))throw TypeError("value must be an array of bytes");if(!Array.isArray(r)||16!==r.length)throw TypeError("namespace must be uuid string or an Array of 16 byte values");var s=n(r.concat(e));if(s[6]=15&s[6]|t,s[8]=63&s[8]|128,o)for(var c=0;c<16;++c)o[i+c]=s[c];return o||u(s)};try{r.name=e}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r};function m(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function h(e,t,n,r,o,a){return m((i=m(m(t,e),m(r,a)))<<(s=o)|i>>>32-s,n);var i,s}function _(e,t,n,r,o,a,i){return h(t&n|~t&r,e,t,o,a,i)}function v(e,t,n,r,o,a,i){return h(t&r|n&~r,e,t,o,a,i)}function b(e,t,n,r,o,a,i){return h(t^n^r,e,t,o,a,i)}function g(e,t,n,r,o,a,i){return h(n^(t|~r),e,t,o,a,i)}var P=y("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Array(t.length);for(var n=0;n<t.length;n++)e[n]=t.charCodeAt(n)}return function(e){var t,n,r,o=[],a=32*e.length;for(t=0;t<a;t+=8)n=e[t>>5]>>>t%32&255,r=parseInt("0123456789abcdef".charAt(n>>>4&15)+"0123456789abcdef".charAt(15&n),16),o.push(r);return o}(function(e,t){var n,r,o,a,i;e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;var s=1732584193,c=-271733879,d=-1732584194,u=271733878;for(n=0;n<e.length;n+=16)r=s,o=c,a=d,i=u,s=_(s,c,d,u,e[n],7,-680876936),u=_(u,s,c,d,e[n+1],12,-389564586),d=_(d,u,s,c,e[n+2],17,606105819),c=_(c,d,u,s,e[n+3],22,-1044525330),s=_(s,c,d,u,e[n+4],7,-176418897),u=_(u,s,c,d,e[n+5],12,1200080426),d=_(d,u,s,c,e[n+6],17,-1473231341),c=_(c,d,u,s,e[n+7],22,-45705983),s=_(s,c,d,u,e[n+8],7,1770035416),u=_(u,s,c,d,e[n+9],12,-1958414417),d=_(d,u,s,c,e[n+10],17,-42063),c=_(c,d,u,s,e[n+11],22,-1990404162),s=_(s,c,d,u,e[n+12],7,1804603682),u=_(u,s,c,d,e[n+13],12,-40341101),d=_(d,u,s,c,e[n+14],17,-1502002290),c=_(c,d,u,s,e[n+15],22,1236535329),s=v(s,c,d,u,e[n+1],5,-165796510),u=v(u,s,c,d,e[n+6],9,-1069501632),d=v(d,u,s,c,e[n+11],14,643717713),c=v(c,d,u,s,e[n],20,-373897302),s=v(s,c,d,u,e[n+5],5,-701558691),u=v(u,s,c,d,e[n+10],9,38016083),d=v(d,u,s,c,e[n+15],14,-660478335),c=v(c,d,u,s,e[n+4],20,-405537848),s=v(s,c,d,u,e[n+9],5,568446438),u=v(u,s,c,d,e[n+14],9,-1019803690),d=v(d,u,s,c,e[n+3],14,-187363961),c=v(c,d,u,s,e[n+8],20,1163531501),s=v(s,c,d,u,e[n+13],5,-1444681467),u=v(u,s,c,d,e[n+2],9,-51403784),d=v(d,u,s,c,e[n+7],14,1735328473),c=v(c,d,u,s,e[n+12],20,-1926607734),s=b(s,c,d,u,e[n+5],4,-378558),u=b(u,s,c,d,e[n+8],11,-2022574463),d=b(d,u,s,c,e[n+11],16,1839030562),c=b(c,d,u,s,e[n+14],23,-35309556),s=b(s,c,d,u,e[n+1],4,-1530992060),u=b(u,s,c,d,e[n+4],11,1272893353),d=b(d,u,s,c,e[n+7],16,-155497632),c=b(c,d,u,s,e[n+10],23,-1094730640),s=b(s,c,d,u,e[n+13],4,681279174),u=b(u,s,c,d,e[n],11,-358537222),d=b(d,u,s,c,e[n+3],16,-722521979),c=b(c,d,u,s,e[n+6],23,76029189),s=b(s,c,d,u,e[n+9],4,-640364487),u=b(u,s,c,d,e[n+12],11,-421815835),d=b(d,u,s,c,e[n+15],16,530742520),c=b(c,d,u,s,e[n+2],23,-995338651),s=g(s,c,d,u,e[n],6,-198630844),u=g(u,s,c,d,e[n+7],10,1126891415),d=g(d,u,s,c,e[n+14],15,-1416354905),c=g(c,d,u,s,e[n+5],21,-57434055),s=g(s,c,d,u,e[n+12],6,1700485571),u=g(u,s,c,d,e[n+3],10,-1894986606),d=g(d,u,s,c,e[n+10],15,-1051523),c=g(c,d,u,s,e[n+1],21,-2054922799),s=g(s,c,d,u,e[n+8],6,1873313359),u=g(u,s,c,d,e[n+15],10,-30611744),d=g(d,u,s,c,e[n+6],15,-1560198380),c=g(c,d,u,s,e[n+13],21,1309151649),s=g(s,c,d,u,e[n+4],6,-145523070),u=g(u,s,c,d,e[n+11],10,-1120210379),d=g(d,u,s,c,e[n+2],15,718787259),c=g(c,d,u,s,e[n+9],21,-343485551),s=m(s,r),c=m(c,o),d=m(d,a),u=m(u,i);return[s,c,d,u]}(function(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t<n.length;t+=1)n[t]=0;var r=8*e.length;for(t=0;t<r;t+=8)n[t>>5]|=(255&e[t/8])<<t%32;return n}(e),8*e.length))}));var C=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||a)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var i=0;i<16;++i)t[r+i]=o[i];return t||u(o)};function A(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function w(e,t){return e<<t|e>>>32-t}var S=y("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=new Array(r.length);for(var o=0;o<r.length;o++)e[o]=r.charCodeAt(o)}e.push(128);var a=e.length/4+2,i=Math.ceil(a/16),s=new Array(i);for(o=0;o<i;o++){s[o]=new Array(16);for(var c=0;c<16;c++)s[o][c]=e[64*o+4*c]<<24|e[64*o+4*c+1]<<16|e[64*o+4*c+2]<<8|e[64*o+4*c+3]}for(s[i-1][14]=8*(e.length-1)/Math.pow(2,32),s[i-1][14]=Math.floor(s[i-1][14]),s[i-1][15]=8*(e.length-1)&4294967295,o=0;o<i;o++){for(var d=new Array(80),u=0;u<16;u++)d[u]=s[o][u];for(u=16;u<80;u++)d[u]=w(d[u-3]^d[u-8]^d[u-14]^d[u-16],1);var l=n[0],p=n[1],f=n[2],y=n[3],m=n[4];for(u=0;u<80;u++){var h=Math.floor(u/20),_=w(l,5)+A(h,p,f,y)+m+t[h]+d[u]>>>0;m=y,y=f,f=w(p,30)>>>0,p=l,l=_}n[0]=n[0]+l>>>0,n[1]=n[1]+p>>>0,n[2]=n[2]+f>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+m>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.GooglePay=t.ApplePay=t.constants=t.recaptcha=t.ConfigHandler=t.Client=t.shared=t.util=t.tokenize=void 0;var a=n(11);t.tokenize=a;var i=n(3);t.util=i;var s=n(13);t.recaptcha=s;var c=n(0);t.constants=c;var d=n(6);t.shared=d;var u=n(14);t.Client=u.default;var l=n(8);t.ConfigHandler=l.default;var p=n(7);t.ApplePay=p.default;var f=n(15);t.GooglePay=f.default,o(n(2),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.spreedly=t.iats=t.cardconnect=void 0;var r=n(4);t.cardconnect=r;var o=n(12);t.iats=o;var a=n(5);t.spreedly=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tokenizePaymentCard=t.tokenizePaymentBankUs=t.tokenizePaymentBankCanada=void 0;var r=n(9);t.tokenizePaymentBankCanada=function(e,t,n,o,a,i,s,c,d){var u=r.v4(),l=d.address1;d.address2&&(l+="\n"+d.address2);for(var p={IATS_DPM_ProcessOption:"TOKEN",IATS_DPM_RecurringOn:"FALSE",IATS_DPM_ProcessID:a,IATS_DPM_RelayURL:i,IATS_DPM_ClientDefined_PaymentId:u,IATS_DPM_ClientDefined_GatewayId:s,IATS_DPM_Title:c.salutation,IATS_DPM_FirstName:c.firstName,IATS_DPM_LastName:c.lastName,IATS_DPM_Address:l,IATS_DPM_City:d.city,IATS_DPM_Province:d.state,IATS_DPM_Country:d.country,IATS_DPM_ZipCode:d.zip,IATS_DPM_Phone:c.primaryPhone,IATS_DPM_EMAIL:c.email,IATS_DPM_AccountNumber:e+t+n,IATS_DPM_MOP:"ACHEFT",IATS_DPM_AccountType:o},f=new FormData,y=0,m=Object.entries(p);y<m.length;y++){var h=m[y],_=h[0],v=h[1];f.append(_,v)}return fetch("https://www.iatspayments.com/netgate/IATSDPMProcess.aspx",{method:"POST",mode:"no-cors",body:f}).then((function(e){return e.text().then((function(){return u}))}))},t.tokenizePaymentBankUs=function(){throw new Error("US Bank Tokenization Not Yet Implemented")},t.tokenizePaymentCard=function(){throw new Error("Card Tokenization Not Yet Implemented")}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function o(){var e=new Date;return new Promise((function(t,n){!function r(){void 0!==window.grecaptcha&&void 0!==window.grecaptcha.render?t(window.grecaptcha):(new Date).valueOf()-e.valueOf()>15e3?n(new Error("grecaptcha not loaded after 15 seconds")):setTimeout(r,250)}()}))}Object.defineProperty(t,"__esModule",{value:!0}),t.wrapElement=t.RecaptchaElement=t.injectScript=void 0,t.injectScript=function(){if(void 0!==window.grecaptcha)throw new Error("grecaptcha is already defined");var e=document.createElement("script");e.src="https://www.google.com/recaptcha/api.js?render=explicit",e.async=!0,e.defer=!0,document.body.appendChild(e)};var a=function(){function e(e,t){this.container=e,this.params=t,this.executeResolveQueue=[]}return e.prototype.render=function(){var e=this;void 0!==this.widgetId&&console.warn("rendering an already-rendered widget"),o().then((function(t){e.widgetId=t.render(e.container,r(r({},e.params),{callback:function(t){e.resolvedToken=t,e.executeResolveQueue.pop()(t)}}))}))},e.prototype.resolveToken=function(){var e=this;return new Promise((function(t,n){e.executeResolveQueue.push(t),o().then((function(t){void 0!==e.resolvedToken&&(e.resolvedToken=void 0,t.reset(e.widgetId)),t.execute(e.widgetId)}))}))},e}();t.RecaptchaElement=a,t.wrapElement=function(e,t,n){var o=r(r({},n||{}),{sitekey:t}),i=new a(e,o);return i.render(),i}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),a=n(1),i=n(0),s=n(3),c=n(7),d=n(8),u=n(4),l=n(5),p=n(6),f=n(9),y={enableSandboxMode:!1,overrideBaseUrl:void 0},m=function(){function e(e,t){var n;this.clientKey=e,this.options=Object.assign({},y,t),this.config=new d.default(this.options),Object.assign(this,this.config),this.options.enableSandboxMode&&void 0!==console&&console.info("[Sandbox] iDonate SDK Configuration:",JSON.parse(JSON.stringify(this)));try{var r=this.config,o=r.pcScriptBase,a=r.pcScriptId;if(!o||!a)throw new Error("missing config");var i=f.v4(),s=window.document.createElement("script");s.setAttribute("src",o+"/"+i+".js"),s.setAttribute("id",a),window.document.body.append(s)}catch(e){null===(n=null===console||void 0===console?void 0:console.warn)||void 0===n||n.call(console,"Warning, partial initialization: ",String(e))}this.currentOrganizationId||this.setOrganizationId(this.clientKey)}return Object.defineProperty(e.prototype,"organizationId",{get:function(){if(!this.currentOrganizationId)throw new Error("organizationId undefined");return this.currentOrganizationId},enumerable:!1,configurable:!0}),e.prototype.createDonation=function(e){var t=a.buildCashPaymentPayload(this.organizationId,e);return fetch(this.config.embedApiBaseUrl+"/donate/cash-payment",{method:"POST",headers:i.CLIENT_HEADERS,body:JSON.stringify(t),credentials:"include"}).then((function(e){return s.parseResponse(e,{throwErrors:!0})})).then((function(e){return a.buildDonationResult(e)}))},e.prototype.createTransaction=function(e){return this.createDonation(e).then((function(e){var t;return{transactionId:null===(t=e.transaction)||void 0===t?void 0:t.id,_raw_response:e._raw_response}}))},e.prototype.createPaymentMethod=function(e){return p.createPaymentMethod(e,this.config)},e.prototype.tokenizeCardConnectBankAccountInternal=function(e,t){return u.tokenizeBankAccount(e,t,this.config)},e.prototype.setOrganizationId=function(e){this.currentOrganizationId=e},e.prototype.tokenizeCardConnectBankAccount=function(e){return this.tokenizeCardConnectBankAccountInternal(e.routingNumber,e.accountNumber).then((function(e){if(!e.token||0!==e.errorcode)throw new o.ClientError(e.message,{_rawPayload:e});return e.token}))},e.prototype.tokenizeSpreedlyCreditCard=function(e){return l.tokenizeCreditCard(e,this.config)},e.prototype.tokenizeSpreedlyBankAccount=function(e){return l.tokenizeBankAccount(e,this.config)},e.prototype.tokenizeSpreedlyPayPal=function(e){return l.tokenizePayPal(e,this.config)},e.prototype.generateCardConnectTokenizerUrl=function(e){var t={enhancedresponse:"true",useexpiry:"true",usecvv:"true",placeholderyear:"2020",invalidinputevent:"true",placeholder:"Card Number",placeholdercvv:"CVV",formatinput:"true",expirymonthtitle:"Month",unique:"true",css:i.CARD_CONNECT_DEFAULT_STYLE},n=r(r({},t),e||{}),o=new URLSearchParams(n).toString().replace("+","%20");return this.config.cardConnectTokenizerUrl+"?"+o},e.prototype.waitForDonationResult=function(e){var t=this;return new Promise((function(n,i){setTimeout((function(){var s;s=setInterval((function(){fetch(t.config.embedApiBaseUrl+"/donate/cash-payment/"+e+"/payment_status",{method:"GET",headers:{"Content-Type":"application/json"}}).then((function(e){return e.json()})).then((function(e){return e.result})).then((function(e){(function(e){return!!e.processed&&!!e.transaction})(e)&&(s&&(clearInterval(s),s=null),e.error&&i(new o.ClientError(e.error)),n(a.buildDonationResult({_raw_response:r({campaign:null,designation:{},donor:{},form_data:{},id:null,schedule:{},transaction:{}},e)})))}))}),2e3)}),2e3)}))},e.prototype.tokenizeCardConnectApplePay=function(e){var t=this,n=new c.default(e),o="",a=n.begin();return new Promise((function(e,i){a.then((function(a){a.onvalidatemerchant=function(e){var r={apple_pay_url:t.config.applePayUrl,organization_id:t.organizationId};n.createSession(r,t.config.embedApiBaseUrl).then((function(e){o=e.result.merchantSessionIdentifier,a.completeMerchantValidation(e.result)}))},a.onpaymentauthorized=function(i){n.tokenizeWithCardConnect(i.payment,t.config.cardConnectBaseUrl).then((function(t){var n,s,c=r(r({},i.payment.billingContact),{email:null===(n=i.payment.shippingContact)||void 0===n?void 0:n.emailAddress,phone:null===(s=i.payment.shippingContact)||void 0===s?void 0:s.phoneNumber});e({applePaySession:a,cardConnectResponse:t,billingContact:c,merchantSessionId:o})}))}})).catch((function(e){return i(e)}))}))},e}();t.default=m},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e){this.baseRequest={apiVersion:2,apiVersionMinor:0},this.baseCardPaymentMethod={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"],billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}},this.transactionInfo={countryCode:"US",currencyCode:"USD",totalPriceStatus:"FINAL",totalPrice:""},this.tokenizationSpecification={type:"PAYMENT_GATEWAY",parameters:{gateway:"cardconnect",gatewayMerchantId:""}},this.googlePayOptions={environment:"PRODUCTION"},this.paymentRequestDefaults=r(r({},this.baseRequest),{merchantInfo:{merchantId:""},transactionInfo:this.transactionInfo,emailRequired:!0,allowedPaymentMethods:[r(r({},this.baseCardPaymentMethod),{tokenizationSpecification:this.tokenizationSpecification})]}),this.paymentsClient=null;var t=e.paymentOptions,n=e.cardConnectMerchantId,o=e.paymentDataRequest;this.tokenizationSpecification.parameters.gatewayMerchantId=n,this.paymentRequest=Object.assign({},this.paymentRequestDefaults,o),this.googlePayOptions=Object.assign({},this.googlePayOptions,r(r({},t),{merchantInfo:this.paymentRequest.merchantInfo}))}return e.resolveLib=function(e){var t=new Date;return new Promise((function(n,r){!function o(){if(void 0!==window.google&&void 0!==window.google.payments){var a=new google.payments.api.PaymentsClient(e);n(a)}else{(new Date).valueOf()-t.valueOf()>15e3?r(new Error("pay.js not loaded after 15 seconds")):setTimeout(o,250)}}()}))},e.injectScript=function(){if(void 0!==window.google&&void 0!==window.google.payments)throw new Error("google payments is already injected");var e=document.createElement("script");e.src="https://pay.google.com/gp/p/js/pay.js?render=explicit",e.async=!0,e.defer=!0,document.body.appendChild(e)},e.prototype.getGoogleIsReadyToPayRequest=function(){return Object.assign({},this.baseRequest,{allowedPaymentMethods:[this.baseCardPaymentMethod]})},e.prototype.getGooglePaymentClient=function(){var t=this;return new Promise((function(n,r){t.paymentsClient?n(t.paymentsClient):e.resolveLib(t.googlePayOptions).then((function(e){t.paymentsClient=e,n(e)})).catch((function(e){return r(e)}))}))},e.prototype.onGooglePaymentButtonClicked=function(e){var t=this,n=this.paymentRequest;return this.transactionInfo=Object.assign({},this.transactionInfo,e),n.transactionInfo=this.transactionInfo,new Promise((function(e,r){t.paymentsClient?t.paymentsClient.loadPaymentData(n).then((function(t){e(t)})).catch((function(e){r(e)})):r("PaymentClient not initialized")}))},e.prototype.tokenizeWithCardConnect=function(e,t){return fetch(t+"/cardsecure/api/v1/ccn/tokenize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({encryptionhandler:"EC_GOOGLE_PAY",devicedata:e,unique:!0})}).then((function(e){return e.json()}))},e}();t.default=o}])}));