@pelcro/react-pelcro-js 3.22.0-beta.9 → 3.22.1
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 +771 -140
- package/dist/index.esm.js +771 -140
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -3457,7 +3457,8 @@ var labels$10 = {
|
|
|
3457
3457
|
removeCoupon: "REMOVE",
|
|
3458
3458
|
firstName: "First name",
|
|
3459
3459
|
lastName: "Last name",
|
|
3460
|
-
phone: "Phone"
|
|
3460
|
+
phone: "Phone",
|
|
3461
|
+
freeItems: "Free Items"
|
|
3461
3462
|
};
|
|
3462
3463
|
var checkoutForm_en = {
|
|
3463
3464
|
messages: messages$14,
|
|
@@ -4398,7 +4399,8 @@ var labels$H = {
|
|
|
4398
4399
|
removeCoupon: "RETIRER",
|
|
4399
4400
|
firstName: "Prénom",
|
|
4400
4401
|
lastName: "Nom de famille",
|
|
4401
|
-
phone: "Téléphoner"
|
|
4402
|
+
phone: "Téléphoner",
|
|
4403
|
+
freeItems: "Articles gratuits"
|
|
4402
4404
|
};
|
|
4403
4405
|
var checkoutForm_fr = {
|
|
4404
4406
|
messages: messages$M,
|
|
@@ -5225,7 +5227,8 @@ var labels$s = {
|
|
|
5225
5227
|
removeCoupon: "제거",
|
|
5226
5228
|
firstName: "이름",
|
|
5227
5229
|
lastName: "성",
|
|
5228
|
-
phone: "핸드폰"
|
|
5230
|
+
phone: "핸드폰",
|
|
5231
|
+
freeItems: "무료 아이템"
|
|
5229
5232
|
};
|
|
5230
5233
|
var checkoutForm_ko = {
|
|
5231
5234
|
messages: messages$v,
|
|
@@ -6156,7 +6159,8 @@ var labels$d = {
|
|
|
6156
6159
|
removeCoupon: "ELIMINAR",
|
|
6157
6160
|
firstName: "Nombre",
|
|
6158
6161
|
lastName: "Apellido",
|
|
6159
|
-
phone: "Teléfono"
|
|
6162
|
+
phone: "Teléfono",
|
|
6163
|
+
freeItems: "Artículos gratis"
|
|
6160
6164
|
};
|
|
6161
6165
|
var checkoutForm_es = {
|
|
6162
6166
|
messages: messages$e,
|
|
@@ -10873,13 +10877,16 @@ const debounce = (func, waitTime) => {
|
|
|
10873
10877
|
};
|
|
10874
10878
|
};
|
|
10875
10879
|
function getSiteCardProcessor() {
|
|
10876
|
-
var _window$Pelcro$site$r, _window$Pelcro$site$r2;
|
|
10880
|
+
var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3;
|
|
10877
10881
|
if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
|
|
10878
10882
|
return "vantiv";
|
|
10879
10883
|
}
|
|
10880
10884
|
if ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r2 !== void 0 && _window$Pelcro$site$r2.tap_gateway_settings) {
|
|
10881
10885
|
return "tap";
|
|
10882
10886
|
}
|
|
10887
|
+
if ((_window$Pelcro$site$r3 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r3 !== void 0 && _window$Pelcro$site$r3.cybersource_gateway_settings) {
|
|
10888
|
+
return "cybersource";
|
|
10889
|
+
}
|
|
10883
10890
|
return "stripe";
|
|
10884
10891
|
}
|
|
10885
10892
|
|
|
@@ -11740,6 +11747,8 @@ const SET_FIRST_NAME_ERROR = "SET_FIRST_NAME_ERROR";
|
|
|
11740
11747
|
const SET_LAST_NAME_ERROR = "SET_LAST_NAME_ERROR";
|
|
11741
11748
|
const SET_PHONE_ERROR = "SET_PHONE_ERROR";
|
|
11742
11749
|
const SET_TEXT_FIELD = "SET_TEXT_FIELD";
|
|
11750
|
+
const SET_MONTH = "SET_MONTH";
|
|
11751
|
+
const SET_YEAR = "SET_YEAR";
|
|
11743
11752
|
const SET_TOKEN = "SET_TOKEN";
|
|
11744
11753
|
const SET_GIFT_CODE = "SET_GIFT_CODE";
|
|
11745
11754
|
const RESET_LOGIN_FORM = "RESET_LOGIN_FORM";
|
|
@@ -14079,6 +14088,7 @@ class SelectModal extends React.Component {
|
|
|
14079
14088
|
});
|
|
14080
14089
|
});
|
|
14081
14090
|
});
|
|
14091
|
+
console.log("bugsnag Triggered");
|
|
14082
14092
|
}
|
|
14083
14093
|
});
|
|
14084
14094
|
_defineProperty$3(this, "componentWillUnmount", () => {
|
|
@@ -15498,7 +15508,7 @@ var _isPaymentGatewayInvalid = /*#__PURE__*/new WeakMap();
|
|
|
15498
15508
|
var _generateUserError = /*#__PURE__*/new WeakMap();
|
|
15499
15509
|
class Payment {
|
|
15500
15510
|
/**
|
|
15501
|
-
* @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway)} paymentGateway
|
|
15511
|
+
* @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway|CybersourceGateway)} paymentGateway
|
|
15502
15512
|
*/
|
|
15503
15513
|
constructor(paymentGateway) {
|
|
15504
15514
|
_defineProperty$3(this, "execute", (options, callback) => {
|
|
@@ -15517,7 +15527,7 @@ class Payment {
|
|
|
15517
15527
|
_classPrivateFieldInitSpec$1(this, _isPaymentGatewayInvalid, {
|
|
15518
15528
|
writable: true,
|
|
15519
15529
|
value: gateway => {
|
|
15520
|
-
return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway);
|
|
15530
|
+
return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway || gateway instanceof CybersourceGateway);
|
|
15521
15531
|
}
|
|
15522
15532
|
});
|
|
15523
15533
|
_classPrivateFieldInitSpec$1(this, _generateUserError, {
|
|
@@ -15571,7 +15581,8 @@ const PAYMENT_GATEWAYS_ENUM = {
|
|
|
15571
15581
|
stripe: "stripe",
|
|
15572
15582
|
paypal: "braintree",
|
|
15573
15583
|
vantiv: "vantiv",
|
|
15574
|
-
tap: "tap"
|
|
15584
|
+
tap: "tap",
|
|
15585
|
+
cybersource: "cybersource"
|
|
15575
15586
|
};
|
|
15576
15587
|
|
|
15577
15588
|
/**
|
|
@@ -16293,6 +16304,222 @@ class TapGateway {
|
|
|
16293
16304
|
}
|
|
16294
16305
|
}
|
|
16295
16306
|
|
|
16307
|
+
/**
|
|
16308
|
+
* Cybersource gateway strategy
|
|
16309
|
+
*/
|
|
16310
|
+
var _paymentGateway5 = /*#__PURE__*/new WeakMap();
|
|
16311
|
+
var _createSubscription5 = /*#__PURE__*/new WeakMap();
|
|
16312
|
+
var _renewSubscription4 = /*#__PURE__*/new WeakMap();
|
|
16313
|
+
var _createGiftedSubscription5 = /*#__PURE__*/new WeakMap();
|
|
16314
|
+
var _renewGiftedSubscription4 = /*#__PURE__*/new WeakMap();
|
|
16315
|
+
var _purchaseEcommerceOrder4 = /*#__PURE__*/new WeakMap();
|
|
16316
|
+
var _payInvoice5 = /*#__PURE__*/new WeakMap();
|
|
16317
|
+
class CybersourceGateway {
|
|
16318
|
+
constructor() {
|
|
16319
|
+
_classPrivateFieldInitSpec$1(this, _paymentGateway5, {
|
|
16320
|
+
writable: true,
|
|
16321
|
+
value: PAYMENT_GATEWAYS_ENUM["cybersource"]
|
|
16322
|
+
});
|
|
16323
|
+
_defineProperty$3(this, "execute", (options, callback) => {
|
|
16324
|
+
const types = PAYMENT_TYPES;
|
|
16325
|
+
switch (options.type) {
|
|
16326
|
+
case types.CREATE_SUBSCRIPTION:
|
|
16327
|
+
return _classPrivateFieldGet(this, _createSubscription5).call(this, options, callback);
|
|
16328
|
+
case types.RENEW_SUBSCRIPTION:
|
|
16329
|
+
return _classPrivateFieldGet(this, _renewSubscription4).call(this, options, callback);
|
|
16330
|
+
case types.CREATE_GIFTED_SUBSCRIPTION:
|
|
16331
|
+
return _classPrivateFieldGet(this, _createGiftedSubscription5).call(this, options, callback);
|
|
16332
|
+
case types.RENEW_GIFTED_SUBSCRIPTION:
|
|
16333
|
+
return _classPrivateFieldGet(this, _renewGiftedSubscription4).call(this, options, callback);
|
|
16334
|
+
case types.PURCHASE_ECOMMERCE_ORDER:
|
|
16335
|
+
return _classPrivateFieldGet(this, _purchaseEcommerceOrder4).call(this, options, callback);
|
|
16336
|
+
case types.PAY_INVOICE:
|
|
16337
|
+
return _classPrivateFieldGet(this, _payInvoice5).call(this, options, callback);
|
|
16338
|
+
default:
|
|
16339
|
+
console.error("Unsupported payment method: cybersource Gateway");
|
|
16340
|
+
}
|
|
16341
|
+
});
|
|
16342
|
+
_classPrivateFieldInitSpec$1(this, _createSubscription5, {
|
|
16343
|
+
writable: true,
|
|
16344
|
+
value: (options, callback) => {
|
|
16345
|
+
const {
|
|
16346
|
+
token,
|
|
16347
|
+
plan,
|
|
16348
|
+
couponCode,
|
|
16349
|
+
product,
|
|
16350
|
+
quantity = 1,
|
|
16351
|
+
addressId,
|
|
16352
|
+
isExistingSource
|
|
16353
|
+
} = options;
|
|
16354
|
+
const params = isExistingSource ? {
|
|
16355
|
+
source_id: token
|
|
16356
|
+
} : {
|
|
16357
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16358
|
+
gateway_token: token
|
|
16359
|
+
};
|
|
16360
|
+
window.Pelcro.subscription.create({
|
|
16361
|
+
quantity,
|
|
16362
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16363
|
+
plan_id: plan.id,
|
|
16364
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
16365
|
+
coupon_code: couponCode,
|
|
16366
|
+
address_id: product.address_required ? addressId : null,
|
|
16367
|
+
...params
|
|
16368
|
+
}, (err, res) => {
|
|
16369
|
+
callback(err, res);
|
|
16370
|
+
});
|
|
16371
|
+
}
|
|
16372
|
+
});
|
|
16373
|
+
_classPrivateFieldInitSpec$1(this, _renewSubscription4, {
|
|
16374
|
+
writable: true,
|
|
16375
|
+
value: (options, callback) => {
|
|
16376
|
+
const {
|
|
16377
|
+
subscriptionIdToRenew,
|
|
16378
|
+
token,
|
|
16379
|
+
plan,
|
|
16380
|
+
couponCode,
|
|
16381
|
+
product,
|
|
16382
|
+
addressId,
|
|
16383
|
+
isExistingSource
|
|
16384
|
+
} = options;
|
|
16385
|
+
const params = isExistingSource ? {
|
|
16386
|
+
source_id: token
|
|
16387
|
+
} : {
|
|
16388
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16389
|
+
gateway_token: token
|
|
16390
|
+
};
|
|
16391
|
+
window.Pelcro.subscription.renew({
|
|
16392
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16393
|
+
plan_id: plan.id,
|
|
16394
|
+
coupon_code: couponCode,
|
|
16395
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
16396
|
+
subscription_id: subscriptionIdToRenew,
|
|
16397
|
+
address_id: product.address_required ? addressId : null,
|
|
16398
|
+
...params
|
|
16399
|
+
}, (err, res) => {
|
|
16400
|
+
callback(err, res);
|
|
16401
|
+
});
|
|
16402
|
+
}
|
|
16403
|
+
});
|
|
16404
|
+
_classPrivateFieldInitSpec$1(this, _createGiftedSubscription5, {
|
|
16405
|
+
writable: true,
|
|
16406
|
+
value: (options, callback) => {
|
|
16407
|
+
const {
|
|
16408
|
+
token,
|
|
16409
|
+
plan,
|
|
16410
|
+
couponCode,
|
|
16411
|
+
product,
|
|
16412
|
+
giftRecipient,
|
|
16413
|
+
quantity = 1,
|
|
16414
|
+
addressId,
|
|
16415
|
+
isExistingSource
|
|
16416
|
+
} = options;
|
|
16417
|
+
const params = isExistingSource ? {
|
|
16418
|
+
source_id: token
|
|
16419
|
+
} : {
|
|
16420
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16421
|
+
gateway_token: token
|
|
16422
|
+
};
|
|
16423
|
+
window.Pelcro.subscription.create({
|
|
16424
|
+
quantity,
|
|
16425
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16426
|
+
plan_id: plan.id,
|
|
16427
|
+
coupon_code: couponCode,
|
|
16428
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
16429
|
+
gift_recipient_email: giftRecipient.email,
|
|
16430
|
+
gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
|
|
16431
|
+
gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
|
|
16432
|
+
gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
|
|
16433
|
+
gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
|
|
16434
|
+
address_id: product.address_required ? addressId : null,
|
|
16435
|
+
...params
|
|
16436
|
+
}, (err, res) => {
|
|
16437
|
+
callback(err, res);
|
|
16438
|
+
});
|
|
16439
|
+
}
|
|
16440
|
+
});
|
|
16441
|
+
_classPrivateFieldInitSpec$1(this, _renewGiftedSubscription4, {
|
|
16442
|
+
writable: true,
|
|
16443
|
+
value: (options, callback) => {
|
|
16444
|
+
const {
|
|
16445
|
+
subscriptionIdToRenew,
|
|
16446
|
+
token,
|
|
16447
|
+
product,
|
|
16448
|
+
plan,
|
|
16449
|
+
couponCode,
|
|
16450
|
+
addressId,
|
|
16451
|
+
isExistingSource
|
|
16452
|
+
} = options;
|
|
16453
|
+
const params = isExistingSource ? {
|
|
16454
|
+
source_id: token
|
|
16455
|
+
} : {
|
|
16456
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16457
|
+
gateway_token: token
|
|
16458
|
+
};
|
|
16459
|
+
window.Pelcro.subscription.renewGift({
|
|
16460
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16461
|
+
plan_id: plan.id,
|
|
16462
|
+
coupon_code: couponCode,
|
|
16463
|
+
subscription_id: subscriptionIdToRenew,
|
|
16464
|
+
address_id: product.address_required ? addressId : null,
|
|
16465
|
+
...params
|
|
16466
|
+
}, (err, res) => {
|
|
16467
|
+
callback(err, res);
|
|
16468
|
+
});
|
|
16469
|
+
}
|
|
16470
|
+
});
|
|
16471
|
+
_classPrivateFieldInitSpec$1(this, _purchaseEcommerceOrder4, {
|
|
16472
|
+
writable: true,
|
|
16473
|
+
value: (options, callback) => {
|
|
16474
|
+
const {
|
|
16475
|
+
token,
|
|
16476
|
+
items,
|
|
16477
|
+
couponCode,
|
|
16478
|
+
addressId,
|
|
16479
|
+
isExistingSource
|
|
16480
|
+
} = options;
|
|
16481
|
+
const params = isExistingSource ? {
|
|
16482
|
+
source_id: token
|
|
16483
|
+
} : {
|
|
16484
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16485
|
+
gateway_token: token
|
|
16486
|
+
};
|
|
16487
|
+
window.Pelcro.ecommerce.order.create({
|
|
16488
|
+
items,
|
|
16489
|
+
coupon_code: couponCode,
|
|
16490
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
16491
|
+
...params,
|
|
16492
|
+
...(addressId && {
|
|
16493
|
+
address_id: addressId
|
|
16494
|
+
})
|
|
16495
|
+
}, (err, res) => {
|
|
16496
|
+
callback(err, res);
|
|
16497
|
+
});
|
|
16498
|
+
}
|
|
16499
|
+
});
|
|
16500
|
+
_classPrivateFieldInitSpec$1(this, _payInvoice5, {
|
|
16501
|
+
writable: true,
|
|
16502
|
+
value: (options, callback) => {
|
|
16503
|
+
const {
|
|
16504
|
+
token,
|
|
16505
|
+
invoiceId
|
|
16506
|
+
} = options;
|
|
16507
|
+
const params = options.isExistingSource ? {
|
|
16508
|
+
source_id: token,
|
|
16509
|
+
invoice_id: invoiceId
|
|
16510
|
+
} : {
|
|
16511
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16512
|
+
gateway_token: token,
|
|
16513
|
+
invoice_id: invoiceId
|
|
16514
|
+
};
|
|
16515
|
+
window.Pelcro.invoice.pay(params, (err, res) => {
|
|
16516
|
+
callback(err, res);
|
|
16517
|
+
});
|
|
16518
|
+
}
|
|
16519
|
+
});
|
|
16520
|
+
}
|
|
16521
|
+
}
|
|
16522
|
+
|
|
16296
16523
|
/**
|
|
16297
16524
|
* @typedef {Object} PaymentStateType
|
|
16298
16525
|
* @property {boolean} disableSubmit
|
|
@@ -16332,6 +16559,8 @@ const initialState$k = {
|
|
|
16332
16559
|
firstNameError: null,
|
|
16333
16560
|
lastNameError: null,
|
|
16334
16561
|
phoneError: null,
|
|
16562
|
+
month: "",
|
|
16563
|
+
year: "",
|
|
16335
16564
|
alert: {
|
|
16336
16565
|
type: "error",
|
|
16337
16566
|
content: ""
|
|
@@ -16397,37 +16626,44 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16397
16626
|
updateTotalAmountWithTax();
|
|
16398
16627
|
}, []);
|
|
16399
16628
|
|
|
16400
|
-
/*====== Start
|
|
16401
|
-
const
|
|
16402
|
-
var
|
|
16629
|
+
/*====== Start Cybersource integration ========*/
|
|
16630
|
+
const cybersourceErrorHandle = err => {
|
|
16631
|
+
var _err$details, _err$details$response, _err$details$response2;
|
|
16632
|
+
if ((err === null || err === void 0 ? void 0 : (_err$details = err.details) === null || _err$details === void 0 ? void 0 : (_err$details$response = _err$details.responseStatus) === null || _err$details$response === void 0 ? void 0 : (_err$details$response2 = _err$details$response.details) === null || _err$details$response2 === void 0 ? void 0 : _err$details$response2.length) > 0) {
|
|
16633
|
+
var _err$details2, _err$details2$respons;
|
|
16634
|
+
const errorMessages = [];
|
|
16635
|
+
|
|
16636
|
+
// enumerable error (ex: validation errors)
|
|
16637
|
+
Object.values(err === null || err === void 0 ? void 0 : (_err$details2 = err.details) === null || _err$details2 === void 0 ? void 0 : (_err$details2$respons = _err$details2.responseStatus) === null || _err$details2$respons === void 0 ? void 0 : _err$details2$respons.details).forEach(_ref2 => {
|
|
16638
|
+
let {
|
|
16639
|
+
message
|
|
16640
|
+
} = _ref2;
|
|
16641
|
+
errorMessages.push(message);
|
|
16642
|
+
});
|
|
16643
|
+
|
|
16644
|
+
// convert to multiline string
|
|
16645
|
+
return errorMessages.join("\n");
|
|
16646
|
+
} else {
|
|
16647
|
+
var _err$details3;
|
|
16648
|
+
return getErrorMessages(err === null || err === void 0 ? void 0 : (_err$details3 = err.details) === null || _err$details3 === void 0 ? void 0 : _err$details3.responseStatus);
|
|
16649
|
+
}
|
|
16650
|
+
};
|
|
16651
|
+
const submitUsingCybersource = (state, dispatch) => {
|
|
16652
|
+
var _cybersourceInstanceR;
|
|
16403
16653
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16404
16654
|
if (isUsingExistingPaymentMethod) {
|
|
16405
|
-
// no need to create a new source using
|
|
16406
|
-
return
|
|
16655
|
+
// no need to create a new source using cybersrce
|
|
16656
|
+
return handleCybersourcePayment(null, state);
|
|
16407
16657
|
}
|
|
16408
|
-
if (!
|
|
16409
|
-
return console.error("
|
|
16658
|
+
if (!cybersourceInstanceRef.current) {
|
|
16659
|
+
return console.error("Cybersource sdk script wasn't loaded, you need to load Cybersource sdk before rendering the Cybersource payment flow");
|
|
16410
16660
|
}
|
|
16411
|
-
|
|
16412
|
-
|
|
16413
|
-
|
|
16414
|
-
}
|
|
16415
|
-
const isQuickPurchase = !Array.isArray(order);
|
|
16416
|
-
if (isQuickPurchase) {
|
|
16417
|
-
return order.price * order.quantity;
|
|
16418
|
-
}
|
|
16419
|
-
if (order.length === 0) {
|
|
16420
|
-
return null;
|
|
16421
|
-
}
|
|
16422
|
-
return order.reduce((total, item) => {
|
|
16423
|
-
return total + item.price * item.quantity;
|
|
16424
|
-
}, 0);
|
|
16661
|
+
let options = {
|
|
16662
|
+
cardExpirationMonth: state.month,
|
|
16663
|
+
cardExpirationYear: state.year
|
|
16425
16664
|
};
|
|
16426
|
-
|
|
16427
|
-
|
|
16428
|
-
if (result.error) {
|
|
16429
|
-
// Inform the user if there was an error
|
|
16430
|
-
onFailure(result.error);
|
|
16665
|
+
(_cybersourceInstanceR = cybersourceInstanceRef.current) === null || _cybersourceInstanceR === void 0 ? void 0 : _cybersourceInstanceR.createToken(options, function (err, response) {
|
|
16666
|
+
if (err) {
|
|
16431
16667
|
dispatch({
|
|
16432
16668
|
type: DISABLE_SUBMIT,
|
|
16433
16669
|
payload: false
|
|
@@ -16440,40 +16676,280 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16440
16676
|
type: SHOW_ALERT,
|
|
16441
16677
|
payload: {
|
|
16442
16678
|
type: "error",
|
|
16443
|
-
content:
|
|
16679
|
+
content: cybersourceErrorHandle(err)
|
|
16444
16680
|
}
|
|
16445
16681
|
});
|
|
16446
|
-
}
|
|
16447
|
-
|
|
16448
|
-
|
|
16449
|
-
|
|
16450
|
-
|
|
16451
|
-
|
|
16452
|
-
|
|
16453
|
-
|
|
16454
|
-
|
|
16455
|
-
|
|
16456
|
-
|
|
16457
|
-
|
|
16458
|
-
|
|
16459
|
-
|
|
16460
|
-
|
|
16461
|
-
|
|
16462
|
-
|
|
16463
|
-
|
|
16464
|
-
|
|
16465
|
-
|
|
16466
|
-
|
|
16467
|
-
|
|
16468
|
-
|
|
16469
|
-
|
|
16470
|
-
|
|
16471
|
-
|
|
16472
|
-
|
|
16473
|
-
|
|
16474
|
-
|
|
16475
|
-
|
|
16476
|
-
|
|
16682
|
+
}
|
|
16683
|
+
handleCybersourcePayment(response.token, state);
|
|
16684
|
+
});
|
|
16685
|
+
};
|
|
16686
|
+
function handleCybersourcePayment(paymentRequest, state) {
|
|
16687
|
+
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16688
|
+
if (type === "createPayment") {
|
|
16689
|
+
handleCybersourceSubscription();
|
|
16690
|
+
} else if (type === "orderCreate") {
|
|
16691
|
+
purchase(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
|
|
16692
|
+
} else if (type === "invoicePayment") {
|
|
16693
|
+
payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
|
|
16694
|
+
} else if (type === "updatePaymentSource") {
|
|
16695
|
+
createNewCybersourceCard();
|
|
16696
|
+
}
|
|
16697
|
+
function createNewCybersourceCard() {
|
|
16698
|
+
window.Pelcro.source.create({
|
|
16699
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16700
|
+
token: paymentRequest,
|
|
16701
|
+
gateway: "cybersource"
|
|
16702
|
+
}, (err, res) => {
|
|
16703
|
+
dispatch({
|
|
16704
|
+
type: DISABLE_SUBMIT,
|
|
16705
|
+
payload: false
|
|
16706
|
+
});
|
|
16707
|
+
dispatch({
|
|
16708
|
+
type: LOADING,
|
|
16709
|
+
payload: false
|
|
16710
|
+
});
|
|
16711
|
+
toggleAuthenticationSuccessPendingView(false);
|
|
16712
|
+
if (err) {
|
|
16713
|
+
onFailure(err);
|
|
16714
|
+
return dispatch({
|
|
16715
|
+
type: SHOW_ALERT,
|
|
16716
|
+
payload: {
|
|
16717
|
+
type: "error",
|
|
16718
|
+
content: getErrorMessages(err)
|
|
16719
|
+
}
|
|
16720
|
+
});
|
|
16721
|
+
}
|
|
16722
|
+
dispatch({
|
|
16723
|
+
type: SHOW_ALERT,
|
|
16724
|
+
payload: {
|
|
16725
|
+
type: "success",
|
|
16726
|
+
content: t("messages.sourceUpdated")
|
|
16727
|
+
}
|
|
16728
|
+
});
|
|
16729
|
+
onSuccess(res);
|
|
16730
|
+
} //
|
|
16731
|
+
);
|
|
16732
|
+
}
|
|
16733
|
+
|
|
16734
|
+
function handleCybersourceSubscription() {
|
|
16735
|
+
const payment = new Payment(new CybersourceGateway());
|
|
16736
|
+
const createSubscription = !isGift && !subscriptionIdToRenew;
|
|
16737
|
+
const renewSubscription = !isGift && subscriptionIdToRenew;
|
|
16738
|
+
const giftSubscriprition = isGift && !subscriptionIdToRenew;
|
|
16739
|
+
const renewGift = isRenewingGift;
|
|
16740
|
+
const {
|
|
16741
|
+
couponCode
|
|
16742
|
+
} = state;
|
|
16743
|
+
if (renewGift) {
|
|
16744
|
+
return payment.execute({
|
|
16745
|
+
type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
|
|
16746
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
|
|
16747
|
+
plan,
|
|
16748
|
+
couponCode,
|
|
16749
|
+
product,
|
|
16750
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
16751
|
+
subscriptionIdToRenew,
|
|
16752
|
+
addressId: selectedAddressId
|
|
16753
|
+
}, (err, res) => {
|
|
16754
|
+
if (err) {
|
|
16755
|
+
return handlePaymentError(err);
|
|
16756
|
+
}
|
|
16757
|
+
onSuccess(res);
|
|
16758
|
+
});
|
|
16759
|
+
} else if (giftSubscriprition) {
|
|
16760
|
+
return payment.execute({
|
|
16761
|
+
type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
|
|
16762
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
|
|
16763
|
+
quantity: plan.quantity,
|
|
16764
|
+
plan,
|
|
16765
|
+
couponCode,
|
|
16766
|
+
product,
|
|
16767
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
16768
|
+
giftRecipient,
|
|
16769
|
+
addressId: selectedAddressId
|
|
16770
|
+
}, (err, res) => {
|
|
16771
|
+
if (err) {
|
|
16772
|
+
return handlePaymentError(err);
|
|
16773
|
+
}
|
|
16774
|
+
onSuccess(res);
|
|
16775
|
+
});
|
|
16776
|
+
} else if (renewSubscription) {
|
|
16777
|
+
return payment.execute({
|
|
16778
|
+
type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
|
|
16779
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
|
|
16780
|
+
quantity: plan.quantity,
|
|
16781
|
+
plan,
|
|
16782
|
+
couponCode,
|
|
16783
|
+
product,
|
|
16784
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
16785
|
+
subscriptionIdToRenew,
|
|
16786
|
+
addressId: selectedAddressId
|
|
16787
|
+
}, (err, res) => {
|
|
16788
|
+
if (err) {
|
|
16789
|
+
return handlePaymentError(err);
|
|
16790
|
+
}
|
|
16791
|
+
onSuccess(res);
|
|
16792
|
+
});
|
|
16793
|
+
} else if (createSubscription) {
|
|
16794
|
+
return payment.execute({
|
|
16795
|
+
type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
|
|
16796
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
|
|
16797
|
+
quantity: plan.quantity,
|
|
16798
|
+
plan,
|
|
16799
|
+
couponCode,
|
|
16800
|
+
product,
|
|
16801
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
16802
|
+
addressId: selectedAddressId
|
|
16803
|
+
}, (err, res) => {
|
|
16804
|
+
if (err) {
|
|
16805
|
+
return handlePaymentError(err);
|
|
16806
|
+
}
|
|
16807
|
+
onSuccess(res);
|
|
16808
|
+
});
|
|
16809
|
+
}
|
|
16810
|
+
}
|
|
16811
|
+
}
|
|
16812
|
+
const tokenizeCard = (error, microformInstance) => {
|
|
16813
|
+
if (error) {
|
|
16814
|
+
return;
|
|
16815
|
+
}
|
|
16816
|
+
cybersourceInstanceRef.current = microformInstance;
|
|
16817
|
+
};
|
|
16818
|
+
const initCybersourceScript = () => {
|
|
16819
|
+
// jwk api call
|
|
16820
|
+
window.Pelcro.payment.getJWK({
|
|
16821
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16822
|
+
site_id: window.Pelcro.siteid
|
|
16823
|
+
}, (err, res) => {
|
|
16824
|
+
if (err) {
|
|
16825
|
+
onFailure(err);
|
|
16826
|
+
dispatch({
|
|
16827
|
+
type: DISABLE_SUBMIT,
|
|
16828
|
+
payload: false
|
|
16829
|
+
});
|
|
16830
|
+
dispatch({
|
|
16831
|
+
type: LOADING,
|
|
16832
|
+
payload: false
|
|
16833
|
+
});
|
|
16834
|
+
return dispatch({
|
|
16835
|
+
type: SHOW_ALERT,
|
|
16836
|
+
payload: {
|
|
16837
|
+
type: "error",
|
|
16838
|
+
content: getErrorMessages(err)
|
|
16839
|
+
}
|
|
16840
|
+
});
|
|
16841
|
+
}
|
|
16842
|
+
const {
|
|
16843
|
+
key: jwk
|
|
16844
|
+
} = res;
|
|
16845
|
+
// SETUP MICROFORM
|
|
16846
|
+
FLEX.microform({
|
|
16847
|
+
keyId: jwk.kid,
|
|
16848
|
+
keystore: jwk,
|
|
16849
|
+
container: "#cybersourceCardNumber",
|
|
16850
|
+
placeholder: "Card Number",
|
|
16851
|
+
styles: {
|
|
16852
|
+
input: {
|
|
16853
|
+
"font-size": "14px",
|
|
16854
|
+
"font-family": "helvetica, tahoma, calibri, sans-serif",
|
|
16855
|
+
color: "#555"
|
|
16856
|
+
},
|
|
16857
|
+
":focus": {
|
|
16858
|
+
color: "blue"
|
|
16859
|
+
},
|
|
16860
|
+
":disabled": {
|
|
16861
|
+
cursor: "not-allowed"
|
|
16862
|
+
},
|
|
16863
|
+
valid: {
|
|
16864
|
+
color: "#3c763d"
|
|
16865
|
+
},
|
|
16866
|
+
invalid: {
|
|
16867
|
+
color: "#a94442"
|
|
16868
|
+
}
|
|
16869
|
+
}
|
|
16870
|
+
}, tokenizeCard);
|
|
16871
|
+
});
|
|
16872
|
+
};
|
|
16873
|
+
|
|
16874
|
+
/*====== End Cybersource integration ========*/
|
|
16875
|
+
|
|
16876
|
+
/*====== Start Tap integration ========*/
|
|
16877
|
+
const submitUsingTap = state => {
|
|
16878
|
+
var _ref3, _ref4, _ref5, _state$updatedPrice;
|
|
16879
|
+
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16880
|
+
if (isUsingExistingPaymentMethod) {
|
|
16881
|
+
// no need to create a new source using tap
|
|
16882
|
+
return handleTapPayment(null, state);
|
|
16883
|
+
}
|
|
16884
|
+
if (!tapInstanceRef.current) {
|
|
16885
|
+
return console.error("Tap sdk script wasn't loaded, you need to load tap sdk before rendering the tap payment flow");
|
|
16886
|
+
}
|
|
16887
|
+
const getOrderItemsTotal = () => {
|
|
16888
|
+
if (!order) {
|
|
16889
|
+
return null;
|
|
16890
|
+
}
|
|
16891
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
16892
|
+
if (isQuickPurchase) {
|
|
16893
|
+
return order.price * order.quantity;
|
|
16894
|
+
}
|
|
16895
|
+
if (order.length === 0) {
|
|
16896
|
+
return null;
|
|
16897
|
+
}
|
|
16898
|
+
return order.reduce((total, item) => {
|
|
16899
|
+
return total + item.price * item.quantity;
|
|
16900
|
+
}, 0);
|
|
16901
|
+
};
|
|
16902
|
+
const totalAmount = (_ref3 = (_ref4 = (_ref5 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref5 !== void 0 ? _ref5 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref4 !== void 0 ? _ref4 : getOrderItemsTotal()) !== null && _ref3 !== void 0 ? _ref3 : 10;
|
|
16903
|
+
tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
|
|
16904
|
+
if (result.error) {
|
|
16905
|
+
// Inform the user if there was an error
|
|
16906
|
+
onFailure(result.error);
|
|
16907
|
+
dispatch({
|
|
16908
|
+
type: DISABLE_SUBMIT,
|
|
16909
|
+
payload: false
|
|
16910
|
+
});
|
|
16911
|
+
dispatch({
|
|
16912
|
+
type: LOADING,
|
|
16913
|
+
payload: false
|
|
16914
|
+
});
|
|
16915
|
+
return dispatch({
|
|
16916
|
+
type: SHOW_ALERT,
|
|
16917
|
+
payload: {
|
|
16918
|
+
type: "error",
|
|
16919
|
+
content: getErrorMessages(result.error)
|
|
16920
|
+
}
|
|
16921
|
+
});
|
|
16922
|
+
} else {
|
|
16923
|
+
window.Pelcro.payment.verify({
|
|
16924
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16925
|
+
first_name: window.Pelcro.user.read().first_name || state.firstName,
|
|
16926
|
+
last_name: window.Pelcro.user.read().last_name || state.lastName,
|
|
16927
|
+
phone: window.Pelcro.user.read().phone || state.phone,
|
|
16928
|
+
site_id: window.Pelcro.siteid,
|
|
16929
|
+
amount: totalAmount,
|
|
16930
|
+
currency: (plan === null || plan === void 0 ? void 0 : plan.currency) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency) || window.Pelcro.site.read().default_currency,
|
|
16931
|
+
tap_token: result.id,
|
|
16932
|
+
funding: result.card.funding,
|
|
16933
|
+
redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}&type=verify_card&site_id=${window.Pelcro.siteid}`
|
|
16934
|
+
}, (err, res) => {
|
|
16935
|
+
if (err) {
|
|
16936
|
+
// Inform the user if there was an error
|
|
16937
|
+
onFailure(err);
|
|
16938
|
+
dispatch({
|
|
16939
|
+
type: DISABLE_SUBMIT,
|
|
16940
|
+
payload: false
|
|
16941
|
+
});
|
|
16942
|
+
dispatch({
|
|
16943
|
+
type: LOADING,
|
|
16944
|
+
payload: false
|
|
16945
|
+
});
|
|
16946
|
+
return dispatch({
|
|
16947
|
+
type: SHOW_ALERT,
|
|
16948
|
+
payload: {
|
|
16949
|
+
type: "error",
|
|
16950
|
+
content: getErrorMessages(err)
|
|
16951
|
+
}
|
|
16952
|
+
});
|
|
16477
16953
|
} else {
|
|
16478
16954
|
toggleAuthenticationPendingView(true, res);
|
|
16479
16955
|
const listenFor3DSecureCompletionMessage = () => {
|
|
@@ -16688,7 +17164,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16688
17164
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16689
17165
|
if (isUsingExistingPaymentMethod) {
|
|
16690
17166
|
// no need to create a new source using vantiv
|
|
16691
|
-
return handleVantivPayment(null);
|
|
17167
|
+
return handleVantivPayment(null, state.couponCode);
|
|
16692
17168
|
}
|
|
16693
17169
|
if (!vantivInstanceRef.current) {
|
|
16694
17170
|
return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
|
|
@@ -16840,8 +17316,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16840
17316
|
const vantivInstanceRef = React__default['default'].useRef(null);
|
|
16841
17317
|
const tapInstanceRef = React__default['default'].useRef(null);
|
|
16842
17318
|
const tapInstanceCard = React__default['default'].useRef(null);
|
|
17319
|
+
const cybersourceInstanceRef = React__default['default'].useRef(null);
|
|
16843
17320
|
React.useEffect(() => {
|
|
16844
|
-
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 ||
|
|
17321
|
+
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
16845
17322
|
if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
|
|
16846
17323
|
var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
|
|
16847
17324
|
const payPageId = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.vantiv_gateway_settings.pay_page_id;
|
|
@@ -16877,7 +17354,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16877
17354
|
}, [vantivPaymentRequest]);
|
|
16878
17355
|
React.useEffect(() => {
|
|
16879
17356
|
whenUserReady(() => {
|
|
16880
|
-
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 ||
|
|
17357
|
+
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
16881
17358
|
if (cardProcessor === "tap" && !window.Tapjsli) {
|
|
16882
17359
|
window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
|
|
16883
17360
|
window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
|
|
@@ -16888,10 +17365,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16888
17365
|
if (cardProcessor === "tap" && !selectedPaymentMethodId && window.Tapjsli) {
|
|
16889
17366
|
initTapScript();
|
|
16890
17367
|
}
|
|
17368
|
+
if (cardProcessor === "cybersource" && !selectedPaymentMethodId && !window.FLEX) {
|
|
17369
|
+
window.Pelcro.helpers.loadSDK("https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js", "cybersource-cdn");
|
|
17370
|
+
document.querySelector('script[src="https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js"]').addEventListener("load", () => {
|
|
17371
|
+
initCybersourceScript();
|
|
17372
|
+
});
|
|
17373
|
+
}
|
|
17374
|
+
if (cardProcessor === "cybersource" && !selectedPaymentMethodId && window.FLEX) {
|
|
17375
|
+
initCybersourceScript();
|
|
17376
|
+
}
|
|
16891
17377
|
});
|
|
16892
17378
|
}, [selectedPaymentMethodId]);
|
|
16893
17379
|
const initPaymentRequest = (state, dispatch) => {
|
|
16894
|
-
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 ||
|
|
17380
|
+
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
16895
17381
|
try {
|
|
16896
17382
|
const paymentRequest = stripe.paymentRequest({
|
|
16897
17383
|
country: window.Pelcro.user.location.countryCode || "US",
|
|
@@ -16903,13 +17389,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16903
17389
|
});
|
|
16904
17390
|
|
|
16905
17391
|
// When Google pay / Apple pay source created
|
|
16906
|
-
paymentRequest.on("source",
|
|
17392
|
+
paymentRequest.on("source", _ref6 => {
|
|
16907
17393
|
var _source$card;
|
|
16908
17394
|
let {
|
|
16909
17395
|
complete,
|
|
16910
17396
|
source,
|
|
16911
17397
|
...data
|
|
16912
|
-
} =
|
|
17398
|
+
} = _ref6;
|
|
16913
17399
|
dispatch({
|
|
16914
17400
|
type: DISABLE_COUPON_BUTTON,
|
|
16915
17401
|
payload: true
|
|
@@ -16924,11 +17410,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16924
17410
|
});
|
|
16925
17411
|
complete("success");
|
|
16926
17412
|
if ((source === null || source === void 0 ? void 0 : (_source$card = source.card) === null || _source$card === void 0 ? void 0 : _source$card.three_d_secure) === "required") {
|
|
16927
|
-
return generate3DSecureSource(source).then(
|
|
17413
|
+
return generate3DSecureSource(source).then(_ref7 => {
|
|
16928
17414
|
let {
|
|
16929
17415
|
source,
|
|
16930
17416
|
error
|
|
16931
|
-
} =
|
|
17417
|
+
} = _ref7;
|
|
16932
17418
|
if (error) {
|
|
16933
17419
|
return handlePaymentError(error);
|
|
16934
17420
|
}
|
|
@@ -16960,7 +17446,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16960
17446
|
*/
|
|
16961
17447
|
const updateTotalAmountWithTax = () => {
|
|
16962
17448
|
var _window$Pelcro$site$r4;
|
|
16963
|
-
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 ||
|
|
17449
|
+
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
16964
17450
|
const taxesEnabled = (_window$Pelcro$site$r4 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.taxes_enabled;
|
|
16965
17451
|
if (taxesEnabled && type === "createPayment") {
|
|
16966
17452
|
dispatch({
|
|
@@ -17235,6 +17721,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17235
17721
|
type: LOADING,
|
|
17236
17722
|
payload: false
|
|
17237
17723
|
});
|
|
17724
|
+
onFailure(error);
|
|
17238
17725
|
return dispatch({
|
|
17239
17726
|
type: SHOW_ALERT,
|
|
17240
17727
|
payload: {
|
|
@@ -17457,16 +17944,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17457
17944
|
items: mappedOrderItems,
|
|
17458
17945
|
addressId: selectedAddressId,
|
|
17459
17946
|
couponCode
|
|
17460
|
-
}, (err,
|
|
17461
|
-
|
|
17462
|
-
type: DISABLE_SUBMIT,
|
|
17463
|
-
payload: false
|
|
17464
|
-
});
|
|
17465
|
-
dispatch({
|
|
17466
|
-
type: LOADING,
|
|
17467
|
-
payload: false
|
|
17468
|
-
});
|
|
17947
|
+
}, (err, orderResponse) => {
|
|
17948
|
+
var _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$;
|
|
17469
17949
|
if (err) {
|
|
17950
|
+
toggleAuthenticationSuccessPendingView(false);
|
|
17951
|
+
dispatch({
|
|
17952
|
+
type: DISABLE_SUBMIT,
|
|
17953
|
+
payload: false
|
|
17954
|
+
});
|
|
17955
|
+
dispatch({
|
|
17956
|
+
type: LOADING,
|
|
17957
|
+
payload: false
|
|
17958
|
+
});
|
|
17470
17959
|
onFailure(err);
|
|
17471
17960
|
return dispatch({
|
|
17472
17961
|
type: SHOW_ALERT,
|
|
@@ -17486,7 +17975,30 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17486
17975
|
cartItems: []
|
|
17487
17976
|
});
|
|
17488
17977
|
}
|
|
17489
|
-
|
|
17978
|
+
window.Pelcro.user.refresh({
|
|
17979
|
+
auth_token: (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : (_window$Pelcro2$user$ = _window$Pelcro2$user.read()) === null || _window$Pelcro2$user$ === void 0 ? void 0 : _window$Pelcro2$user$.auth_token
|
|
17980
|
+
}, (err, res) => {
|
|
17981
|
+
dispatch({
|
|
17982
|
+
type: DISABLE_SUBMIT,
|
|
17983
|
+
payload: false
|
|
17984
|
+
});
|
|
17985
|
+
dispatch({
|
|
17986
|
+
type: LOADING,
|
|
17987
|
+
payload: false
|
|
17988
|
+
});
|
|
17989
|
+
toggleAuthenticationSuccessPendingView(false);
|
|
17990
|
+
if (err) {
|
|
17991
|
+
onFailure(err);
|
|
17992
|
+
return dispatch({
|
|
17993
|
+
type: SHOW_ALERT,
|
|
17994
|
+
payload: {
|
|
17995
|
+
type: "error",
|
|
17996
|
+
content: getErrorMessages(err)
|
|
17997
|
+
}
|
|
17998
|
+
});
|
|
17999
|
+
}
|
|
18000
|
+
onSuccess(orderResponse);
|
|
18001
|
+
});
|
|
17490
18002
|
});
|
|
17491
18003
|
};
|
|
17492
18004
|
const payInvoice = (gatewayService, gatewayToken, dispatch) => {
|
|
@@ -17503,12 +18015,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17503
18015
|
const updatePaymentSource = (state, dispatch) => {
|
|
17504
18016
|
return stripe.createSource({
|
|
17505
18017
|
type: "card"
|
|
17506
|
-
}).then(
|
|
18018
|
+
}).then(_ref8 => {
|
|
17507
18019
|
var _source$card2;
|
|
17508
18020
|
let {
|
|
17509
18021
|
source,
|
|
17510
18022
|
error
|
|
17511
|
-
} =
|
|
18023
|
+
} = _ref8;
|
|
17512
18024
|
if (error) {
|
|
17513
18025
|
return handlePaymentError(error);
|
|
17514
18026
|
}
|
|
@@ -17564,7 +18076,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17564
18076
|
});
|
|
17565
18077
|
};
|
|
17566
18078
|
const submitPayment = (state, dispatch) => {
|
|
17567
|
-
if (skipPayment &&
|
|
18079
|
+
if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
|
|
17568
18080
|
const isQuickPurchase = !Array.isArray(order);
|
|
17569
18081
|
const mappedOrderItems = isQuickPurchase ? [{
|
|
17570
18082
|
sku_id: order.id,
|
|
@@ -17589,12 +18101,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17589
18101
|
}
|
|
17590
18102
|
stripe.createSource({
|
|
17591
18103
|
type: "card"
|
|
17592
|
-
}).then(
|
|
17593
|
-
var
|
|
18104
|
+
}).then(_ref9 => {
|
|
18105
|
+
var _ref10, _ref11, _state$updatedPrice2;
|
|
17594
18106
|
let {
|
|
17595
18107
|
source,
|
|
17596
18108
|
error
|
|
17597
|
-
} =
|
|
18109
|
+
} = _ref9;
|
|
17598
18110
|
if (error) {
|
|
17599
18111
|
return handlePaymentError(error);
|
|
17600
18112
|
}
|
|
@@ -17613,7 +18125,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17613
18125
|
return total + item.price * item.quantity;
|
|
17614
18126
|
}, 0);
|
|
17615
18127
|
};
|
|
17616
|
-
(
|
|
18128
|
+
(_ref10 = (_ref11 = (_state$updatedPrice2 = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice2 !== void 0 ? _state$updatedPrice2 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref11 !== void 0 ? _ref11 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref10 !== void 0 ? _ref10 : getOrderItemsTotal();
|
|
17617
18129
|
return handlePayment(source);
|
|
17618
18130
|
}).catch(error => {
|
|
17619
18131
|
return handlePaymentError(error);
|
|
@@ -17820,15 +18332,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17820
18332
|
disableSubmit: true,
|
|
17821
18333
|
isLoading: true
|
|
17822
18334
|
}, (state, dispatch) => {
|
|
17823
|
-
if (skipPayment &&
|
|
18335
|
+
if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
|
|
17824
18336
|
return submitPayment(state);
|
|
17825
18337
|
}
|
|
17826
18338
|
if (getSiteCardProcessor() === "vantiv") {
|
|
17827
|
-
return submitUsingVantiv();
|
|
18339
|
+
return submitUsingVantiv(state);
|
|
17828
18340
|
}
|
|
17829
18341
|
if (getSiteCardProcessor() === "tap") {
|
|
17830
18342
|
return submitUsingTap(state);
|
|
17831
18343
|
}
|
|
18344
|
+
if (getSiteCardProcessor() === "cybersource") {
|
|
18345
|
+
return submitUsingCybersource(state, dispatch);
|
|
18346
|
+
}
|
|
17832
18347
|
if (selectedPaymentMethodId) {
|
|
17833
18348
|
// pay with selected method (source) if exists already
|
|
17834
18349
|
return handlePayment({
|
|
@@ -17896,6 +18411,16 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17896
18411
|
...state,
|
|
17897
18412
|
percentOff: action.payload
|
|
17898
18413
|
});
|
|
18414
|
+
case SET_MONTH:
|
|
18415
|
+
return lib_7({
|
|
18416
|
+
...state,
|
|
18417
|
+
month: action.payload
|
|
18418
|
+
});
|
|
18419
|
+
case SET_YEAR:
|
|
18420
|
+
return lib_7({
|
|
18421
|
+
...state,
|
|
18422
|
+
year: action.payload
|
|
18423
|
+
});
|
|
17899
18424
|
case SET_FIRST_NAME:
|
|
17900
18425
|
return lib_7({
|
|
17901
18426
|
...state,
|
|
@@ -17986,13 +18511,122 @@ const PaymentMethodContainer = props => {
|
|
|
17986
18511
|
}, /*#__PURE__*/React__default['default'].createElement(es_11, null, /*#__PURE__*/React__default['default'].createElement(UnwrappedForm, Object.assign({
|
|
17987
18512
|
store: store$k
|
|
17988
18513
|
}, props))));
|
|
17989
|
-
} else {
|
|
18514
|
+
} else if (cardProcessor !== "stripe") {
|
|
17990
18515
|
return /*#__PURE__*/React__default['default'].createElement(PaymentMethodContainerWithoutStripe, Object.assign({
|
|
17991
18516
|
store: store$k
|
|
17992
18517
|
}, props));
|
|
17993
18518
|
}
|
|
18519
|
+
return null;
|
|
17994
18520
|
};
|
|
17995
18521
|
|
|
18522
|
+
function Select(_ref) {
|
|
18523
|
+
let {
|
|
18524
|
+
label = "",
|
|
18525
|
+
required,
|
|
18526
|
+
id,
|
|
18527
|
+
errorId,
|
|
18528
|
+
error = "",
|
|
18529
|
+
className = "",
|
|
18530
|
+
labelClassName = "",
|
|
18531
|
+
errorClassName = "",
|
|
18532
|
+
wrapperClassName = "",
|
|
18533
|
+
children,
|
|
18534
|
+
...otherProps
|
|
18535
|
+
} = _ref;
|
|
18536
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
18537
|
+
className: `pelcro-input-wrapper ${wrapperClassName}`
|
|
18538
|
+
}, /*#__PURE__*/React__default['default'].createElement("label", {
|
|
18539
|
+
htmlFor: id,
|
|
18540
|
+
className: `pelcro-input-label ${labelClassName}`
|
|
18541
|
+
}, `${label}${required ? "*" : ""}`), /*#__PURE__*/React__default['default'].createElement("select", Object.assign({
|
|
18542
|
+
id: id,
|
|
18543
|
+
className: `pelcro-input-field ${className} ${error ? "pelcro-input-invalid" : ""}`,
|
|
18544
|
+
"aria-describedby": errorId,
|
|
18545
|
+
"aria-invalid": Boolean(error)
|
|
18546
|
+
}, otherProps), children), error && /*#__PURE__*/React__default['default'].createElement("p", {
|
|
18547
|
+
id: errorId,
|
|
18548
|
+
"aria-live": "assertive",
|
|
18549
|
+
className: `pelcro-input-error ${errorClassName}`
|
|
18550
|
+
}, error));
|
|
18551
|
+
}
|
|
18552
|
+
|
|
18553
|
+
function MonthSelect(_ref) {
|
|
18554
|
+
let {
|
|
18555
|
+
placeholder,
|
|
18556
|
+
store,
|
|
18557
|
+
...otherProps
|
|
18558
|
+
} = _ref;
|
|
18559
|
+
const {
|
|
18560
|
+
dispatch,
|
|
18561
|
+
state: {
|
|
18562
|
+
month
|
|
18563
|
+
}
|
|
18564
|
+
} = React.useContext(store);
|
|
18565
|
+
const get2digits = num => num < 10 ? "0" + num.toString() : num.toString();
|
|
18566
|
+
const createMonthsItems = React.useMemo(() => {
|
|
18567
|
+
return [...Array.from({
|
|
18568
|
+
length: 12
|
|
18569
|
+
}, (_, i) => i + 1)].map(i => {
|
|
18570
|
+
return /*#__PURE__*/React__default['default'].createElement("option", {
|
|
18571
|
+
key: i,
|
|
18572
|
+
value: get2digits(i)
|
|
18573
|
+
}, get2digits(i));
|
|
18574
|
+
});
|
|
18575
|
+
}, []);
|
|
18576
|
+
const handleInputChange = value => {
|
|
18577
|
+
dispatch({
|
|
18578
|
+
type: SET_MONTH,
|
|
18579
|
+
payload: value
|
|
18580
|
+
});
|
|
18581
|
+
};
|
|
18582
|
+
return /*#__PURE__*/React__default['default'].createElement(Select, Object.assign({
|
|
18583
|
+
value: month,
|
|
18584
|
+
onChange: e => handleInputChange(e.target.value)
|
|
18585
|
+
}, otherProps), /*#__PURE__*/React__default['default'].createElement("option", {
|
|
18586
|
+
value: "",
|
|
18587
|
+
disabled: true,
|
|
18588
|
+
selected: true
|
|
18589
|
+
}, placeholder), createMonthsItems);
|
|
18590
|
+
}
|
|
18591
|
+
|
|
18592
|
+
function YearSelect(_ref) {
|
|
18593
|
+
let {
|
|
18594
|
+
placeholder,
|
|
18595
|
+
store,
|
|
18596
|
+
...otherProps
|
|
18597
|
+
} = _ref;
|
|
18598
|
+
const {
|
|
18599
|
+
dispatch,
|
|
18600
|
+
state: {
|
|
18601
|
+
year
|
|
18602
|
+
}
|
|
18603
|
+
} = React.useContext(store);
|
|
18604
|
+
const createYearsItems = React.useMemo(() => {
|
|
18605
|
+
return Array.from({
|
|
18606
|
+
length: 10
|
|
18607
|
+
}, (_, i) => i + new Date().getFullYear()).map(i => {
|
|
18608
|
+
return /*#__PURE__*/React__default['default'].createElement("option", {
|
|
18609
|
+
key: i,
|
|
18610
|
+
value: i
|
|
18611
|
+
}, i);
|
|
18612
|
+
});
|
|
18613
|
+
}, []);
|
|
18614
|
+
const handleInputChange = value => {
|
|
18615
|
+
dispatch({
|
|
18616
|
+
type: SET_YEAR,
|
|
18617
|
+
payload: value
|
|
18618
|
+
});
|
|
18619
|
+
};
|
|
18620
|
+
return /*#__PURE__*/React__default['default'].createElement(Select, Object.assign({
|
|
18621
|
+
value: year,
|
|
18622
|
+
onChange: e => handleInputChange(e.target.value)
|
|
18623
|
+
}, otherProps), /*#__PURE__*/React__default['default'].createElement("option", {
|
|
18624
|
+
value: "",
|
|
18625
|
+
disabled: true,
|
|
18626
|
+
selected: true
|
|
18627
|
+
}, placeholder), createYearsItems);
|
|
18628
|
+
}
|
|
18629
|
+
|
|
17996
18630
|
const StripeInputStyle = {
|
|
17997
18631
|
base: "plc-w-full plc-p-3 plc-border plc-border-gray-300 plc-appearance-none plc-outline-none plc-rounded-sm plc-bg-gray-50 pelcro-input-input",
|
|
17998
18632
|
focus: "plc-ring-2 plc-ring-primary-400",
|
|
@@ -18082,6 +18716,24 @@ const CheckoutForm = () => {
|
|
|
18082
18716
|
id: "tapPaymentIframe"
|
|
18083
18717
|
});
|
|
18084
18718
|
}
|
|
18719
|
+
if (cardProcessor === "cybersource") {
|
|
18720
|
+
return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
18721
|
+
id: "cybersourceCardNumber",
|
|
18722
|
+
className: "pelcro-input-field plc-h-12"
|
|
18723
|
+
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
18724
|
+
className: "plc-flex plc-items-end plc-justify-between plc-my-2"
|
|
18725
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
18726
|
+
className: "plc-w-6/12 plc-pr-4"
|
|
18727
|
+
}, /*#__PURE__*/React__default['default'].createElement(MonthSelect, {
|
|
18728
|
+
store: store$k,
|
|
18729
|
+
placeholder: "Exp Month *"
|
|
18730
|
+
})), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
18731
|
+
className: "plc-w-6/12"
|
|
18732
|
+
}, /*#__PURE__*/React__default['default'].createElement(YearSelect, {
|
|
18733
|
+
store: store$k,
|
|
18734
|
+
placeholder: "Exp Year *"
|
|
18735
|
+
}))));
|
|
18736
|
+
}
|
|
18085
18737
|
if (cardProcessor === "stripe") {
|
|
18086
18738
|
return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(PelcroCardNumber, {
|
|
18087
18739
|
autoFocus: true
|
|
@@ -18142,13 +18794,14 @@ const DiscountedPrice = props => {
|
|
|
18142
18794
|
};
|
|
18143
18795
|
|
|
18144
18796
|
const SubmitPaymentMethod = _ref => {
|
|
18145
|
-
var _plan$quantity, _window$Pelcro$site$r;
|
|
18797
|
+
var _plan$quantity, _window$Pelcro$site$r, _window$Pelcro$site$r2;
|
|
18146
18798
|
let {
|
|
18147
18799
|
onClick,
|
|
18148
18800
|
...otherProps
|
|
18149
18801
|
} = _ref;
|
|
18150
18802
|
const {
|
|
18151
|
-
plan
|
|
18803
|
+
plan,
|
|
18804
|
+
selectedPaymentMethodId
|
|
18152
18805
|
} = usePelcro();
|
|
18153
18806
|
const {
|
|
18154
18807
|
t
|
|
@@ -18164,13 +18817,16 @@ const SubmitPaymentMethod = _ref => {
|
|
|
18164
18817
|
phone,
|
|
18165
18818
|
disableSubmit,
|
|
18166
18819
|
isLoading,
|
|
18167
|
-
updatedPrice
|
|
18820
|
+
updatedPrice,
|
|
18821
|
+
month,
|
|
18822
|
+
year
|
|
18168
18823
|
}
|
|
18169
18824
|
} = React.useContext(store$k);
|
|
18170
18825
|
const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
|
|
18171
18826
|
const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
|
|
18172
18827
|
const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
|
|
18173
18828
|
const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
|
|
18829
|
+
const supportsCybersource = Boolean((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.cybersource_gateway_settings);
|
|
18174
18830
|
const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
|
|
18175
18831
|
const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
|
|
18176
18832
|
const isUserPhone = Boolean(window.Pelcro.user.read().phone);
|
|
@@ -18179,9 +18835,9 @@ const SubmitPaymentMethod = _ref => {
|
|
|
18179
18835
|
if (supportsTap && isUserFirstName && isUserLastName && isUserPhone) {
|
|
18180
18836
|
setDisabled(disableSubmit);
|
|
18181
18837
|
} else {
|
|
18182
|
-
setDisabled(disableSubmit || supportsTap && firstNameError || supportsTap && lastNameError || supportsTap && phoneError || supportsTap && !(firstName !== null && firstName !== void 0 && firstName.length) || supportsTap && !(lastName !== null && lastName !== void 0 && lastName.length) || supportsTap && !(phone !== null && phone !== void 0 && phone.length));
|
|
18838
|
+
setDisabled(disableSubmit || supportsTap && firstNameError || supportsTap && lastNameError || supportsTap && phoneError || supportsTap && !(firstName !== null && firstName !== void 0 && firstName.length) || supportsTap && !(lastName !== null && lastName !== void 0 && lastName.length) || supportsTap && !(phone !== null && phone !== void 0 && phone.length) || supportsCybersource && !selectedPaymentMethodId && !(month !== null && month !== void 0 && month.length) || supportsCybersource && !selectedPaymentMethodId && !(year !== null && year !== void 0 && year.length));
|
|
18183
18839
|
}
|
|
18184
|
-
}, [disableSubmit, firstNameError, lastNameError, phoneError, firstName, lastName, phone]);
|
|
18840
|
+
}, [disableSubmit, firstNameError, lastNameError, phoneError, firstName, lastName, phone, month, year]);
|
|
18185
18841
|
return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
|
|
18186
18842
|
role: "submit",
|
|
18187
18843
|
className: "plc-w-full plc-py-3",
|
|
@@ -18820,7 +19476,7 @@ const OrderCreateFreeButton = _ref => {
|
|
|
18820
19476
|
*
|
|
18821
19477
|
*/
|
|
18822
19478
|
function PaymentMethodView(_ref) {
|
|
18823
|
-
var _window$Pelcro$site$r, _window$Pelcro$site$r2
|
|
19479
|
+
var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _calcAndFormatItemsTo, _order$;
|
|
18824
19480
|
let {
|
|
18825
19481
|
onSuccess,
|
|
18826
19482
|
onGiftRenewalSuccess,
|
|
@@ -18838,6 +19494,7 @@ function PaymentMethodView(_ref) {
|
|
|
18838
19494
|
const cardProcessor = getSiteCardProcessor();
|
|
18839
19495
|
const supportsVantiv = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings);
|
|
18840
19496
|
const supportsTap = Boolean((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.tap_gateway_settings);
|
|
19497
|
+
const supportsCybersource = Boolean((_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.cybersource_gateway_settings);
|
|
18841
19498
|
const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
|
|
18842
19499
|
const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
|
|
18843
19500
|
const isUserPhone = Boolean(window.Pelcro.user.read().phone);
|
|
@@ -18847,11 +19504,13 @@ function PaymentMethodView(_ref) {
|
|
|
18847
19504
|
className: "plc-w-full plc-p-2 plc-mb-4 plc-font-semibold plc-text-center plc-text-gray-900 plc-bg-gray-100 plc-border plc-border-gray-200"
|
|
18848
19505
|
}, /*#__PURE__*/React__default['default'].createElement("p", {
|
|
18849
19506
|
className: "plc-text-gray-600"
|
|
18850
|
-
}, /*#__PURE__*/React__default['default'].createElement("span", {
|
|
19507
|
+
}, !Array.isArray(order) ? /*#__PURE__*/React__default['default'].createElement("span", {
|
|
19508
|
+
className: "plc-tracking-wider plc-uppercase"
|
|
19509
|
+
}, order === null || order === void 0 ? void 0 : order.name) : /*#__PURE__*/React__default['default'].createElement("span", {
|
|
18851
19510
|
className: "plc-tracking-wider plc-uppercase"
|
|
18852
|
-
},
|
|
19511
|
+
}, t("labels.freeItems")), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
|
|
18853
19512
|
className: "plc-text-xl plc-font-semibold plc-text-primary-600"
|
|
18854
|
-
}, getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage())))), cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
19513
|
+
}, (_calcAndFormatItemsTo = calcAndFormatItemsTotal(order, (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency)) !== null && _calcAndFormatItemsTo !== void 0 ? _calcAndFormatItemsTo : getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage())))), cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
18855
19514
|
className: "plc-flex plc-items-center plc-w-full plc-px-4 plc-py-2 plc-text-center plc-text-green-600 plc-border plc-border-green-400 plc-rounded plc-bg-green-50"
|
|
18856
19515
|
}, /*#__PURE__*/React__default['default'].createElement(SvgLock, {
|
|
18857
19516
|
className: "plc-w-5 plc-h-5 plc-mr-1"
|
|
@@ -18867,7 +19526,8 @@ function PaymentMethodView(_ref) {
|
|
|
18867
19526
|
type: type,
|
|
18868
19527
|
onSuccess: onSuccess,
|
|
18869
19528
|
onGiftRenewalSuccess: onGiftRenewalSuccess,
|
|
18870
|
-
onFailure: onFailure
|
|
19529
|
+
onFailure: onFailure,
|
|
19530
|
+
freeOrders: showOrderButton
|
|
18871
19531
|
}, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
|
|
18872
19532
|
className: "plc-mb-2"
|
|
18873
19533
|
}), showSubscriptionButton && /*#__PURE__*/React__default['default'].createElement(SubscriptionCreateFreePlanButton, null), showOrderButton && /*#__PURE__*/React__default['default'].createElement(OrderCreateFreeButton, null), !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(BankRedirection, null), /*#__PURE__*/React__default['default'].createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
@@ -18892,7 +19552,7 @@ function PaymentMethodView(_ref) {
|
|
|
18892
19552
|
className: "plc-mb-2"
|
|
18893
19553
|
}, /*#__PURE__*/React__default['default'].createElement(CouponCode, null), /*#__PURE__*/React__default['default'].createElement(DiscountedPrice, null)), /*#__PURE__*/React__default['default'].createElement(TaxAmount, null), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
18894
19554
|
className: "plc-grid plc-mt-4 plc-gap-y-2"
|
|
18895
|
-
}, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : null)))));
|
|
19555
|
+
}, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : null)))));
|
|
18896
19556
|
}
|
|
18897
19557
|
|
|
18898
19558
|
const SubscriptionRenewView = _ref => {
|
|
@@ -21519,6 +22179,7 @@ const AddressCreateContainer = _ref => {
|
|
|
21519
22179
|
first_name: firstName,
|
|
21520
22180
|
last_name: lastName,
|
|
21521
22181
|
line1: line1,
|
|
22182
|
+
line2: line2,
|
|
21522
22183
|
city: city,
|
|
21523
22184
|
state: state,
|
|
21524
22185
|
country: country,
|
|
@@ -21913,37 +22574,6 @@ const AddressCreateSubmit = _ref => {
|
|
|
21913
22574
|
}, otherProps), name !== null && name !== void 0 ? name : t("buttons.submit"));
|
|
21914
22575
|
};
|
|
21915
22576
|
|
|
21916
|
-
function Select(_ref) {
|
|
21917
|
-
let {
|
|
21918
|
-
label = "",
|
|
21919
|
-
required,
|
|
21920
|
-
id,
|
|
21921
|
-
errorId,
|
|
21922
|
-
error = "",
|
|
21923
|
-
className = "",
|
|
21924
|
-
labelClassName = "",
|
|
21925
|
-
errorClassName = "",
|
|
21926
|
-
wrapperClassName = "",
|
|
21927
|
-
children,
|
|
21928
|
-
...otherProps
|
|
21929
|
-
} = _ref;
|
|
21930
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
21931
|
-
className: `pelcro-input-wrapper ${wrapperClassName}`
|
|
21932
|
-
}, /*#__PURE__*/React__default['default'].createElement("label", {
|
|
21933
|
-
htmlFor: id,
|
|
21934
|
-
className: `pelcro-input-label ${labelClassName}`
|
|
21935
|
-
}, `${label}${required ? "*" : ""}`), /*#__PURE__*/React__default['default'].createElement("select", Object.assign({
|
|
21936
|
-
id: id,
|
|
21937
|
-
className: `pelcro-input-field ${className} ${error ? "pelcro-input-invalid" : ""}`,
|
|
21938
|
-
"aria-describedby": errorId,
|
|
21939
|
-
"aria-invalid": Boolean(error)
|
|
21940
|
-
}, otherProps), children), error && /*#__PURE__*/React__default['default'].createElement("p", {
|
|
21941
|
-
id: errorId,
|
|
21942
|
-
"aria-live": "assertive",
|
|
21943
|
-
className: `pelcro-input-error ${errorClassName}`
|
|
21944
|
-
}, error));
|
|
21945
|
-
}
|
|
21946
|
-
|
|
21947
22577
|
function CountrySelect(_ref) {
|
|
21948
22578
|
let {
|
|
21949
22579
|
placeholder,
|
|
@@ -22346,6 +22976,7 @@ const AddressUpdateContainer = _ref => {
|
|
|
22346
22976
|
first_name: firstName,
|
|
22347
22977
|
last_name: lastName,
|
|
22348
22978
|
line1: line1,
|
|
22979
|
+
line2: line2,
|
|
22349
22980
|
city: city,
|
|
22350
22981
|
state: state,
|
|
22351
22982
|
country: country,
|
|
@@ -24293,7 +24924,7 @@ const OrderCreateView = props => {
|
|
|
24293
24924
|
order
|
|
24294
24925
|
} = usePelcro();
|
|
24295
24926
|
const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
|
|
24296
|
-
const showOrderButton = skipPayment && (order === null || order === void 0 ? void 0 : order.price) === 0;
|
|
24927
|
+
const showOrderButton = skipPayment && ((order === null || order === void 0 ? void 0 : order.price) === 0 || (order === null || order === void 0 ? void 0 : order.length) > 0 && order.every(item => (item === null || item === void 0 ? void 0 : item.price) === 0));
|
|
24297
24928
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
24298
24929
|
id: "pelcro-order-create-view"
|
|
24299
24930
|
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
@@ -27627,7 +28258,7 @@ const InvoicesItems = () => {
|
|
|
27627
28258
|
setInvoice,
|
|
27628
28259
|
switchView
|
|
27629
28260
|
} = usePelcro();
|
|
27630
|
-
const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
|
|
28261
|
+
const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.order_id || invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
|
|
27631
28262
|
const showInvoiceDetails = event => {
|
|
27632
28263
|
if (setInvoice(event.target.dataset.id)) {
|
|
27633
28264
|
switchView("invoice-details");
|
|
@@ -28395,7 +29026,7 @@ class Dashboard extends React.Component {
|
|
|
28395
29026
|
}
|
|
28396
29027
|
function hasInvoices() {
|
|
28397
29028
|
var _window$Pelcro$invoic, _window$Pelcro$invoic2;
|
|
28398
|
-
const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
|
|
29029
|
+
const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.order_id || invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
|
|
28399
29030
|
return invoices.length > 0;
|
|
28400
29031
|
}
|
|
28401
29032
|
function hasDonationSubs() {
|