@pelcro/react-pelcro-js 3.26.0-beta.52 → 3.26.0-beta.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +641 -15
- package/dist/index.esm.js +641 -15
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -11898,7 +11898,7 @@ const debounce = (func, waitTime) => {
|
|
|
11898
11898
|
};
|
|
11899
11899
|
};
|
|
11900
11900
|
function getSiteCardProcessor() {
|
|
11901
|
-
var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3;
|
|
11901
|
+
var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _window$Pelcro$site$r4;
|
|
11902
11902
|
if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
|
|
11903
11903
|
return "vantiv";
|
|
11904
11904
|
}
|
|
@@ -11908,6 +11908,9 @@ function getSiteCardProcessor() {
|
|
|
11908
11908
|
if ((_window$Pelcro$site$r3 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r3 !== void 0 && _window$Pelcro$site$r3.cybersource_gateway_settings) {
|
|
11909
11909
|
return "cybersource";
|
|
11910
11910
|
}
|
|
11911
|
+
if ((_window$Pelcro$site$r4 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r4 !== void 0 && _window$Pelcro$site$r4.braintree_gateway_settings) {
|
|
11912
|
+
return "braintree";
|
|
11913
|
+
}
|
|
11911
11914
|
return "stripe";
|
|
11912
11915
|
}
|
|
11913
11916
|
function getFourDigitYear(lastTwoDigits) {
|
|
@@ -12008,6 +12011,7 @@ const loadPaymentSDKs = () => {
|
|
|
12008
12011
|
usePelcro.getStore();
|
|
12009
12012
|
const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_gateway_settings);
|
|
12010
12013
|
const supportsTap = Boolean(window.Pelcro.site.read().tap_gateway_settings);
|
|
12014
|
+
const supportsBraintree = Boolean(window.Pelcro.site.read().braintree_gateway_settings);
|
|
12011
12015
|
if (!window.Stripe && !supportsVantiv && !supportsTap) {
|
|
12012
12016
|
pure_1(window.Pelcro.environment.stripe);
|
|
12013
12017
|
}
|
|
@@ -12015,9 +12019,14 @@ const loadPaymentSDKs = () => {
|
|
|
12015
12019
|
|
|
12016
12020
|
// Load PayPal SDKs
|
|
12017
12021
|
const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
|
|
12022
|
+
if (supportsPaypal || supportsBraintree) {
|
|
12023
|
+
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.99.0/js/client.min.js", "braintree-sdk");
|
|
12024
|
+
}
|
|
12018
12025
|
if (supportsPaypal) {
|
|
12019
|
-
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.
|
|
12020
|
-
|
|
12026
|
+
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.99.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
|
|
12027
|
+
}
|
|
12028
|
+
if (supportsBraintree) {
|
|
12029
|
+
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.99.0/js/hosted-fields.min.js", "braintree-histed-fields-sdk");
|
|
12021
12030
|
}
|
|
12022
12031
|
|
|
12023
12032
|
// Load Vantiv SDKs
|
|
@@ -17222,7 +17231,7 @@ var _isPaymentGatewayInvalid = /*#__PURE__*/new WeakMap();
|
|
|
17222
17231
|
var _generateUserError = /*#__PURE__*/new WeakMap();
|
|
17223
17232
|
class Payment {
|
|
17224
17233
|
/**
|
|
17225
|
-
* @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway|CybersourceGateway)} paymentGateway
|
|
17234
|
+
* @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway|CybersourceGateway|BraintreeGateway)} paymentGateway
|
|
17226
17235
|
*/
|
|
17227
17236
|
constructor(paymentGateway) {
|
|
17228
17237
|
_defineProperty$3(this, "execute", (options, callback) => {
|
|
@@ -17241,7 +17250,7 @@ class Payment {
|
|
|
17241
17250
|
_classPrivateFieldInitSpec$1(this, _isPaymentGatewayInvalid, {
|
|
17242
17251
|
writable: true,
|
|
17243
17252
|
value: gateway => {
|
|
17244
|
-
return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway || gateway instanceof CybersourceGateway);
|
|
17253
|
+
return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway || gateway instanceof CybersourceGateway || gateway instanceof BraintreeGateway);
|
|
17245
17254
|
}
|
|
17246
17255
|
});
|
|
17247
17256
|
_classPrivateFieldInitSpec$1(this, _generateUserError, {
|
|
@@ -17296,7 +17305,8 @@ const PAYMENT_GATEWAYS_ENUM = {
|
|
|
17296
17305
|
paypal: "braintree",
|
|
17297
17306
|
vantiv: "vantiv",
|
|
17298
17307
|
tap: "tap",
|
|
17299
|
-
cybersource: "cybersource"
|
|
17308
|
+
cybersource: "cybersource",
|
|
17309
|
+
braintree: "braintree"
|
|
17300
17310
|
};
|
|
17301
17311
|
|
|
17302
17312
|
/**
|
|
@@ -18235,6 +18245,218 @@ class CybersourceGateway {
|
|
|
18235
18245
|
});
|
|
18236
18246
|
}
|
|
18237
18247
|
}
|
|
18248
|
+
var _paymentGateway6 = /*#__PURE__*/new WeakMap();
|
|
18249
|
+
var _createSubscription6 = /*#__PURE__*/new WeakMap();
|
|
18250
|
+
var _renewSubscription5 = /*#__PURE__*/new WeakMap();
|
|
18251
|
+
var _createGiftedSubscription6 = /*#__PURE__*/new WeakMap();
|
|
18252
|
+
var _renewGiftedSubscription5 = /*#__PURE__*/new WeakMap();
|
|
18253
|
+
var _purchaseEcommerceOrder5 = /*#__PURE__*/new WeakMap();
|
|
18254
|
+
var _payInvoice6 = /*#__PURE__*/new WeakMap();
|
|
18255
|
+
class BraintreeGateway {
|
|
18256
|
+
constructor() {
|
|
18257
|
+
_classPrivateFieldInitSpec$1(this, _paymentGateway6, {
|
|
18258
|
+
writable: true,
|
|
18259
|
+
value: PAYMENT_GATEWAYS_ENUM["braintree"]
|
|
18260
|
+
});
|
|
18261
|
+
_defineProperty$3(this, "execute", (options, callback) => {
|
|
18262
|
+
const types = PAYMENT_TYPES;
|
|
18263
|
+
switch (options.type) {
|
|
18264
|
+
case types.CREATE_SUBSCRIPTION:
|
|
18265
|
+
return _classPrivateFieldGet(this, _createSubscription6).call(this, options, callback);
|
|
18266
|
+
case types.RENEW_SUBSCRIPTION:
|
|
18267
|
+
return _classPrivateFieldGet(this, _renewSubscription5).call(this, options, callback);
|
|
18268
|
+
case types.CREATE_GIFTED_SUBSCRIPTION:
|
|
18269
|
+
return _classPrivateFieldGet(this, _createGiftedSubscription6).call(this, options, callback);
|
|
18270
|
+
case types.RENEW_GIFTED_SUBSCRIPTION:
|
|
18271
|
+
return _classPrivateFieldGet(this, _renewGiftedSubscription5).call(this, options, callback);
|
|
18272
|
+
case types.PURCHASE_ECOMMERCE_ORDER:
|
|
18273
|
+
return _classPrivateFieldGet(this, _purchaseEcommerceOrder5).call(this, options, callback);
|
|
18274
|
+
case types.PAY_INVOICE:
|
|
18275
|
+
return _classPrivateFieldGet(this, _payInvoice6).call(this, options, callback);
|
|
18276
|
+
default:
|
|
18277
|
+
console.error("Unsupported payment method: braintree Gateway");
|
|
18278
|
+
}
|
|
18279
|
+
});
|
|
18280
|
+
_classPrivateFieldInitSpec$1(this, _createSubscription6, {
|
|
18281
|
+
writable: true,
|
|
18282
|
+
value: (options, callback) => {
|
|
18283
|
+
const {
|
|
18284
|
+
token,
|
|
18285
|
+
plan,
|
|
18286
|
+
couponCode,
|
|
18287
|
+
product,
|
|
18288
|
+
quantity = 1,
|
|
18289
|
+
addressId,
|
|
18290
|
+
isExistingSource
|
|
18291
|
+
} = options;
|
|
18292
|
+
const params = isExistingSource ? {
|
|
18293
|
+
source_id: token
|
|
18294
|
+
} : {
|
|
18295
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
|
|
18296
|
+
gateway_token: token
|
|
18297
|
+
};
|
|
18298
|
+
window.Pelcro.subscription.create({
|
|
18299
|
+
quantity,
|
|
18300
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
18301
|
+
plan_id: plan.id,
|
|
18302
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
18303
|
+
coupon_code: couponCode,
|
|
18304
|
+
address_id: product.address_required ? addressId : null,
|
|
18305
|
+
...params
|
|
18306
|
+
}, (err, res) => {
|
|
18307
|
+
callback(err, res);
|
|
18308
|
+
});
|
|
18309
|
+
}
|
|
18310
|
+
});
|
|
18311
|
+
_classPrivateFieldInitSpec$1(this, _renewSubscription5, {
|
|
18312
|
+
writable: true,
|
|
18313
|
+
value: (options, callback) => {
|
|
18314
|
+
const {
|
|
18315
|
+
subscriptionIdToRenew,
|
|
18316
|
+
token,
|
|
18317
|
+
plan,
|
|
18318
|
+
couponCode,
|
|
18319
|
+
product,
|
|
18320
|
+
addressId,
|
|
18321
|
+
isExistingSource
|
|
18322
|
+
} = options;
|
|
18323
|
+
const params = isExistingSource ? {
|
|
18324
|
+
source_id: token
|
|
18325
|
+
} : {
|
|
18326
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
|
|
18327
|
+
gateway_token: token
|
|
18328
|
+
};
|
|
18329
|
+
window.Pelcro.subscription.renew({
|
|
18330
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
18331
|
+
plan_id: plan.id,
|
|
18332
|
+
coupon_code: couponCode,
|
|
18333
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
18334
|
+
subscription_id: subscriptionIdToRenew,
|
|
18335
|
+
address_id: product.address_required ? addressId : null,
|
|
18336
|
+
...params
|
|
18337
|
+
}, (err, res) => {
|
|
18338
|
+
callback(err, res);
|
|
18339
|
+
});
|
|
18340
|
+
}
|
|
18341
|
+
});
|
|
18342
|
+
_classPrivateFieldInitSpec$1(this, _createGiftedSubscription6, {
|
|
18343
|
+
writable: true,
|
|
18344
|
+
value: (options, callback) => {
|
|
18345
|
+
const {
|
|
18346
|
+
token,
|
|
18347
|
+
plan,
|
|
18348
|
+
couponCode,
|
|
18349
|
+
product,
|
|
18350
|
+
giftRecipient,
|
|
18351
|
+
quantity = 1,
|
|
18352
|
+
addressId,
|
|
18353
|
+
isExistingSource
|
|
18354
|
+
} = options;
|
|
18355
|
+
const params = isExistingSource ? {
|
|
18356
|
+
source_id: token
|
|
18357
|
+
} : {
|
|
18358
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
|
|
18359
|
+
gateway_token: token
|
|
18360
|
+
};
|
|
18361
|
+
window.Pelcro.subscription.create({
|
|
18362
|
+
quantity,
|
|
18363
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
18364
|
+
plan_id: plan.id,
|
|
18365
|
+
coupon_code: couponCode,
|
|
18366
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
18367
|
+
gift_recipient_email: giftRecipient.email,
|
|
18368
|
+
gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
|
|
18369
|
+
gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
|
|
18370
|
+
gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
|
|
18371
|
+
gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
|
|
18372
|
+
address_id: product.address_required ? addressId : null,
|
|
18373
|
+
...params
|
|
18374
|
+
}, (err, res) => {
|
|
18375
|
+
callback(err, res);
|
|
18376
|
+
});
|
|
18377
|
+
}
|
|
18378
|
+
});
|
|
18379
|
+
_classPrivateFieldInitSpec$1(this, _renewGiftedSubscription5, {
|
|
18380
|
+
writable: true,
|
|
18381
|
+
value: (options, callback) => {
|
|
18382
|
+
const {
|
|
18383
|
+
subscriptionIdToRenew,
|
|
18384
|
+
token,
|
|
18385
|
+
product,
|
|
18386
|
+
plan,
|
|
18387
|
+
couponCode,
|
|
18388
|
+
addressId,
|
|
18389
|
+
isExistingSource
|
|
18390
|
+
} = options;
|
|
18391
|
+
const params = isExistingSource ? {
|
|
18392
|
+
source_id: token
|
|
18393
|
+
} : {
|
|
18394
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
|
|
18395
|
+
gateway_token: token
|
|
18396
|
+
};
|
|
18397
|
+
window.Pelcro.subscription.renewGift({
|
|
18398
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
18399
|
+
plan_id: plan.id,
|
|
18400
|
+
coupon_code: couponCode,
|
|
18401
|
+
subscription_id: subscriptionIdToRenew,
|
|
18402
|
+
address_id: product.address_required ? addressId : null,
|
|
18403
|
+
...params
|
|
18404
|
+
}, (err, res) => {
|
|
18405
|
+
callback(err, res);
|
|
18406
|
+
});
|
|
18407
|
+
}
|
|
18408
|
+
});
|
|
18409
|
+
_classPrivateFieldInitSpec$1(this, _purchaseEcommerceOrder5, {
|
|
18410
|
+
writable: true,
|
|
18411
|
+
value: (options, callback) => {
|
|
18412
|
+
const {
|
|
18413
|
+
token,
|
|
18414
|
+
items,
|
|
18415
|
+
couponCode,
|
|
18416
|
+
addressId,
|
|
18417
|
+
isExistingSource
|
|
18418
|
+
} = options;
|
|
18419
|
+
const params = isExistingSource ? {
|
|
18420
|
+
source_id: token
|
|
18421
|
+
} : {
|
|
18422
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
|
|
18423
|
+
gateway_token: token
|
|
18424
|
+
};
|
|
18425
|
+
window.Pelcro.ecommerce.order.create({
|
|
18426
|
+
items,
|
|
18427
|
+
coupon_code: couponCode,
|
|
18428
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
18429
|
+
...params,
|
|
18430
|
+
...(addressId && {
|
|
18431
|
+
address_id: addressId
|
|
18432
|
+
})
|
|
18433
|
+
}, (err, res) => {
|
|
18434
|
+
callback(err, res);
|
|
18435
|
+
});
|
|
18436
|
+
}
|
|
18437
|
+
});
|
|
18438
|
+
_classPrivateFieldInitSpec$1(this, _payInvoice6, {
|
|
18439
|
+
writable: true,
|
|
18440
|
+
value: (options, callback) => {
|
|
18441
|
+
const {
|
|
18442
|
+
token,
|
|
18443
|
+
invoiceId
|
|
18444
|
+
} = options;
|
|
18445
|
+
const params = options.isExistingSource ? {
|
|
18446
|
+
source_id: token,
|
|
18447
|
+
invoice_id: invoiceId
|
|
18448
|
+
} : {
|
|
18449
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
|
|
18450
|
+
gateway_token: token,
|
|
18451
|
+
invoice_id: invoiceId
|
|
18452
|
+
};
|
|
18453
|
+
window.Pelcro.invoice.pay(params, (err, res) => {
|
|
18454
|
+
callback(err, res);
|
|
18455
|
+
});
|
|
18456
|
+
}
|
|
18457
|
+
});
|
|
18458
|
+
}
|
|
18459
|
+
}
|
|
18238
18460
|
|
|
18239
18461
|
/**
|
|
18240
18462
|
* @typedef {Object} PaymentStateType
|
|
@@ -18258,6 +18480,7 @@ class CybersourceGateway {
|
|
|
18258
18480
|
const initialState$l = {
|
|
18259
18481
|
disableSubmit: false,
|
|
18260
18482
|
isLoading: false,
|
|
18483
|
+
isSkeletonLoaded: false,
|
|
18261
18484
|
disableCouponButton: false,
|
|
18262
18485
|
couponObject: null,
|
|
18263
18486
|
couponCode: "",
|
|
@@ -18936,6 +19159,375 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18936
19159
|
};
|
|
18937
19160
|
/* ====== End Tap integration ======== */
|
|
18938
19161
|
|
|
19162
|
+
/* ====== Start Braintree integration ======== */
|
|
19163
|
+
const braintreeInstanceRef = React__default.useRef(null);
|
|
19164
|
+
useEffect(() => {
|
|
19165
|
+
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
19166
|
+
if (cardProcessor === "braintree" && !selectedPaymentMethodId) {
|
|
19167
|
+
var _window$Pelcro$site$r6;
|
|
19168
|
+
const {
|
|
19169
|
+
token: braintreeToken
|
|
19170
|
+
} = (_window$Pelcro$site$r6 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r6 === void 0 ? void 0 : _window$Pelcro$site$r6.braintree_gateway_settings;
|
|
19171
|
+
const isBraintreeEnabled = Boolean(braintreeToken);
|
|
19172
|
+
if (!isBraintreeEnabled) {
|
|
19173
|
+
console.error("Braintree integration is currently not enabled on this site's config");
|
|
19174
|
+
return;
|
|
19175
|
+
}
|
|
19176
|
+
braintreeInstanceRef.current = new window.braintree.client.create({
|
|
19177
|
+
authorization: braintreeToken
|
|
19178
|
+
}).then(clientInstance => {
|
|
19179
|
+
const options = {
|
|
19180
|
+
client: clientInstance,
|
|
19181
|
+
styles: {
|
|
19182
|
+
input: {
|
|
19183
|
+
"font-size": "14px"
|
|
19184
|
+
},
|
|
19185
|
+
"input.invalid": {
|
|
19186
|
+
color: "red"
|
|
19187
|
+
},
|
|
19188
|
+
"input.valid": {
|
|
19189
|
+
color: "green"
|
|
19190
|
+
}
|
|
19191
|
+
},
|
|
19192
|
+
fields: {
|
|
19193
|
+
number: {
|
|
19194
|
+
container: "#card-number",
|
|
19195
|
+
placeholder: "4111 1111 1111 1111"
|
|
19196
|
+
},
|
|
19197
|
+
cvv: {
|
|
19198
|
+
container: "#cvv",
|
|
19199
|
+
placeholder: "123"
|
|
19200
|
+
},
|
|
19201
|
+
expirationDate: {
|
|
19202
|
+
container: "#expiration-date",
|
|
19203
|
+
placeholder: "10/2022"
|
|
19204
|
+
}
|
|
19205
|
+
}
|
|
19206
|
+
};
|
|
19207
|
+
dispatch({
|
|
19208
|
+
type: SKELETON_LOADER,
|
|
19209
|
+
payload: true
|
|
19210
|
+
});
|
|
19211
|
+
return window.braintree.hostedFields.create(options);
|
|
19212
|
+
});
|
|
19213
|
+
}
|
|
19214
|
+
}, [selectedPaymentMethodId]);
|
|
19215
|
+
const braintreeErrorHandler = tokenizeErr => {
|
|
19216
|
+
switch (tokenizeErr.code) {
|
|
19217
|
+
case "HOSTED_FIELDS_FIELDS_EMPTY":
|
|
19218
|
+
// occurs when none of the fields are filled in
|
|
19219
|
+
return "All fields are empty! Please fill out the form.";
|
|
19220
|
+
// break;
|
|
19221
|
+
case "HOSTED_FIELDS_FIELDS_INVALID":
|
|
19222
|
+
// occurs when certain fields do not pass client side validation
|
|
19223
|
+
console.error("Some fields are invalid:", tokenizeErr.details.invalidFieldKeys.toString());
|
|
19224
|
+
|
|
19225
|
+
// you can also programmatically access the field containers for the invalid fields
|
|
19226
|
+
// tokenizeErr.details.invalidFields.forEach(function (
|
|
19227
|
+
// fieldContainer
|
|
19228
|
+
// ) {
|
|
19229
|
+
// fieldContainer.className = "invalid";
|
|
19230
|
+
// });
|
|
19231
|
+
return `Some fields are invalid: ${tokenizeErr.details.invalidFieldKeys.toString()}`;
|
|
19232
|
+
case "HOSTED_FIELDS_TOKENIZATION_FAIL_ON_DUPLICATE":
|
|
19233
|
+
// occurs when:
|
|
19234
|
+
// * the client token used for client authorization was generated
|
|
19235
|
+
// with a customer ID and the fail on duplicate payment method
|
|
19236
|
+
// option is set to true
|
|
19237
|
+
// * the card being tokenized has previously been vaulted (with any customer)
|
|
19238
|
+
// See: https://developer.paypal.com/braintree/docs/reference/request/client-token/generate#options.fail_on_duplicate_payment_method
|
|
19239
|
+
return "This payment method already exists in your vault.";
|
|
19240
|
+
case "HOSTED_FIELDS_TOKENIZATION_CVV_VERIFICATION_FAILED":
|
|
19241
|
+
// occurs when:
|
|
19242
|
+
// * the client token used for client authorization was generated
|
|
19243
|
+
// with a customer ID and the verify card option is set to true
|
|
19244
|
+
// and you have credit card verification turned on in the Braintree
|
|
19245
|
+
// control panel
|
|
19246
|
+
// * the cvv does not pass verification (https://developer.paypal.com/braintree/docs/reference/general/testing#avs-and-cvv/cid-responses)
|
|
19247
|
+
// See: https://developer.paypal.com/braintree/docs/reference/request/client-token/generate#options.verify_card
|
|
19248
|
+
return "CVV did not pass verification";
|
|
19249
|
+
case "HOSTED_FIELDS_FAILED_TOKENIZATION":
|
|
19250
|
+
// occurs for any other tokenization error on the server
|
|
19251
|
+
return "Tokenization failed server side. Is the card valid?";
|
|
19252
|
+
case "HOSTED_FIELDS_TOKENIZATION_NETWORK_ERROR":
|
|
19253
|
+
// occurs when the Braintree gateway cannot be contacted
|
|
19254
|
+
return "Network error occurred when tokenizing.";
|
|
19255
|
+
default:
|
|
19256
|
+
console.error("Something bad happened!", tokenizeErr);
|
|
19257
|
+
return "Something bad happened!";
|
|
19258
|
+
}
|
|
19259
|
+
};
|
|
19260
|
+
const submitUsingBraintree = (state, dispatch) => {
|
|
19261
|
+
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
19262
|
+
if (isUsingExistingPaymentMethod) {
|
|
19263
|
+
// no need to create a new source using braintree
|
|
19264
|
+
return handleBraintreePayment(null, state.couponCode);
|
|
19265
|
+
}
|
|
19266
|
+
if (!braintreeInstanceRef.current) {
|
|
19267
|
+
return console.error("Braintree sdk script wasn't loaded, you need to load braintree sdk before rendering the braintree payment flow");
|
|
19268
|
+
}
|
|
19269
|
+
braintreeInstanceRef.current.then(hostedFieldInstance => {
|
|
19270
|
+
hostedFieldInstance.tokenize((tokenizeErr, payload) => {
|
|
19271
|
+
if (tokenizeErr) {
|
|
19272
|
+
dispatch({
|
|
19273
|
+
type: DISABLE_SUBMIT,
|
|
19274
|
+
payload: false
|
|
19275
|
+
});
|
|
19276
|
+
dispatch({
|
|
19277
|
+
type: LOADING,
|
|
19278
|
+
payload: false
|
|
19279
|
+
});
|
|
19280
|
+
return dispatch({
|
|
19281
|
+
type: SHOW_ALERT,
|
|
19282
|
+
payload: {
|
|
19283
|
+
type: "error",
|
|
19284
|
+
content: braintreeErrorHandler(tokenizeErr)
|
|
19285
|
+
}
|
|
19286
|
+
});
|
|
19287
|
+
}
|
|
19288
|
+
console.log(payload);
|
|
19289
|
+
handleBraintreePayment(payload, state);
|
|
19290
|
+
});
|
|
19291
|
+
}).catch(error => {
|
|
19292
|
+
if (error) {
|
|
19293
|
+
console.error(error);
|
|
19294
|
+
return;
|
|
19295
|
+
}
|
|
19296
|
+
});
|
|
19297
|
+
};
|
|
19298
|
+
const handleBraintreePayment = (braintreePaymentRequest, state) => {
|
|
19299
|
+
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
19300
|
+
const braintreeNonce = braintreePaymentRequest === null || braintreePaymentRequest === void 0 ? void 0 : braintreePaymentRequest.nonce;
|
|
19301
|
+
if (type === "createPayment") {
|
|
19302
|
+
handleBraintreeSubscription();
|
|
19303
|
+
} else if (type === "orderCreate") {
|
|
19304
|
+
purchase(new BraintreeGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce, state, dispatch);
|
|
19305
|
+
} else if (type === "invoicePayment") {
|
|
19306
|
+
payInvoice(new BraintreeGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce, dispatch);
|
|
19307
|
+
} else if (type === "createPaymentSource") {
|
|
19308
|
+
createNewBraintreeCard();
|
|
19309
|
+
} else if (type === "updatePaymentSource") {
|
|
19310
|
+
updateBraintreeCard();
|
|
19311
|
+
} else if (type === "deletePaymentSource") {
|
|
19312
|
+
replaceBraintreeCard();
|
|
19313
|
+
}
|
|
19314
|
+
function createNewBraintreeCard() {
|
|
19315
|
+
window.Pelcro.paymentMethods.create({
|
|
19316
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
19317
|
+
token: braintreeNonce,
|
|
19318
|
+
gateway: "braintree"
|
|
19319
|
+
}, (err, res) => {
|
|
19320
|
+
dispatch({
|
|
19321
|
+
type: DISABLE_SUBMIT,
|
|
19322
|
+
payload: false
|
|
19323
|
+
});
|
|
19324
|
+
dispatch({
|
|
19325
|
+
type: LOADING,
|
|
19326
|
+
payload: false
|
|
19327
|
+
});
|
|
19328
|
+
if (err) {
|
|
19329
|
+
onFailure(err);
|
|
19330
|
+
return dispatch({
|
|
19331
|
+
type: SHOW_ALERT,
|
|
19332
|
+
payload: {
|
|
19333
|
+
type: "error",
|
|
19334
|
+
content: getErrorMessages(err)
|
|
19335
|
+
}
|
|
19336
|
+
});
|
|
19337
|
+
}
|
|
19338
|
+
dispatch({
|
|
19339
|
+
type: SHOW_ALERT,
|
|
19340
|
+
payload: {
|
|
19341
|
+
type: "success",
|
|
19342
|
+
content: t("messages.sourceCreated")
|
|
19343
|
+
}
|
|
19344
|
+
});
|
|
19345
|
+
onSuccess(res);
|
|
19346
|
+
});
|
|
19347
|
+
}
|
|
19348
|
+
function replaceBraintreeCard() {
|
|
19349
|
+
const {
|
|
19350
|
+
id: paymentMethodId
|
|
19351
|
+
} = paymentMethodToDelete;
|
|
19352
|
+
window.Pelcro.paymentMethods.create({
|
|
19353
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
19354
|
+
token: braintreeNonce,
|
|
19355
|
+
gateway: "braintree"
|
|
19356
|
+
}, (err, res) => {
|
|
19357
|
+
if (err) {
|
|
19358
|
+
dispatch({
|
|
19359
|
+
type: DISABLE_SUBMIT,
|
|
19360
|
+
payload: false
|
|
19361
|
+
});
|
|
19362
|
+
dispatch({
|
|
19363
|
+
type: LOADING,
|
|
19364
|
+
payload: false
|
|
19365
|
+
});
|
|
19366
|
+
onFailure(err);
|
|
19367
|
+
return dispatch({
|
|
19368
|
+
type: SHOW_ALERT,
|
|
19369
|
+
payload: {
|
|
19370
|
+
type: "error",
|
|
19371
|
+
content: getErrorMessages(err)
|
|
19372
|
+
}
|
|
19373
|
+
});
|
|
19374
|
+
}
|
|
19375
|
+
if (res) {
|
|
19376
|
+
setTimeout(() => {
|
|
19377
|
+
window.Pelcro.paymentMethods.deletePaymentMethod({
|
|
19378
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
19379
|
+
payment_method_id: paymentMethodId
|
|
19380
|
+
}, (err, res) => {
|
|
19381
|
+
dispatch({
|
|
19382
|
+
type: DISABLE_SUBMIT,
|
|
19383
|
+
payload: false
|
|
19384
|
+
});
|
|
19385
|
+
dispatch({
|
|
19386
|
+
type: LOADING,
|
|
19387
|
+
payload: false
|
|
19388
|
+
});
|
|
19389
|
+
if (err) {
|
|
19390
|
+
onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
|
|
19391
|
+
return dispatch({
|
|
19392
|
+
type: SHOW_ALERT,
|
|
19393
|
+
payload: {
|
|
19394
|
+
type: "error",
|
|
19395
|
+
content: getErrorMessages(err)
|
|
19396
|
+
}
|
|
19397
|
+
});
|
|
19398
|
+
}
|
|
19399
|
+
onSuccess(res);
|
|
19400
|
+
});
|
|
19401
|
+
}, 2000);
|
|
19402
|
+
}
|
|
19403
|
+
});
|
|
19404
|
+
}
|
|
19405
|
+
function updateBraintreeCard() {
|
|
19406
|
+
const {
|
|
19407
|
+
id: paymentMethodId
|
|
19408
|
+
} = paymentMethodToEdit;
|
|
19409
|
+
const {
|
|
19410
|
+
expirationMonth,
|
|
19411
|
+
expirationYear
|
|
19412
|
+
} = braintreePaymentRequest === null || braintreePaymentRequest === void 0 ? void 0 : braintreePaymentRequest.details;
|
|
19413
|
+
const {
|
|
19414
|
+
isDefault
|
|
19415
|
+
} = state;
|
|
19416
|
+
window.Pelcro.paymentMethods.update({
|
|
19417
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
19418
|
+
payment_method_id: paymentMethodId,
|
|
19419
|
+
token: braintreeNonce,
|
|
19420
|
+
gateway: "braintree",
|
|
19421
|
+
exp_month: expirationMonth,
|
|
19422
|
+
exp_year: expirationYear,
|
|
19423
|
+
is_default: isDefault
|
|
19424
|
+
}, (err, res) => {
|
|
19425
|
+
dispatch({
|
|
19426
|
+
type: DISABLE_SUBMIT,
|
|
19427
|
+
payload: false
|
|
19428
|
+
});
|
|
19429
|
+
dispatch({
|
|
19430
|
+
type: LOADING,
|
|
19431
|
+
payload: false
|
|
19432
|
+
});
|
|
19433
|
+
if (err) {
|
|
19434
|
+
onFailure(err);
|
|
19435
|
+
return dispatch({
|
|
19436
|
+
type: SHOW_ALERT,
|
|
19437
|
+
payload: {
|
|
19438
|
+
type: "error",
|
|
19439
|
+
content: getErrorMessages(err)
|
|
19440
|
+
}
|
|
19441
|
+
});
|
|
19442
|
+
}
|
|
19443
|
+
dispatch({
|
|
19444
|
+
type: SHOW_ALERT,
|
|
19445
|
+
payload: {
|
|
19446
|
+
type: "success",
|
|
19447
|
+
content: t("messages.sourceUpdated")
|
|
19448
|
+
}
|
|
19449
|
+
});
|
|
19450
|
+
onSuccess(res);
|
|
19451
|
+
});
|
|
19452
|
+
}
|
|
19453
|
+
function handleBraintreeSubscription() {
|
|
19454
|
+
const payment = new Payment(new BraintreeGateway());
|
|
19455
|
+
const createSubscription = !isGift && !subscriptionIdToRenew;
|
|
19456
|
+
const renewSubscription = !isGift && subscriptionIdToRenew;
|
|
19457
|
+
const giftSubscriprition = isGift && !subscriptionIdToRenew;
|
|
19458
|
+
const renewGift = isRenewingGift;
|
|
19459
|
+
if (renewGift) {
|
|
19460
|
+
return payment.execute({
|
|
19461
|
+
type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
|
|
19462
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce,
|
|
19463
|
+
plan,
|
|
19464
|
+
couponCode,
|
|
19465
|
+
product,
|
|
19466
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
19467
|
+
subscriptionIdToRenew,
|
|
19468
|
+
addressId: selectedAddressId
|
|
19469
|
+
}, (err, res) => {
|
|
19470
|
+
if (err) {
|
|
19471
|
+
return handlePaymentError(err);
|
|
19472
|
+
}
|
|
19473
|
+
onSuccess(res);
|
|
19474
|
+
});
|
|
19475
|
+
} else if (giftSubscriprition) {
|
|
19476
|
+
return payment.execute({
|
|
19477
|
+
type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
|
|
19478
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce,
|
|
19479
|
+
quantity: plan.quantity,
|
|
19480
|
+
plan,
|
|
19481
|
+
couponCode,
|
|
19482
|
+
product,
|
|
19483
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
19484
|
+
giftRecipient,
|
|
19485
|
+
addressId: selectedAddressId
|
|
19486
|
+
}, (err, res) => {
|
|
19487
|
+
if (err) {
|
|
19488
|
+
return handlePaymentError(err);
|
|
19489
|
+
}
|
|
19490
|
+
onSuccess(res);
|
|
19491
|
+
});
|
|
19492
|
+
} else if (renewSubscription) {
|
|
19493
|
+
return payment.execute({
|
|
19494
|
+
type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
|
|
19495
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce,
|
|
19496
|
+
quantity: plan.quantity,
|
|
19497
|
+
plan,
|
|
19498
|
+
couponCode,
|
|
19499
|
+
product,
|
|
19500
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
19501
|
+
subscriptionIdToRenew,
|
|
19502
|
+
addressId: selectedAddressId
|
|
19503
|
+
}, (err, res) => {
|
|
19504
|
+
if (err) {
|
|
19505
|
+
return handlePaymentError(err);
|
|
19506
|
+
}
|
|
19507
|
+
onSuccess(res);
|
|
19508
|
+
});
|
|
19509
|
+
} else if (createSubscription) {
|
|
19510
|
+
return payment.execute({
|
|
19511
|
+
type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
|
|
19512
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce,
|
|
19513
|
+
quantity: plan.quantity,
|
|
19514
|
+
plan,
|
|
19515
|
+
couponCode,
|
|
19516
|
+
product,
|
|
19517
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
19518
|
+
addressId: selectedAddressId
|
|
19519
|
+
}, (err, res) => {
|
|
19520
|
+
if (err) {
|
|
19521
|
+
return handlePaymentError(err);
|
|
19522
|
+
}
|
|
19523
|
+
onSuccess(res);
|
|
19524
|
+
});
|
|
19525
|
+
}
|
|
19526
|
+
}
|
|
19527
|
+
};
|
|
19528
|
+
|
|
19529
|
+
/* ====== End Braintree integration ======== */
|
|
19530
|
+
|
|
18939
19531
|
const submitUsingVantiv = state => {
|
|
18940
19532
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
18941
19533
|
if (isUsingExistingPaymentMethod) {
|
|
@@ -19215,9 +19807,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19215
19807
|
useEffect(() => {
|
|
19216
19808
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
19217
19809
|
if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
|
|
19218
|
-
var _window$Pelcro$site$
|
|
19219
|
-
const payPageId = (_window$Pelcro$site$
|
|
19220
|
-
const reportGroup = (_window$Pelcro$site$
|
|
19810
|
+
var _window$Pelcro$site$r7, _window$Pelcro$site$r8;
|
|
19811
|
+
const payPageId = (_window$Pelcro$site$r7 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r7 === void 0 ? void 0 : _window$Pelcro$site$r7.vantiv_gateway_settings.pay_page_id;
|
|
19812
|
+
const reportGroup = (_window$Pelcro$site$r8 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r8 === void 0 ? void 0 : _window$Pelcro$site$r8.vantiv_gateway_settings.report_group;
|
|
19221
19813
|
vantivInstanceRef.current = new window.EprotectIframeClient({
|
|
19222
19814
|
paypageId: payPageId,
|
|
19223
19815
|
reportGroup: reportGroup,
|
|
@@ -19356,9 +19948,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19356
19948
|
* Updates the total amount after adding taxes only if site taxes are enabled
|
|
19357
19949
|
*/
|
|
19358
19950
|
const updateTotalAmountWithTax = () => {
|
|
19359
|
-
var _window$Pelcro$site$
|
|
19951
|
+
var _window$Pelcro$site$r9;
|
|
19360
19952
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
19361
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
19953
|
+
const taxesEnabled = (_window$Pelcro$site$r9 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r9 === void 0 ? void 0 : _window$Pelcro$site$r9.taxes_enabled;
|
|
19362
19954
|
if (taxesEnabled && type === "createPayment") {
|
|
19363
19955
|
dispatch({
|
|
19364
19956
|
type: DISABLE_SUBMIT,
|
|
@@ -20372,11 +20964,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20372
20964
|
* @return {Promise}
|
|
20373
20965
|
*/
|
|
20374
20966
|
const resolveTaxCalculation = () => {
|
|
20375
|
-
var _window$Pelcro$site$
|
|
20967
|
+
var _window$Pelcro$site$r10;
|
|
20376
20968
|
if (type === "invoicePayment") {
|
|
20377
20969
|
return new Promise(resolve => resolve());
|
|
20378
20970
|
}
|
|
20379
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
20971
|
+
const taxesEnabled = (_window$Pelcro$site$r10 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r10 === void 0 ? void 0 : _window$Pelcro$site$r10.taxes_enabled;
|
|
20380
20972
|
return new Promise((resolve, reject) => {
|
|
20381
20973
|
// resolve early if taxes isn't enabled
|
|
20382
20974
|
if (!taxesEnabled) {
|
|
@@ -20542,6 +21134,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20542
21134
|
...state,
|
|
20543
21135
|
isLoading: action.payload
|
|
20544
21136
|
});
|
|
21137
|
+
case SKELETON_LOADER:
|
|
21138
|
+
return lib_7({
|
|
21139
|
+
...state,
|
|
21140
|
+
isSkeletonLoaded: action.payload
|
|
21141
|
+
});
|
|
20545
21142
|
case SHOW_COUPON_FIELD:
|
|
20546
21143
|
return lib_7({
|
|
20547
21144
|
...state,
|
|
@@ -20587,8 +21184,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20587
21184
|
if (getSiteCardProcessor() === "cybersource") {
|
|
20588
21185
|
return submitUsingCybersource(state, dispatch);
|
|
20589
21186
|
}
|
|
20590
|
-
if (getSiteCardProcessor() === "
|
|
20591
|
-
return
|
|
21187
|
+
if (getSiteCardProcessor() === "braintree") {
|
|
21188
|
+
return submitUsingBraintree(state, dispatch);
|
|
20592
21189
|
}
|
|
20593
21190
|
if (selectedPaymentMethodId) {
|
|
20594
21191
|
if (!isAuthenticated() && plan.type === "donation") {
|
|
@@ -21009,6 +21606,11 @@ const CheckoutForm = _ref => {
|
|
|
21009
21606
|
paymentMethodToEdit
|
|
21010
21607
|
} = usePelcro();
|
|
21011
21608
|
const cardProcessor = getSiteCardProcessor();
|
|
21609
|
+
const {
|
|
21610
|
+
state: {
|
|
21611
|
+
isSkeletonLoaded
|
|
21612
|
+
}
|
|
21613
|
+
} = useContext(store$l);
|
|
21012
21614
|
if (selectedPaymentMethodId) {
|
|
21013
21615
|
return null;
|
|
21014
21616
|
}
|
|
@@ -21040,6 +21642,30 @@ const CheckoutForm = _ref => {
|
|
|
21040
21642
|
placeholder: "Exp Year *"
|
|
21041
21643
|
}))));
|
|
21042
21644
|
}
|
|
21645
|
+
if (cardProcessor === "braintree") {
|
|
21646
|
+
return /*#__PURE__*/React__default.createElement("div", null, isSkeletonLoaded ? /*#__PURE__*/React__default.createElement("div", {
|
|
21647
|
+
className: "plc-max-w-[50em]"
|
|
21648
|
+
}, /*#__PURE__*/React__default.createElement("label", {
|
|
21649
|
+
htmlFor: "card-number"
|
|
21650
|
+
}, "Card Number"), /*#__PURE__*/React__default.createElement("div", {
|
|
21651
|
+
id: "card-number",
|
|
21652
|
+
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
21653
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
21654
|
+
className: "plc-flex plc-items-start plc-space-x-3 plc-mb-4"
|
|
21655
|
+
}, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("label", {
|
|
21656
|
+
htmlFor: "expiration-date"
|
|
21657
|
+
}, "Expiration Date"), /*#__PURE__*/React__default.createElement("div", {
|
|
21658
|
+
id: "expiration-date",
|
|
21659
|
+
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
21660
|
+
})), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("label", {
|
|
21661
|
+
htmlFor: "cvv"
|
|
21662
|
+
}, "CVV"), /*#__PURE__*/React__default.createElement("div", {
|
|
21663
|
+
id: "cvv",
|
|
21664
|
+
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
21665
|
+
})))) : /*#__PURE__*/React__default.createElement("div", {
|
|
21666
|
+
className: "plc-w-full plc-h-36 plc-bg-gray-300 plc-rounded plc-animate-pulse"
|
|
21667
|
+
}));
|
|
21668
|
+
}
|
|
21043
21669
|
if (cardProcessor === "stripe") {
|
|
21044
21670
|
if (type === "updatePaymentSource") {
|
|
21045
21671
|
var _paymentMethodToEdit$;
|