@pelcro/react-pelcro-js 3.21.6 → 3.21.8
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 +847 -135
- package/dist/index.esm.js +847 -136
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3427,7 +3427,8 @@ var labels$10 = {
|
|
|
3427
3427
|
removeCoupon: "REMOVE",
|
|
3428
3428
|
firstName: "First name",
|
|
3429
3429
|
lastName: "Last name",
|
|
3430
|
-
phone: "Phone"
|
|
3430
|
+
phone: "Phone",
|
|
3431
|
+
freeItems: "Free Items"
|
|
3431
3432
|
};
|
|
3432
3433
|
var checkoutForm_en = {
|
|
3433
3434
|
messages: messages$14,
|
|
@@ -4368,7 +4369,8 @@ var labels$H = {
|
|
|
4368
4369
|
removeCoupon: "RETIRER",
|
|
4369
4370
|
firstName: "Prénom",
|
|
4370
4371
|
lastName: "Nom de famille",
|
|
4371
|
-
phone: "Téléphoner"
|
|
4372
|
+
phone: "Téléphoner",
|
|
4373
|
+
freeItems: "Articles gratuits"
|
|
4372
4374
|
};
|
|
4373
4375
|
var checkoutForm_fr = {
|
|
4374
4376
|
messages: messages$M,
|
|
@@ -5195,7 +5197,8 @@ var labels$s = {
|
|
|
5195
5197
|
removeCoupon: "제거",
|
|
5196
5198
|
firstName: "이름",
|
|
5197
5199
|
lastName: "성",
|
|
5198
|
-
phone: "핸드폰"
|
|
5200
|
+
phone: "핸드폰",
|
|
5201
|
+
freeItems: "무료 아이템"
|
|
5199
5202
|
};
|
|
5200
5203
|
var checkoutForm_ko = {
|
|
5201
5204
|
messages: messages$v,
|
|
@@ -6126,7 +6129,8 @@ var labels$d = {
|
|
|
6126
6129
|
removeCoupon: "ELIMINAR",
|
|
6127
6130
|
firstName: "Nombre",
|
|
6128
6131
|
lastName: "Apellido",
|
|
6129
|
-
phone: "Teléfono"
|
|
6132
|
+
phone: "Teléfono",
|
|
6133
|
+
freeItems: "Artículos gratis"
|
|
6130
6134
|
};
|
|
6131
6135
|
var checkoutForm_es = {
|
|
6132
6136
|
messages: messages$e,
|
|
@@ -8677,7 +8681,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
|
|
|
8677
8681
|
if (!Array.isArray(items)) return;
|
|
8678
8682
|
let totalWithoutDividingBy100 = 0;
|
|
8679
8683
|
for (const item of items) {
|
|
8680
|
-
totalWithoutDividingBy100 += parseFloat(item.price ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
|
|
8684
|
+
totalWithoutDividingBy100 += parseFloat(item !== null && item !== void 0 && item.price || (item === null || item === void 0 ? void 0 : item.price) === 0 ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
|
|
8681
8685
|
}
|
|
8682
8686
|
return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
|
|
8683
8687
|
};
|
|
@@ -10843,13 +10847,16 @@ const debounce = (func, waitTime) => {
|
|
|
10843
10847
|
};
|
|
10844
10848
|
};
|
|
10845
10849
|
function getSiteCardProcessor() {
|
|
10846
|
-
var _window$Pelcro$site$r, _window$Pelcro$site$r2;
|
|
10850
|
+
var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3;
|
|
10847
10851
|
if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
|
|
10848
10852
|
return "vantiv";
|
|
10849
10853
|
}
|
|
10850
10854
|
if ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r2 !== void 0 && _window$Pelcro$site$r2.tap_gateway_settings) {
|
|
10851
10855
|
return "tap";
|
|
10852
10856
|
}
|
|
10857
|
+
if ((_window$Pelcro$site$r3 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r3 !== void 0 && _window$Pelcro$site$r3.cybersource_gateway_settings) {
|
|
10858
|
+
return "cybersource";
|
|
10859
|
+
}
|
|
10853
10860
|
return "stripe";
|
|
10854
10861
|
}
|
|
10855
10862
|
|
|
@@ -11710,6 +11717,8 @@ const SET_FIRST_NAME_ERROR = "SET_FIRST_NAME_ERROR";
|
|
|
11710
11717
|
const SET_LAST_NAME_ERROR = "SET_LAST_NAME_ERROR";
|
|
11711
11718
|
const SET_PHONE_ERROR = "SET_PHONE_ERROR";
|
|
11712
11719
|
const SET_TEXT_FIELD = "SET_TEXT_FIELD";
|
|
11720
|
+
const SET_MONTH = "SET_MONTH";
|
|
11721
|
+
const SET_YEAR = "SET_YEAR";
|
|
11713
11722
|
const SET_TOKEN = "SET_TOKEN";
|
|
11714
11723
|
const SET_GIFT_CODE = "SET_GIFT_CODE";
|
|
11715
11724
|
const RESET_LOGIN_FORM = "RESET_LOGIN_FORM";
|
|
@@ -15469,7 +15478,7 @@ var _isPaymentGatewayInvalid = /*#__PURE__*/new WeakMap();
|
|
|
15469
15478
|
var _generateUserError = /*#__PURE__*/new WeakMap();
|
|
15470
15479
|
class Payment {
|
|
15471
15480
|
/**
|
|
15472
|
-
* @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway)} paymentGateway
|
|
15481
|
+
* @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway|CybersourceGateway)} paymentGateway
|
|
15473
15482
|
*/
|
|
15474
15483
|
constructor(paymentGateway) {
|
|
15475
15484
|
_defineProperty$3(this, "execute", (options, callback) => {
|
|
@@ -15488,7 +15497,7 @@ class Payment {
|
|
|
15488
15497
|
_classPrivateFieldInitSpec$1(this, _isPaymentGatewayInvalid, {
|
|
15489
15498
|
writable: true,
|
|
15490
15499
|
value: gateway => {
|
|
15491
|
-
return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway);
|
|
15500
|
+
return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway || gateway instanceof CybersourceGateway);
|
|
15492
15501
|
}
|
|
15493
15502
|
});
|
|
15494
15503
|
_classPrivateFieldInitSpec$1(this, _generateUserError, {
|
|
@@ -15542,7 +15551,8 @@ const PAYMENT_GATEWAYS_ENUM = {
|
|
|
15542
15551
|
stripe: "stripe",
|
|
15543
15552
|
paypal: "braintree",
|
|
15544
15553
|
vantiv: "vantiv",
|
|
15545
|
-
tap: "tap"
|
|
15554
|
+
tap: "tap",
|
|
15555
|
+
cybersource: "cybersource"
|
|
15546
15556
|
};
|
|
15547
15557
|
|
|
15548
15558
|
/**
|
|
@@ -16264,6 +16274,222 @@ class TapGateway {
|
|
|
16264
16274
|
}
|
|
16265
16275
|
}
|
|
16266
16276
|
|
|
16277
|
+
/**
|
|
16278
|
+
* Cybersource gateway strategy
|
|
16279
|
+
*/
|
|
16280
|
+
var _paymentGateway5 = /*#__PURE__*/new WeakMap();
|
|
16281
|
+
var _createSubscription5 = /*#__PURE__*/new WeakMap();
|
|
16282
|
+
var _renewSubscription4 = /*#__PURE__*/new WeakMap();
|
|
16283
|
+
var _createGiftedSubscription5 = /*#__PURE__*/new WeakMap();
|
|
16284
|
+
var _renewGiftedSubscription4 = /*#__PURE__*/new WeakMap();
|
|
16285
|
+
var _purchaseEcommerceOrder4 = /*#__PURE__*/new WeakMap();
|
|
16286
|
+
var _payInvoice5 = /*#__PURE__*/new WeakMap();
|
|
16287
|
+
class CybersourceGateway {
|
|
16288
|
+
constructor() {
|
|
16289
|
+
_classPrivateFieldInitSpec$1(this, _paymentGateway5, {
|
|
16290
|
+
writable: true,
|
|
16291
|
+
value: PAYMENT_GATEWAYS_ENUM["cybersource"]
|
|
16292
|
+
});
|
|
16293
|
+
_defineProperty$3(this, "execute", (options, callback) => {
|
|
16294
|
+
const types = PAYMENT_TYPES;
|
|
16295
|
+
switch (options.type) {
|
|
16296
|
+
case types.CREATE_SUBSCRIPTION:
|
|
16297
|
+
return _classPrivateFieldGet(this, _createSubscription5).call(this, options, callback);
|
|
16298
|
+
case types.RENEW_SUBSCRIPTION:
|
|
16299
|
+
return _classPrivateFieldGet(this, _renewSubscription4).call(this, options, callback);
|
|
16300
|
+
case types.CREATE_GIFTED_SUBSCRIPTION:
|
|
16301
|
+
return _classPrivateFieldGet(this, _createGiftedSubscription5).call(this, options, callback);
|
|
16302
|
+
case types.RENEW_GIFTED_SUBSCRIPTION:
|
|
16303
|
+
return _classPrivateFieldGet(this, _renewGiftedSubscription4).call(this, options, callback);
|
|
16304
|
+
case types.PURCHASE_ECOMMERCE_ORDER:
|
|
16305
|
+
return _classPrivateFieldGet(this, _purchaseEcommerceOrder4).call(this, options, callback);
|
|
16306
|
+
case types.PAY_INVOICE:
|
|
16307
|
+
return _classPrivateFieldGet(this, _payInvoice5).call(this, options, callback);
|
|
16308
|
+
default:
|
|
16309
|
+
console.error("Unsupported payment method: cybersource Gateway");
|
|
16310
|
+
}
|
|
16311
|
+
});
|
|
16312
|
+
_classPrivateFieldInitSpec$1(this, _createSubscription5, {
|
|
16313
|
+
writable: true,
|
|
16314
|
+
value: (options, callback) => {
|
|
16315
|
+
const {
|
|
16316
|
+
token,
|
|
16317
|
+
plan,
|
|
16318
|
+
couponCode,
|
|
16319
|
+
product,
|
|
16320
|
+
quantity = 1,
|
|
16321
|
+
addressId,
|
|
16322
|
+
isExistingSource
|
|
16323
|
+
} = options;
|
|
16324
|
+
const params = isExistingSource ? {
|
|
16325
|
+
source_id: token
|
|
16326
|
+
} : {
|
|
16327
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16328
|
+
gateway_token: token
|
|
16329
|
+
};
|
|
16330
|
+
window.Pelcro.subscription.create({
|
|
16331
|
+
quantity,
|
|
16332
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16333
|
+
plan_id: plan.id,
|
|
16334
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
16335
|
+
coupon_code: couponCode,
|
|
16336
|
+
address_id: product.address_required ? addressId : null,
|
|
16337
|
+
...params
|
|
16338
|
+
}, (err, res) => {
|
|
16339
|
+
callback(err, res);
|
|
16340
|
+
});
|
|
16341
|
+
}
|
|
16342
|
+
});
|
|
16343
|
+
_classPrivateFieldInitSpec$1(this, _renewSubscription4, {
|
|
16344
|
+
writable: true,
|
|
16345
|
+
value: (options, callback) => {
|
|
16346
|
+
const {
|
|
16347
|
+
subscriptionIdToRenew,
|
|
16348
|
+
token,
|
|
16349
|
+
plan,
|
|
16350
|
+
couponCode,
|
|
16351
|
+
product,
|
|
16352
|
+
addressId,
|
|
16353
|
+
isExistingSource
|
|
16354
|
+
} = options;
|
|
16355
|
+
const params = isExistingSource ? {
|
|
16356
|
+
source_id: token
|
|
16357
|
+
} : {
|
|
16358
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16359
|
+
gateway_token: token
|
|
16360
|
+
};
|
|
16361
|
+
window.Pelcro.subscription.renew({
|
|
16362
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16363
|
+
plan_id: plan.id,
|
|
16364
|
+
coupon_code: couponCode,
|
|
16365
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
16366
|
+
subscription_id: subscriptionIdToRenew,
|
|
16367
|
+
address_id: product.address_required ? addressId : null,
|
|
16368
|
+
...params
|
|
16369
|
+
}, (err, res) => {
|
|
16370
|
+
callback(err, res);
|
|
16371
|
+
});
|
|
16372
|
+
}
|
|
16373
|
+
});
|
|
16374
|
+
_classPrivateFieldInitSpec$1(this, _createGiftedSubscription5, {
|
|
16375
|
+
writable: true,
|
|
16376
|
+
value: (options, callback) => {
|
|
16377
|
+
const {
|
|
16378
|
+
token,
|
|
16379
|
+
plan,
|
|
16380
|
+
couponCode,
|
|
16381
|
+
product,
|
|
16382
|
+
giftRecipient,
|
|
16383
|
+
quantity = 1,
|
|
16384
|
+
addressId,
|
|
16385
|
+
isExistingSource
|
|
16386
|
+
} = options;
|
|
16387
|
+
const params = isExistingSource ? {
|
|
16388
|
+
source_id: token
|
|
16389
|
+
} : {
|
|
16390
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16391
|
+
gateway_token: token
|
|
16392
|
+
};
|
|
16393
|
+
window.Pelcro.subscription.create({
|
|
16394
|
+
quantity,
|
|
16395
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16396
|
+
plan_id: plan.id,
|
|
16397
|
+
coupon_code: couponCode,
|
|
16398
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
16399
|
+
gift_recipient_email: giftRecipient.email,
|
|
16400
|
+
gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
|
|
16401
|
+
gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
|
|
16402
|
+
gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
|
|
16403
|
+
gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
|
|
16404
|
+
address_id: product.address_required ? addressId : null,
|
|
16405
|
+
...params
|
|
16406
|
+
}, (err, res) => {
|
|
16407
|
+
callback(err, res);
|
|
16408
|
+
});
|
|
16409
|
+
}
|
|
16410
|
+
});
|
|
16411
|
+
_classPrivateFieldInitSpec$1(this, _renewGiftedSubscription4, {
|
|
16412
|
+
writable: true,
|
|
16413
|
+
value: (options, callback) => {
|
|
16414
|
+
const {
|
|
16415
|
+
subscriptionIdToRenew,
|
|
16416
|
+
token,
|
|
16417
|
+
product,
|
|
16418
|
+
plan,
|
|
16419
|
+
couponCode,
|
|
16420
|
+
addressId,
|
|
16421
|
+
isExistingSource
|
|
16422
|
+
} = options;
|
|
16423
|
+
const params = isExistingSource ? {
|
|
16424
|
+
source_id: token
|
|
16425
|
+
} : {
|
|
16426
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16427
|
+
gateway_token: token
|
|
16428
|
+
};
|
|
16429
|
+
window.Pelcro.subscription.renewGift({
|
|
16430
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16431
|
+
plan_id: plan.id,
|
|
16432
|
+
coupon_code: couponCode,
|
|
16433
|
+
subscription_id: subscriptionIdToRenew,
|
|
16434
|
+
address_id: product.address_required ? addressId : null,
|
|
16435
|
+
...params
|
|
16436
|
+
}, (err, res) => {
|
|
16437
|
+
callback(err, res);
|
|
16438
|
+
});
|
|
16439
|
+
}
|
|
16440
|
+
});
|
|
16441
|
+
_classPrivateFieldInitSpec$1(this, _purchaseEcommerceOrder4, {
|
|
16442
|
+
writable: true,
|
|
16443
|
+
value: (options, callback) => {
|
|
16444
|
+
const {
|
|
16445
|
+
token,
|
|
16446
|
+
items,
|
|
16447
|
+
couponCode,
|
|
16448
|
+
addressId,
|
|
16449
|
+
isExistingSource
|
|
16450
|
+
} = options;
|
|
16451
|
+
const params = isExistingSource ? {
|
|
16452
|
+
source_id: token
|
|
16453
|
+
} : {
|
|
16454
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16455
|
+
gateway_token: token
|
|
16456
|
+
};
|
|
16457
|
+
window.Pelcro.ecommerce.order.create({
|
|
16458
|
+
items,
|
|
16459
|
+
coupon_code: couponCode,
|
|
16460
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
16461
|
+
...params,
|
|
16462
|
+
...(addressId && {
|
|
16463
|
+
address_id: addressId
|
|
16464
|
+
})
|
|
16465
|
+
}, (err, res) => {
|
|
16466
|
+
callback(err, res);
|
|
16467
|
+
});
|
|
16468
|
+
}
|
|
16469
|
+
});
|
|
16470
|
+
_classPrivateFieldInitSpec$1(this, _payInvoice5, {
|
|
16471
|
+
writable: true,
|
|
16472
|
+
value: (options, callback) => {
|
|
16473
|
+
const {
|
|
16474
|
+
token,
|
|
16475
|
+
invoiceId
|
|
16476
|
+
} = options;
|
|
16477
|
+
const params = options.isExistingSource ? {
|
|
16478
|
+
source_id: token,
|
|
16479
|
+
invoice_id: invoiceId
|
|
16480
|
+
} : {
|
|
16481
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
|
|
16482
|
+
gateway_token: token,
|
|
16483
|
+
invoice_id: invoiceId
|
|
16484
|
+
};
|
|
16485
|
+
window.Pelcro.invoice.pay(params, (err, res) => {
|
|
16486
|
+
callback(err, res);
|
|
16487
|
+
});
|
|
16488
|
+
}
|
|
16489
|
+
});
|
|
16490
|
+
}
|
|
16491
|
+
}
|
|
16492
|
+
|
|
16267
16493
|
/**
|
|
16268
16494
|
* @typedef {Object} PaymentStateType
|
|
16269
16495
|
* @property {boolean} disableSubmit
|
|
@@ -16303,6 +16529,8 @@ const initialState$k = {
|
|
|
16303
16529
|
firstNameError: null,
|
|
16304
16530
|
lastNameError: null,
|
|
16305
16531
|
phoneError: null,
|
|
16532
|
+
month: "",
|
|
16533
|
+
year: "",
|
|
16306
16534
|
alert: {
|
|
16307
16535
|
type: "error",
|
|
16308
16536
|
content: ""
|
|
@@ -16368,37 +16596,38 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16368
16596
|
updateTotalAmountWithTax();
|
|
16369
16597
|
}, []);
|
|
16370
16598
|
|
|
16371
|
-
/*====== Start
|
|
16372
|
-
const
|
|
16373
|
-
var
|
|
16599
|
+
/*====== Start Cybersource integration ========*/
|
|
16600
|
+
const cybersourceErrorHandle = err => {
|
|
16601
|
+
var _err$details, _err$details$response;
|
|
16602
|
+
const errorMessages = [];
|
|
16603
|
+
|
|
16604
|
+
// enumerable error (ex: validation errors)
|
|
16605
|
+
Object.values(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$response.details).forEach(_ref2 => {
|
|
16606
|
+
let {
|
|
16607
|
+
message
|
|
16608
|
+
} = _ref2;
|
|
16609
|
+
errorMessages.push(message);
|
|
16610
|
+
});
|
|
16611
|
+
|
|
16612
|
+
// convert to multiline string
|
|
16613
|
+
return errorMessages.join("\n");
|
|
16614
|
+
};
|
|
16615
|
+
const submitUsingCybersource = (state, dispatch) => {
|
|
16616
|
+
var _cybersourceInstanceR;
|
|
16374
16617
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16375
16618
|
if (isUsingExistingPaymentMethod) {
|
|
16376
|
-
// no need to create a new source using
|
|
16377
|
-
return
|
|
16619
|
+
// no need to create a new source using cybersrce
|
|
16620
|
+
return handleCybersourcePayment(null, state);
|
|
16378
16621
|
}
|
|
16379
|
-
if (!
|
|
16380
|
-
return console.error("
|
|
16622
|
+
if (!cybersourceInstanceRef.current) {
|
|
16623
|
+
return console.error("Cybersource sdk script wasn't loaded, you need to load Cybersource sdk before rendering the Cybersource payment flow");
|
|
16381
16624
|
}
|
|
16382
|
-
|
|
16383
|
-
|
|
16384
|
-
|
|
16385
|
-
}
|
|
16386
|
-
const isQuickPurchase = !Array.isArray(order);
|
|
16387
|
-
if (isQuickPurchase) {
|
|
16388
|
-
return order.price * order.quantity;
|
|
16389
|
-
}
|
|
16390
|
-
if (order.length === 0) {
|
|
16391
|
-
return null;
|
|
16392
|
-
}
|
|
16393
|
-
return order.reduce((total, item) => {
|
|
16394
|
-
return total + item.price * item.quantity;
|
|
16395
|
-
}, 0);
|
|
16625
|
+
let options = {
|
|
16626
|
+
cardExpirationMonth: state.month,
|
|
16627
|
+
cardExpirationYear: state.year
|
|
16396
16628
|
};
|
|
16397
|
-
|
|
16398
|
-
|
|
16399
|
-
if (result.error) {
|
|
16400
|
-
// Inform the user if there was an error
|
|
16401
|
-
onFailure(result.error);
|
|
16629
|
+
(_cybersourceInstanceR = cybersourceInstanceRef.current) === null || _cybersourceInstanceR === void 0 ? void 0 : _cybersourceInstanceR.createToken(options, function (err, response) {
|
|
16630
|
+
if (err) {
|
|
16402
16631
|
dispatch({
|
|
16403
16632
|
type: DISABLE_SUBMIT,
|
|
16404
16633
|
payload: false
|
|
@@ -16411,36 +16640,276 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16411
16640
|
type: SHOW_ALERT,
|
|
16412
16641
|
payload: {
|
|
16413
16642
|
type: "error",
|
|
16414
|
-
content:
|
|
16643
|
+
content: cybersourceErrorHandle(err)
|
|
16415
16644
|
}
|
|
16416
16645
|
});
|
|
16417
|
-
}
|
|
16418
|
-
|
|
16419
|
-
|
|
16420
|
-
|
|
16421
|
-
|
|
16422
|
-
|
|
16423
|
-
|
|
16424
|
-
|
|
16425
|
-
|
|
16426
|
-
|
|
16427
|
-
|
|
16428
|
-
|
|
16429
|
-
|
|
16430
|
-
|
|
16431
|
-
|
|
16432
|
-
|
|
16433
|
-
|
|
16434
|
-
|
|
16435
|
-
|
|
16436
|
-
|
|
16437
|
-
|
|
16438
|
-
|
|
16439
|
-
|
|
16440
|
-
|
|
16441
|
-
|
|
16442
|
-
|
|
16443
|
-
|
|
16646
|
+
}
|
|
16647
|
+
handleCybersourcePayment(response.token, state);
|
|
16648
|
+
});
|
|
16649
|
+
};
|
|
16650
|
+
function handleCybersourcePayment(paymentRequest, state) {
|
|
16651
|
+
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16652
|
+
if (type === "createPayment") {
|
|
16653
|
+
handleCybersourceSubscription();
|
|
16654
|
+
} else if (type === "orderCreate") {
|
|
16655
|
+
purchase(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
|
|
16656
|
+
} else if (type === "invoicePayment") {
|
|
16657
|
+
payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
|
|
16658
|
+
} else if (type === "updatePaymentSource") {
|
|
16659
|
+
createNewCybersourceCard();
|
|
16660
|
+
}
|
|
16661
|
+
function createNewCybersourceCard() {
|
|
16662
|
+
window.Pelcro.source.create({
|
|
16663
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16664
|
+
token: paymentRequest,
|
|
16665
|
+
gateway: "cybersource"
|
|
16666
|
+
}, (err, res) => {
|
|
16667
|
+
dispatch({
|
|
16668
|
+
type: DISABLE_SUBMIT,
|
|
16669
|
+
payload: false
|
|
16670
|
+
});
|
|
16671
|
+
dispatch({
|
|
16672
|
+
type: LOADING,
|
|
16673
|
+
payload: false
|
|
16674
|
+
});
|
|
16675
|
+
toggleAuthenticationSuccessPendingView(false);
|
|
16676
|
+
if (err) {
|
|
16677
|
+
onFailure(err);
|
|
16678
|
+
return dispatch({
|
|
16679
|
+
type: SHOW_ALERT,
|
|
16680
|
+
payload: {
|
|
16681
|
+
type: "error",
|
|
16682
|
+
content: getErrorMessages(err)
|
|
16683
|
+
}
|
|
16684
|
+
});
|
|
16685
|
+
}
|
|
16686
|
+
dispatch({
|
|
16687
|
+
type: SHOW_ALERT,
|
|
16688
|
+
payload: {
|
|
16689
|
+
type: "success",
|
|
16690
|
+
content: t("messages.sourceUpdated")
|
|
16691
|
+
}
|
|
16692
|
+
});
|
|
16693
|
+
onSuccess(res);
|
|
16694
|
+
} //
|
|
16695
|
+
);
|
|
16696
|
+
}
|
|
16697
|
+
|
|
16698
|
+
function handleCybersourceSubscription() {
|
|
16699
|
+
const payment = new Payment(new CybersourceGateway());
|
|
16700
|
+
const createSubscription = !isGift && !subscriptionIdToRenew;
|
|
16701
|
+
const renewSubscription = !isGift && subscriptionIdToRenew;
|
|
16702
|
+
const giftSubscriprition = isGift && !subscriptionIdToRenew;
|
|
16703
|
+
const renewGift = isRenewingGift;
|
|
16704
|
+
const {
|
|
16705
|
+
couponCode
|
|
16706
|
+
} = state;
|
|
16707
|
+
if (renewGift) {
|
|
16708
|
+
return payment.execute({
|
|
16709
|
+
type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
|
|
16710
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
|
|
16711
|
+
plan,
|
|
16712
|
+
couponCode,
|
|
16713
|
+
product,
|
|
16714
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
16715
|
+
subscriptionIdToRenew,
|
|
16716
|
+
addressId: selectedAddressId
|
|
16717
|
+
}, (err, res) => {
|
|
16718
|
+
if (err) {
|
|
16719
|
+
return handlePaymentError(err);
|
|
16720
|
+
}
|
|
16721
|
+
onSuccess(res);
|
|
16722
|
+
});
|
|
16723
|
+
} else if (giftSubscriprition) {
|
|
16724
|
+
return payment.execute({
|
|
16725
|
+
type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
|
|
16726
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
|
|
16727
|
+
quantity: plan.quantity,
|
|
16728
|
+
plan,
|
|
16729
|
+
couponCode,
|
|
16730
|
+
product,
|
|
16731
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
16732
|
+
giftRecipient,
|
|
16733
|
+
addressId: selectedAddressId
|
|
16734
|
+
}, (err, res) => {
|
|
16735
|
+
if (err) {
|
|
16736
|
+
return handlePaymentError(err);
|
|
16737
|
+
}
|
|
16738
|
+
onSuccess(res);
|
|
16739
|
+
});
|
|
16740
|
+
} else if (renewSubscription) {
|
|
16741
|
+
return payment.execute({
|
|
16742
|
+
type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
|
|
16743
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
|
|
16744
|
+
quantity: plan.quantity,
|
|
16745
|
+
plan,
|
|
16746
|
+
couponCode,
|
|
16747
|
+
product,
|
|
16748
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
16749
|
+
subscriptionIdToRenew,
|
|
16750
|
+
addressId: selectedAddressId
|
|
16751
|
+
}, (err, res) => {
|
|
16752
|
+
if (err) {
|
|
16753
|
+
return handlePaymentError(err);
|
|
16754
|
+
}
|
|
16755
|
+
onSuccess(res);
|
|
16756
|
+
});
|
|
16757
|
+
} else if (createSubscription) {
|
|
16758
|
+
return payment.execute({
|
|
16759
|
+
type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
|
|
16760
|
+
token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
|
|
16761
|
+
quantity: plan.quantity,
|
|
16762
|
+
plan,
|
|
16763
|
+
couponCode,
|
|
16764
|
+
product,
|
|
16765
|
+
isExistingSource: isUsingExistingPaymentMethod,
|
|
16766
|
+
addressId: selectedAddressId
|
|
16767
|
+
}, (err, res) => {
|
|
16768
|
+
if (err) {
|
|
16769
|
+
return handlePaymentError(err);
|
|
16770
|
+
}
|
|
16771
|
+
onSuccess(res);
|
|
16772
|
+
});
|
|
16773
|
+
}
|
|
16774
|
+
}
|
|
16775
|
+
}
|
|
16776
|
+
const tokenizeCard = (error, microformInstance) => {
|
|
16777
|
+
if (error) {
|
|
16778
|
+
return;
|
|
16779
|
+
}
|
|
16780
|
+
cybersourceInstanceRef.current = microformInstance;
|
|
16781
|
+
};
|
|
16782
|
+
const initCybersourceScript = () => {
|
|
16783
|
+
// jwk api call
|
|
16784
|
+
window.Pelcro.payment.getJWK({
|
|
16785
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16786
|
+
site_id: window.Pelcro.siteid
|
|
16787
|
+
}, (err, res) => {
|
|
16788
|
+
if (err) {
|
|
16789
|
+
onFailure(err);
|
|
16790
|
+
dispatch({
|
|
16791
|
+
type: DISABLE_SUBMIT,
|
|
16792
|
+
payload: false
|
|
16793
|
+
});
|
|
16794
|
+
dispatch({
|
|
16795
|
+
type: LOADING,
|
|
16796
|
+
payload: false
|
|
16797
|
+
});
|
|
16798
|
+
return dispatch({
|
|
16799
|
+
type: SHOW_ALERT,
|
|
16800
|
+
payload: {
|
|
16801
|
+
type: "error",
|
|
16802
|
+
content: getErrorMessages(err)
|
|
16803
|
+
}
|
|
16804
|
+
});
|
|
16805
|
+
}
|
|
16806
|
+
const {
|
|
16807
|
+
key: jwk
|
|
16808
|
+
} = res;
|
|
16809
|
+
// SETUP MICROFORM
|
|
16810
|
+
FLEX.microform({
|
|
16811
|
+
keyId: jwk.kid,
|
|
16812
|
+
keystore: jwk,
|
|
16813
|
+
container: "#cybersourceCardNumber",
|
|
16814
|
+
placeholder: "Card Number",
|
|
16815
|
+
styles: {
|
|
16816
|
+
input: {
|
|
16817
|
+
"font-size": "14px",
|
|
16818
|
+
"font-family": "helvetica, tahoma, calibri, sans-serif",
|
|
16819
|
+
color: "#555"
|
|
16820
|
+
},
|
|
16821
|
+
":focus": {
|
|
16822
|
+
color: "blue"
|
|
16823
|
+
},
|
|
16824
|
+
":disabled": {
|
|
16825
|
+
cursor: "not-allowed"
|
|
16826
|
+
},
|
|
16827
|
+
valid: {
|
|
16828
|
+
color: "#3c763d"
|
|
16829
|
+
},
|
|
16830
|
+
invalid: {
|
|
16831
|
+
color: "#a94442"
|
|
16832
|
+
}
|
|
16833
|
+
}
|
|
16834
|
+
}, tokenizeCard);
|
|
16835
|
+
});
|
|
16836
|
+
};
|
|
16837
|
+
|
|
16838
|
+
/*====== End Cybersource integration ========*/
|
|
16839
|
+
|
|
16840
|
+
/*====== Start Tap integration ========*/
|
|
16841
|
+
const submitUsingTap = state => {
|
|
16842
|
+
var _ref3, _ref4, _ref5, _state$updatedPrice;
|
|
16843
|
+
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16844
|
+
if (isUsingExistingPaymentMethod) {
|
|
16845
|
+
// no need to create a new source using tap
|
|
16846
|
+
return handleTapPayment(null, state);
|
|
16847
|
+
}
|
|
16848
|
+
if (!tapInstanceRef.current) {
|
|
16849
|
+
return console.error("Tap sdk script wasn't loaded, you need to load tap sdk before rendering the tap payment flow");
|
|
16850
|
+
}
|
|
16851
|
+
const getOrderItemsTotal = () => {
|
|
16852
|
+
if (!order) {
|
|
16853
|
+
return null;
|
|
16854
|
+
}
|
|
16855
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
16856
|
+
if (isQuickPurchase) {
|
|
16857
|
+
return order.price * order.quantity;
|
|
16858
|
+
}
|
|
16859
|
+
if (order.length === 0) {
|
|
16860
|
+
return null;
|
|
16861
|
+
}
|
|
16862
|
+
return order.reduce((total, item) => {
|
|
16863
|
+
return total + item.price * item.quantity;
|
|
16864
|
+
}, 0);
|
|
16865
|
+
};
|
|
16866
|
+
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;
|
|
16867
|
+
tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
|
|
16868
|
+
if (result.error) {
|
|
16869
|
+
// Inform the user if there was an error
|
|
16870
|
+
onFailure(result.error);
|
|
16871
|
+
dispatch({
|
|
16872
|
+
type: DISABLE_SUBMIT,
|
|
16873
|
+
payload: false
|
|
16874
|
+
});
|
|
16875
|
+
dispatch({
|
|
16876
|
+
type: LOADING,
|
|
16877
|
+
payload: false
|
|
16878
|
+
});
|
|
16879
|
+
return dispatch({
|
|
16880
|
+
type: SHOW_ALERT,
|
|
16881
|
+
payload: {
|
|
16882
|
+
type: "error",
|
|
16883
|
+
content: getErrorMessages(result.error)
|
|
16884
|
+
}
|
|
16885
|
+
});
|
|
16886
|
+
} else {
|
|
16887
|
+
window.Pelcro.payment.verify({
|
|
16888
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
16889
|
+
first_name: window.Pelcro.user.read().first_name || state.firstName,
|
|
16890
|
+
last_name: window.Pelcro.user.read().last_name || state.lastName,
|
|
16891
|
+
phone: window.Pelcro.user.read().phone || state.phone,
|
|
16892
|
+
site_id: window.Pelcro.siteid,
|
|
16893
|
+
amount: totalAmount,
|
|
16894
|
+
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,
|
|
16895
|
+
tap_token: result.id,
|
|
16896
|
+
funding: result.card.funding,
|
|
16897
|
+
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}`
|
|
16898
|
+
}, (err, res) => {
|
|
16899
|
+
if (err) {
|
|
16900
|
+
// Inform the user if there was an error
|
|
16901
|
+
onFailure(err);
|
|
16902
|
+
dispatch({
|
|
16903
|
+
type: DISABLE_SUBMIT,
|
|
16904
|
+
payload: false
|
|
16905
|
+
});
|
|
16906
|
+
dispatch({
|
|
16907
|
+
type: LOADING,
|
|
16908
|
+
payload: false
|
|
16909
|
+
});
|
|
16910
|
+
return dispatch({
|
|
16911
|
+
type: SHOW_ALERT,
|
|
16912
|
+
payload: {
|
|
16444
16913
|
type: "error",
|
|
16445
16914
|
content: getErrorMessages(err)
|
|
16446
16915
|
}
|
|
@@ -16811,8 +17280,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16811
17280
|
const vantivInstanceRef = React__default.useRef(null);
|
|
16812
17281
|
const tapInstanceRef = React__default.useRef(null);
|
|
16813
17282
|
const tapInstanceCard = React__default.useRef(null);
|
|
17283
|
+
const cybersourceInstanceRef = React__default.useRef(null);
|
|
16814
17284
|
useEffect(() => {
|
|
16815
|
-
if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
|
|
17285
|
+
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
16816
17286
|
if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
|
|
16817
17287
|
var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
|
|
16818
17288
|
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;
|
|
@@ -16848,7 +17318,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16848
17318
|
}, [vantivPaymentRequest]);
|
|
16849
17319
|
useEffect(() => {
|
|
16850
17320
|
whenUserReady(() => {
|
|
16851
|
-
if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
|
|
17321
|
+
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
16852
17322
|
if (cardProcessor === "tap" && !window.Tapjsli) {
|
|
16853
17323
|
window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
|
|
16854
17324
|
window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
|
|
@@ -16859,10 +17329,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16859
17329
|
if (cardProcessor === "tap" && !selectedPaymentMethodId && window.Tapjsli) {
|
|
16860
17330
|
initTapScript();
|
|
16861
17331
|
}
|
|
17332
|
+
if (cardProcessor === "cybersource" && !selectedPaymentMethodId && !window.FLEX) {
|
|
17333
|
+
window.Pelcro.helpers.loadSDK("https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js", "cybersource-cdn");
|
|
17334
|
+
document.querySelector('script[src="https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js"]').addEventListener("load", () => {
|
|
17335
|
+
initCybersourceScript();
|
|
17336
|
+
});
|
|
17337
|
+
}
|
|
17338
|
+
if (cardProcessor === "cybersource" && !selectedPaymentMethodId && window.FLEX) {
|
|
17339
|
+
initCybersourceScript();
|
|
17340
|
+
}
|
|
16862
17341
|
});
|
|
16863
17342
|
}, [selectedPaymentMethodId]);
|
|
16864
17343
|
const initPaymentRequest = (state, dispatch) => {
|
|
16865
|
-
if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
|
|
17344
|
+
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
16866
17345
|
try {
|
|
16867
17346
|
const paymentRequest = stripe.paymentRequest({
|
|
16868
17347
|
country: window.Pelcro.user.location.countryCode || "US",
|
|
@@ -16874,13 +17353,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16874
17353
|
});
|
|
16875
17354
|
|
|
16876
17355
|
// When Google pay / Apple pay source created
|
|
16877
|
-
paymentRequest.on("source",
|
|
17356
|
+
paymentRequest.on("source", _ref6 => {
|
|
16878
17357
|
var _source$card;
|
|
16879
17358
|
let {
|
|
16880
17359
|
complete,
|
|
16881
17360
|
source,
|
|
16882
17361
|
...data
|
|
16883
|
-
} =
|
|
17362
|
+
} = _ref6;
|
|
16884
17363
|
dispatch({
|
|
16885
17364
|
type: DISABLE_COUPON_BUTTON,
|
|
16886
17365
|
payload: true
|
|
@@ -16895,11 +17374,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16895
17374
|
});
|
|
16896
17375
|
complete("success");
|
|
16897
17376
|
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") {
|
|
16898
|
-
return generate3DSecureSource(source).then(
|
|
17377
|
+
return generate3DSecureSource(source).then(_ref7 => {
|
|
16899
17378
|
let {
|
|
16900
17379
|
source,
|
|
16901
17380
|
error
|
|
16902
|
-
} =
|
|
17381
|
+
} = _ref7;
|
|
16903
17382
|
if (error) {
|
|
16904
17383
|
return handlePaymentError(error);
|
|
16905
17384
|
}
|
|
@@ -16931,7 +17410,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16931
17410
|
*/
|
|
16932
17411
|
const updateTotalAmountWithTax = () => {
|
|
16933
17412
|
var _window$Pelcro$site$r4;
|
|
16934
|
-
if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
|
|
17413
|
+
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
16935
17414
|
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;
|
|
16936
17415
|
if (taxesEnabled && type === "createPayment") {
|
|
16937
17416
|
dispatch({
|
|
@@ -17428,16 +17907,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17428
17907
|
items: mappedOrderItems,
|
|
17429
17908
|
addressId: selectedAddressId,
|
|
17430
17909
|
couponCode
|
|
17431
|
-
}, (err,
|
|
17432
|
-
|
|
17433
|
-
type: DISABLE_SUBMIT,
|
|
17434
|
-
payload: false
|
|
17435
|
-
});
|
|
17436
|
-
dispatch({
|
|
17437
|
-
type: LOADING,
|
|
17438
|
-
payload: false
|
|
17439
|
-
});
|
|
17910
|
+
}, (err, orderResponse) => {
|
|
17911
|
+
var _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$;
|
|
17440
17912
|
if (err) {
|
|
17913
|
+
toggleAuthenticationSuccessPendingView(false);
|
|
17914
|
+
dispatch({
|
|
17915
|
+
type: DISABLE_SUBMIT,
|
|
17916
|
+
payload: false
|
|
17917
|
+
});
|
|
17918
|
+
dispatch({
|
|
17919
|
+
type: LOADING,
|
|
17920
|
+
payload: false
|
|
17921
|
+
});
|
|
17441
17922
|
onFailure(err);
|
|
17442
17923
|
return dispatch({
|
|
17443
17924
|
type: SHOW_ALERT,
|
|
@@ -17457,7 +17938,30 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17457
17938
|
cartItems: []
|
|
17458
17939
|
});
|
|
17459
17940
|
}
|
|
17460
|
-
|
|
17941
|
+
window.Pelcro.user.refresh({
|
|
17942
|
+
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
|
|
17943
|
+
}, (err, res) => {
|
|
17944
|
+
dispatch({
|
|
17945
|
+
type: DISABLE_SUBMIT,
|
|
17946
|
+
payload: false
|
|
17947
|
+
});
|
|
17948
|
+
dispatch({
|
|
17949
|
+
type: LOADING,
|
|
17950
|
+
payload: false
|
|
17951
|
+
});
|
|
17952
|
+
toggleAuthenticationSuccessPendingView(false);
|
|
17953
|
+
if (err) {
|
|
17954
|
+
onFailure(err);
|
|
17955
|
+
return dispatch({
|
|
17956
|
+
type: SHOW_ALERT,
|
|
17957
|
+
payload: {
|
|
17958
|
+
type: "error",
|
|
17959
|
+
content: getErrorMessages(err)
|
|
17960
|
+
}
|
|
17961
|
+
});
|
|
17962
|
+
}
|
|
17963
|
+
onSuccess(orderResponse);
|
|
17964
|
+
});
|
|
17461
17965
|
});
|
|
17462
17966
|
};
|
|
17463
17967
|
const payInvoice = (gatewayService, gatewayToken, dispatch) => {
|
|
@@ -17474,12 +17978,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17474
17978
|
const updatePaymentSource = (state, dispatch) => {
|
|
17475
17979
|
return stripe.createSource({
|
|
17476
17980
|
type: "card"
|
|
17477
|
-
}).then(
|
|
17981
|
+
}).then(_ref8 => {
|
|
17478
17982
|
var _source$card2;
|
|
17479
17983
|
let {
|
|
17480
17984
|
source,
|
|
17481
17985
|
error
|
|
17482
|
-
} =
|
|
17986
|
+
} = _ref8;
|
|
17483
17987
|
if (error) {
|
|
17484
17988
|
return handlePaymentError(error);
|
|
17485
17989
|
}
|
|
@@ -17535,14 +18039,37 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17535
18039
|
});
|
|
17536
18040
|
};
|
|
17537
18041
|
const submitPayment = (state, dispatch) => {
|
|
18042
|
+
if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
|
|
18043
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
18044
|
+
const mappedOrderItems = isQuickPurchase ? [{
|
|
18045
|
+
sku_id: order.id,
|
|
18046
|
+
quantity: order.quantity
|
|
18047
|
+
}] : order.map(item => ({
|
|
18048
|
+
sku_id: item.id,
|
|
18049
|
+
quantity: item.quantity
|
|
18050
|
+
}));
|
|
18051
|
+
window.Pelcro.ecommerce.order.create({
|
|
18052
|
+
items: mappedOrderItems,
|
|
18053
|
+
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
18054
|
+
...(selectedAddressId && {
|
|
18055
|
+
address_id: selectedAddressId
|
|
18056
|
+
})
|
|
18057
|
+
}, (err, res) => {
|
|
18058
|
+
if (err) {
|
|
18059
|
+
return handlePaymentError(err);
|
|
18060
|
+
}
|
|
18061
|
+
return onSuccess(res);
|
|
18062
|
+
});
|
|
18063
|
+
return;
|
|
18064
|
+
}
|
|
17538
18065
|
stripe.createSource({
|
|
17539
18066
|
type: "card"
|
|
17540
|
-
}).then(
|
|
17541
|
-
var
|
|
18067
|
+
}).then(_ref9 => {
|
|
18068
|
+
var _ref10, _ref11, _state$updatedPrice2;
|
|
17542
18069
|
let {
|
|
17543
18070
|
source,
|
|
17544
18071
|
error
|
|
17545
|
-
} =
|
|
18072
|
+
} = _ref9;
|
|
17546
18073
|
if (error) {
|
|
17547
18074
|
return handlePaymentError(error);
|
|
17548
18075
|
}
|
|
@@ -17561,7 +18088,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17561
18088
|
return total + item.price * item.quantity;
|
|
17562
18089
|
}, 0);
|
|
17563
18090
|
};
|
|
17564
|
-
(
|
|
18091
|
+
(_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();
|
|
17565
18092
|
return handlePayment(source);
|
|
17566
18093
|
}).catch(error => {
|
|
17567
18094
|
return handlePaymentError(error);
|
|
@@ -17768,12 +18295,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17768
18295
|
disableSubmit: true,
|
|
17769
18296
|
isLoading: true
|
|
17770
18297
|
}, (state, dispatch) => {
|
|
18298
|
+
if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
|
|
18299
|
+
return submitPayment(state);
|
|
18300
|
+
}
|
|
17771
18301
|
if (getSiteCardProcessor() === "vantiv") {
|
|
17772
18302
|
return submitUsingVantiv(state);
|
|
17773
18303
|
}
|
|
17774
18304
|
if (getSiteCardProcessor() === "tap") {
|
|
17775
18305
|
return submitUsingTap(state);
|
|
17776
18306
|
}
|
|
18307
|
+
if (getSiteCardProcessor() === "cybersource") {
|
|
18308
|
+
return submitUsingCybersource(state, dispatch);
|
|
18309
|
+
}
|
|
17777
18310
|
if (selectedPaymentMethodId) {
|
|
17778
18311
|
// pay with selected method (source) if exists already
|
|
17779
18312
|
return handlePayment({
|
|
@@ -17841,6 +18374,16 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17841
18374
|
...state,
|
|
17842
18375
|
percentOff: action.payload
|
|
17843
18376
|
});
|
|
18377
|
+
case SET_MONTH:
|
|
18378
|
+
return lib_7({
|
|
18379
|
+
...state,
|
|
18380
|
+
month: action.payload
|
|
18381
|
+
});
|
|
18382
|
+
case SET_YEAR:
|
|
18383
|
+
return lib_7({
|
|
18384
|
+
...state,
|
|
18385
|
+
year: action.payload
|
|
18386
|
+
});
|
|
17844
18387
|
case SET_FIRST_NAME:
|
|
17845
18388
|
return lib_7({
|
|
17846
18389
|
...state,
|
|
@@ -17896,10 +18439,14 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17896
18439
|
state,
|
|
17897
18440
|
dispatch
|
|
17898
18441
|
}
|
|
17899
|
-
}, children.length ? children.map((child, i) =>
|
|
17900
|
-
|
|
17901
|
-
|
|
17902
|
-
|
|
18442
|
+
}, children.length ? children.map((child, i) => {
|
|
18443
|
+
if (child) {
|
|
18444
|
+
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
18445
|
+
store: store$k,
|
|
18446
|
+
key: i
|
|
18447
|
+
});
|
|
18448
|
+
}
|
|
18449
|
+
}) : /*#__PURE__*/React__default.cloneElement(children, {
|
|
17903
18450
|
store: store$k
|
|
17904
18451
|
})));
|
|
17905
18452
|
};
|
|
@@ -17935,6 +18482,114 @@ const PaymentMethodContainer = props => {
|
|
|
17935
18482
|
return null;
|
|
17936
18483
|
};
|
|
17937
18484
|
|
|
18485
|
+
function Select(_ref) {
|
|
18486
|
+
let {
|
|
18487
|
+
label = "",
|
|
18488
|
+
required,
|
|
18489
|
+
id,
|
|
18490
|
+
errorId,
|
|
18491
|
+
error = "",
|
|
18492
|
+
className = "",
|
|
18493
|
+
labelClassName = "",
|
|
18494
|
+
errorClassName = "",
|
|
18495
|
+
wrapperClassName = "",
|
|
18496
|
+
children,
|
|
18497
|
+
...otherProps
|
|
18498
|
+
} = _ref;
|
|
18499
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
18500
|
+
className: `pelcro-input-wrapper ${wrapperClassName}`
|
|
18501
|
+
}, /*#__PURE__*/React__default.createElement("label", {
|
|
18502
|
+
htmlFor: id,
|
|
18503
|
+
className: `pelcro-input-label ${labelClassName}`
|
|
18504
|
+
}, `${label}${required ? "*" : ""}`), /*#__PURE__*/React__default.createElement("select", Object.assign({
|
|
18505
|
+
id: id,
|
|
18506
|
+
className: `pelcro-input-field ${className} ${error ? "pelcro-input-invalid" : ""}`,
|
|
18507
|
+
"aria-describedby": errorId,
|
|
18508
|
+
"aria-invalid": Boolean(error)
|
|
18509
|
+
}, otherProps), children), error && /*#__PURE__*/React__default.createElement("p", {
|
|
18510
|
+
id: errorId,
|
|
18511
|
+
"aria-live": "assertive",
|
|
18512
|
+
className: `pelcro-input-error ${errorClassName}`
|
|
18513
|
+
}, error));
|
|
18514
|
+
}
|
|
18515
|
+
|
|
18516
|
+
function MonthSelect(_ref) {
|
|
18517
|
+
let {
|
|
18518
|
+
placeholder,
|
|
18519
|
+
store,
|
|
18520
|
+
...otherProps
|
|
18521
|
+
} = _ref;
|
|
18522
|
+
const {
|
|
18523
|
+
dispatch,
|
|
18524
|
+
state: {
|
|
18525
|
+
month
|
|
18526
|
+
}
|
|
18527
|
+
} = useContext(store);
|
|
18528
|
+
const get2digits = num => num < 10 ? "0" + num.toString() : num.toString();
|
|
18529
|
+
const createMonthsItems = useMemo(() => {
|
|
18530
|
+
return [...Array.from({
|
|
18531
|
+
length: 12
|
|
18532
|
+
}, (_, i) => i + 1)].map(i => {
|
|
18533
|
+
return /*#__PURE__*/React__default.createElement("option", {
|
|
18534
|
+
key: i,
|
|
18535
|
+
value: get2digits(i)
|
|
18536
|
+
}, get2digits(i));
|
|
18537
|
+
});
|
|
18538
|
+
}, []);
|
|
18539
|
+
const handleInputChange = value => {
|
|
18540
|
+
dispatch({
|
|
18541
|
+
type: SET_MONTH,
|
|
18542
|
+
payload: value
|
|
18543
|
+
});
|
|
18544
|
+
};
|
|
18545
|
+
return /*#__PURE__*/React__default.createElement(Select, Object.assign({
|
|
18546
|
+
value: month,
|
|
18547
|
+
onChange: e => handleInputChange(e.target.value)
|
|
18548
|
+
}, otherProps), /*#__PURE__*/React__default.createElement("option", {
|
|
18549
|
+
value: "",
|
|
18550
|
+
disabled: true,
|
|
18551
|
+
selected: true
|
|
18552
|
+
}, placeholder), createMonthsItems);
|
|
18553
|
+
}
|
|
18554
|
+
|
|
18555
|
+
function YearSelect(_ref) {
|
|
18556
|
+
let {
|
|
18557
|
+
placeholder,
|
|
18558
|
+
store,
|
|
18559
|
+
...otherProps
|
|
18560
|
+
} = _ref;
|
|
18561
|
+
const {
|
|
18562
|
+
dispatch,
|
|
18563
|
+
state: {
|
|
18564
|
+
year
|
|
18565
|
+
}
|
|
18566
|
+
} = useContext(store);
|
|
18567
|
+
const createYearsItems = useMemo(() => {
|
|
18568
|
+
return Array.from({
|
|
18569
|
+
length: 10
|
|
18570
|
+
}, (_, i) => i + new Date().getFullYear()).map(i => {
|
|
18571
|
+
return /*#__PURE__*/React__default.createElement("option", {
|
|
18572
|
+
key: i,
|
|
18573
|
+
value: i
|
|
18574
|
+
}, i);
|
|
18575
|
+
});
|
|
18576
|
+
}, []);
|
|
18577
|
+
const handleInputChange = value => {
|
|
18578
|
+
dispatch({
|
|
18579
|
+
type: SET_YEAR,
|
|
18580
|
+
payload: value
|
|
18581
|
+
});
|
|
18582
|
+
};
|
|
18583
|
+
return /*#__PURE__*/React__default.createElement(Select, Object.assign({
|
|
18584
|
+
value: year,
|
|
18585
|
+
onChange: e => handleInputChange(e.target.value)
|
|
18586
|
+
}, otherProps), /*#__PURE__*/React__default.createElement("option", {
|
|
18587
|
+
value: "",
|
|
18588
|
+
disabled: true,
|
|
18589
|
+
selected: true
|
|
18590
|
+
}, placeholder), createYearsItems);
|
|
18591
|
+
}
|
|
18592
|
+
|
|
17938
18593
|
const StripeInputStyle = {
|
|
17939
18594
|
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",
|
|
17940
18595
|
focus: "plc-ring-2 plc-ring-primary-400",
|
|
@@ -18024,6 +18679,24 @@ const CheckoutForm = () => {
|
|
|
18024
18679
|
id: "tapPaymentIframe"
|
|
18025
18680
|
});
|
|
18026
18681
|
}
|
|
18682
|
+
if (cardProcessor === "cybersource") {
|
|
18683
|
+
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("div", {
|
|
18684
|
+
id: "cybersourceCardNumber",
|
|
18685
|
+
className: "pelcro-input-field plc-h-12"
|
|
18686
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
18687
|
+
className: "plc-flex plc-items-end plc-justify-between plc-my-2"
|
|
18688
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
18689
|
+
className: "plc-w-6/12 plc-pr-4"
|
|
18690
|
+
}, /*#__PURE__*/React__default.createElement(MonthSelect, {
|
|
18691
|
+
store: store$k,
|
|
18692
|
+
placeholder: "Exp Month"
|
|
18693
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
18694
|
+
className: "plc-w-6/12"
|
|
18695
|
+
}, /*#__PURE__*/React__default.createElement(YearSelect, {
|
|
18696
|
+
store: store$k,
|
|
18697
|
+
placeholder: "Exp Year"
|
|
18698
|
+
}))));
|
|
18699
|
+
}
|
|
18027
18700
|
if (cardProcessor === "stripe") {
|
|
18028
18701
|
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(PelcroCardNumber, {
|
|
18029
18702
|
autoFocus: true
|
|
@@ -18722,11 +19395,47 @@ const SubscriptionCreateFreePlanButton = _ref => {
|
|
|
18722
19395
|
}, otherProps), t("buttons.subscribe"));
|
|
18723
19396
|
};
|
|
18724
19397
|
|
|
19398
|
+
const OrderCreateFreeButton = _ref => {
|
|
19399
|
+
let {
|
|
19400
|
+
name,
|
|
19401
|
+
onClick,
|
|
19402
|
+
...otherProps
|
|
19403
|
+
} = _ref;
|
|
19404
|
+
const {
|
|
19405
|
+
state: {
|
|
19406
|
+
disableSubmit
|
|
19407
|
+
},
|
|
19408
|
+
dispatch
|
|
19409
|
+
} = useContext(store$k);
|
|
19410
|
+
const {
|
|
19411
|
+
t
|
|
19412
|
+
} = useTranslation("checkoutForm");
|
|
19413
|
+
const [isDisabled, setDisabled] = useState(true);
|
|
19414
|
+
useEffect(() => {
|
|
19415
|
+
setDisabled(disableSubmit);
|
|
19416
|
+
}, [disableSubmit]);
|
|
19417
|
+
return /*#__PURE__*/React__default.createElement(Button, Object.assign({
|
|
19418
|
+
className: "plc-w-full",
|
|
19419
|
+
onClick: () => {
|
|
19420
|
+
dispatch({
|
|
19421
|
+
type: DISABLE_SUBMIT,
|
|
19422
|
+
payload: true
|
|
19423
|
+
});
|
|
19424
|
+
dispatch({
|
|
19425
|
+
type: SUBMIT_PAYMENT
|
|
19426
|
+
});
|
|
19427
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
19428
|
+
},
|
|
19429
|
+
disabled: isDisabled,
|
|
19430
|
+
isLoading: disableSubmit
|
|
19431
|
+
}, otherProps), t("labels.submit"));
|
|
19432
|
+
};
|
|
19433
|
+
|
|
18725
19434
|
/**
|
|
18726
19435
|
*
|
|
18727
19436
|
*/
|
|
18728
19437
|
function PaymentMethodView(_ref) {
|
|
18729
|
-
var _window$Pelcro$site$r, _window$Pelcro$site$r2
|
|
19438
|
+
var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _calcAndFormatItemsTo, _order$;
|
|
18730
19439
|
let {
|
|
18731
19440
|
onSuccess,
|
|
18732
19441
|
onGiftRenewalSuccess,
|
|
@@ -18734,7 +19443,9 @@ function PaymentMethodView(_ref) {
|
|
|
18734
19443
|
type,
|
|
18735
19444
|
showCoupon,
|
|
18736
19445
|
showExternalPaymentMethods,
|
|
18737
|
-
showSubscriptionButton
|
|
19446
|
+
showSubscriptionButton,
|
|
19447
|
+
showOrderButton,
|
|
19448
|
+
order
|
|
18738
19449
|
} = _ref;
|
|
18739
19450
|
const {
|
|
18740
19451
|
t
|
|
@@ -18742,12 +19453,23 @@ function PaymentMethodView(_ref) {
|
|
|
18742
19453
|
const cardProcessor = getSiteCardProcessor();
|
|
18743
19454
|
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);
|
|
18744
19455
|
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);
|
|
19456
|
+
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);
|
|
18745
19457
|
const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
|
|
18746
19458
|
const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
|
|
18747
19459
|
const isUserPhone = Boolean(window.Pelcro.user.read().phone);
|
|
18748
19460
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
18749
19461
|
className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
|
|
18750
|
-
},
|
|
19462
|
+
}, order && /*#__PURE__*/React__default.createElement("div", {
|
|
19463
|
+
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"
|
|
19464
|
+
}, /*#__PURE__*/React__default.createElement("p", {
|
|
19465
|
+
className: "plc-text-gray-600"
|
|
19466
|
+
}, !Array.isArray(order) ? /*#__PURE__*/React__default.createElement("span", {
|
|
19467
|
+
className: "plc-tracking-wider plc-uppercase"
|
|
19468
|
+
}, order === null || order === void 0 ? void 0 : order.name) : /*#__PURE__*/React__default.createElement("span", {
|
|
19469
|
+
className: "plc-tracking-wider plc-uppercase"
|
|
19470
|
+
}, t("labels.freeItems")), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
|
|
19471
|
+
className: "plc-text-xl plc-font-semibold plc-text-primary-600"
|
|
19472
|
+
}, (_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.createElement("div", {
|
|
18751
19473
|
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"
|
|
18752
19474
|
}, /*#__PURE__*/React__default.createElement(SvgLock, {
|
|
18753
19475
|
className: "plc-w-5 plc-h-5 plc-mr-1"
|
|
@@ -18763,10 +19485,11 @@ function PaymentMethodView(_ref) {
|
|
|
18763
19485
|
type: type,
|
|
18764
19486
|
onSuccess: onSuccess,
|
|
18765
19487
|
onGiftRenewalSuccess: onGiftRenewalSuccess,
|
|
18766
|
-
onFailure: onFailure
|
|
19488
|
+
onFailure: onFailure,
|
|
19489
|
+
freeOrders: showOrderButton
|
|
18767
19490
|
}, /*#__PURE__*/React__default.createElement(AlertWithContext, {
|
|
18768
19491
|
className: "plc-mb-2"
|
|
18769
|
-
}), showSubscriptionButton
|
|
19492
|
+
}), showSubscriptionButton && /*#__PURE__*/React__default.createElement(SubscriptionCreateFreePlanButton, null), showOrderButton && /*#__PURE__*/React__default.createElement(OrderCreateFreeButton, null), !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(BankRedirection, null), /*#__PURE__*/React__default.createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default.createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
18770
19493
|
className: "plc-flex plc-items-start"
|
|
18771
19494
|
}, /*#__PURE__*/React__default.createElement(IncludeFirstName, {
|
|
18772
19495
|
id: "pelcro-input-first-name",
|
|
@@ -18788,7 +19511,7 @@ function PaymentMethodView(_ref) {
|
|
|
18788
19511
|
className: "plc-mb-2"
|
|
18789
19512
|
}, /*#__PURE__*/React__default.createElement(CouponCode, null), /*#__PURE__*/React__default.createElement(DiscountedPrice, null)), /*#__PURE__*/React__default.createElement(TaxAmount, null), /*#__PURE__*/React__default.createElement("div", {
|
|
18790
19513
|
className: "plc-grid plc-mt-4 plc-gap-y-2"
|
|
18791
|
-
}, /*#__PURE__*/React__default.createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsTap ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : null)))));
|
|
19514
|
+
}, /*#__PURE__*/React__default.createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : null)))));
|
|
18792
19515
|
}
|
|
18793
19516
|
|
|
18794
19517
|
const SubscriptionRenewView = _ref => {
|
|
@@ -20521,6 +21244,16 @@ function SubscriptionManageMembersList(props) {
|
|
|
20521
21244
|
icon: /*#__PURE__*/React__default.createElement(SvgCheckMark, null)
|
|
20522
21245
|
};
|
|
20523
21246
|
}, []);
|
|
21247
|
+
const showMemberData = useCallback(member => {
|
|
21248
|
+
var _member$customer, _member$customer2, _member$customer3, _member$customer4;
|
|
21249
|
+
let data;
|
|
21250
|
+
if ((member === null || member === void 0 ? void 0 : member.status) !== "active") {
|
|
21251
|
+
data = member === null || member === void 0 ? void 0 : member.invitation_email;
|
|
21252
|
+
return data;
|
|
21253
|
+
}
|
|
21254
|
+
data = (member === null || member === void 0 ? void 0 : (_member$customer = member.customer) === null || _member$customer === void 0 ? void 0 : _member$customer.email) || (member === null || member === void 0 ? void 0 : (_member$customer2 = member.customer) === null || _member$customer2 === void 0 ? void 0 : _member$customer2.first_name) + " " + (member === null || member === void 0 ? void 0 : (_member$customer3 = member.customer) === null || _member$customer3 === void 0 ? void 0 : _member$customer3.last_name) || (member === null || member === void 0 ? void 0 : (_member$customer4 = member.customer) === null || _member$customer4 === void 0 ? void 0 : _member$customer4.username) || "-----";
|
|
21255
|
+
return data;
|
|
21256
|
+
}, []);
|
|
20524
21257
|
if (loading) {
|
|
20525
21258
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("div", {
|
|
20526
21259
|
className: "plc-animate-pulse"
|
|
@@ -20562,10 +21295,10 @@ function SubscriptionManageMembersList(props) {
|
|
|
20562
21295
|
className: `plc-w-full plc-align-middle plc-cursor-pointer accordion-header hover:plc-bg-gray-50 plc-text-center`
|
|
20563
21296
|
}, /*#__PURE__*/React__default.createElement("td", {
|
|
20564
21297
|
className: "plc-truncate plc-text-left",
|
|
20565
|
-
title: member
|
|
21298
|
+
title: showMemberData(member)
|
|
20566
21299
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
20567
21300
|
className: "plc-font-semibold plc-text-gray-500"
|
|
20568
|
-
}, member
|
|
21301
|
+
}, showMemberData(member))), /*#__PURE__*/React__default.createElement("td", {
|
|
20569
21302
|
className: "plc-py-2"
|
|
20570
21303
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
20571
21304
|
className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${getMemberStatus(member).bgColor} plc-uppercase ${getMemberStatus(member).textColor} plc-rounded-lg`
|
|
@@ -21800,37 +22533,6 @@ const AddressCreateSubmit = _ref => {
|
|
|
21800
22533
|
}, otherProps), name !== null && name !== void 0 ? name : t("buttons.submit"));
|
|
21801
22534
|
};
|
|
21802
22535
|
|
|
21803
|
-
function Select(_ref) {
|
|
21804
|
-
let {
|
|
21805
|
-
label = "",
|
|
21806
|
-
required,
|
|
21807
|
-
id,
|
|
21808
|
-
errorId,
|
|
21809
|
-
error = "",
|
|
21810
|
-
className = "",
|
|
21811
|
-
labelClassName = "",
|
|
21812
|
-
errorClassName = "",
|
|
21813
|
-
wrapperClassName = "",
|
|
21814
|
-
children,
|
|
21815
|
-
...otherProps
|
|
21816
|
-
} = _ref;
|
|
21817
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
21818
|
-
className: `pelcro-input-wrapper ${wrapperClassName}`
|
|
21819
|
-
}, /*#__PURE__*/React__default.createElement("label", {
|
|
21820
|
-
htmlFor: id,
|
|
21821
|
-
className: `pelcro-input-label ${labelClassName}`
|
|
21822
|
-
}, `${label}${required ? "*" : ""}`), /*#__PURE__*/React__default.createElement("select", Object.assign({
|
|
21823
|
-
id: id,
|
|
21824
|
-
className: `pelcro-input-field ${className} ${error ? "pelcro-input-invalid" : ""}`,
|
|
21825
|
-
"aria-describedby": errorId,
|
|
21826
|
-
"aria-invalid": Boolean(error)
|
|
21827
|
-
}, otherProps), children), error && /*#__PURE__*/React__default.createElement("p", {
|
|
21828
|
-
id: errorId,
|
|
21829
|
-
"aria-live": "assertive",
|
|
21830
|
-
className: `pelcro-input-error ${errorClassName}`
|
|
21831
|
-
}, error));
|
|
21832
|
-
}
|
|
21833
|
-
|
|
21834
22536
|
function CountrySelect(_ref) {
|
|
21835
22537
|
let {
|
|
21836
22538
|
placeholder,
|
|
@@ -24173,9 +24875,15 @@ const OrderCreateContainer = props => /*#__PURE__*/React__default.createElement(
|
|
|
24173
24875
|
}, props));
|
|
24174
24876
|
|
|
24175
24877
|
const OrderCreateView = props => {
|
|
24878
|
+
var _window$Pelcro, _window$Pelcro$uiSett;
|
|
24176
24879
|
const {
|
|
24177
24880
|
t
|
|
24178
24881
|
} = useTranslation("payment");
|
|
24882
|
+
const {
|
|
24883
|
+
order
|
|
24884
|
+
} = usePelcro();
|
|
24885
|
+
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;
|
|
24886
|
+
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));
|
|
24179
24887
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
24180
24888
|
id: "pelcro-order-create-view"
|
|
24181
24889
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -24186,7 +24894,9 @@ const OrderCreateView = props => {
|
|
|
24186
24894
|
}, /*#__PURE__*/React__default.createElement(PaymentMethodView, Object.assign({
|
|
24187
24895
|
type: "orderCreate",
|
|
24188
24896
|
showCoupon: true,
|
|
24189
|
-
showExternalPaymentMethods: false
|
|
24897
|
+
showExternalPaymentMethods: false,
|
|
24898
|
+
showOrderButton: showOrderButton,
|
|
24899
|
+
order: order
|
|
24190
24900
|
}, props))));
|
|
24191
24901
|
};
|
|
24192
24902
|
|
|
@@ -25394,11 +26104,12 @@ const PaymentMethodSelectModal = _ref => {
|
|
|
25394
26104
|
const {
|
|
25395
26105
|
switchToCheckoutForm,
|
|
25396
26106
|
set,
|
|
25397
|
-
plan
|
|
26107
|
+
plan,
|
|
26108
|
+
order
|
|
25398
26109
|
} = usePelcro();
|
|
25399
26110
|
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;
|
|
25400
26111
|
useEffect(() => {
|
|
25401
|
-
if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
|
|
26112
|
+
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) {
|
|
25402
26113
|
switchToCheckoutForm();
|
|
25403
26114
|
}
|
|
25404
26115
|
}, []);
|
|
@@ -27506,7 +28217,7 @@ const InvoicesItems = () => {
|
|
|
27506
28217
|
setInvoice,
|
|
27507
28218
|
switchView
|
|
27508
28219
|
} = usePelcro();
|
|
27509
|
-
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 : [];
|
|
28220
|
+
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 : [];
|
|
27510
28221
|
const showInvoiceDetails = event => {
|
|
27511
28222
|
if (setInvoice(event.target.dataset.id)) {
|
|
27512
28223
|
switchView("invoice-details");
|
|
@@ -28274,7 +28985,7 @@ class Dashboard extends Component {
|
|
|
28274
28985
|
}
|
|
28275
28986
|
function hasInvoices() {
|
|
28276
28987
|
var _window$Pelcro$invoic, _window$Pelcro$invoic2;
|
|
28277
|
-
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 : [];
|
|
28988
|
+
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 : [];
|
|
28278
28989
|
return invoices.length > 0;
|
|
28279
28990
|
}
|
|
28280
28991
|
function hasDonationSubs() {
|
|
@@ -32103,4 +32814,4 @@ const QrCodeModal = _ref => {
|
|
|
32103
32814
|
};
|
|
32104
32815
|
QrCodeModal.viewId = "qrcode";
|
|
32105
32816
|
|
|
32106
|
-
export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateSetDefault, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateSetDefault, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, Alert as AlertElement, ApplyCouponButton, Auth0LoginButton, Badge, BankAuthenticationSuccess, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, EmailVerifyContainer, EmailVerifyModal, EmailVerifyResendButton, EmailVerifyView, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, IncludeFirstName, IncludeLastName, IncludePhone, Input, InvoiceDetailsContainer, InvoiceDetailsDownloadButton, InvoiceDetailsModal, InvoiceDetailsPayButton, InvoiceDetailsView, InvoicePaymentContainer, InvoicePaymentModal, InvoicePaymentView, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginRequestLoginToken, LoginUsername, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, NewsletterUpdateButton, NewsletterUpdateContainer, NewsletterUpdateList, NewsletterUpdateModal, NewsletterUpdateView, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PasswordlessRequestContainer, PasswordlessRequestEmail, PasswordlessRequestModal, PasswordlessRequestView, PasswordlessRequestViewButton, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, QrCodeModal, QrCodeView, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCancelModal, SubscriptionCreateContainer, SubscriptionCreateFreePlanButton, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionManageMembersButton, SubscriptionManageMembersContainer, SubscriptionManageMembersEmails, SubscriptionManageMembersList, SubscriptionManageMembersModal, SubscriptionManageMembersView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, SubscriptionSuspendContainer, SubscriptionSuspendModal, SubscriptionSuspendView, TaxAmount, TextArea, Tooltip, UserNameInput, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateTin, UserUpdateUsername, UserUpdateView, VerifyLinkTokenContainer, VerifyLinkTokenLoader, VerifyLinkTokenModal, VerifyLinkTokenView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify$1 as notify, unauthenticatedButtons, usePelcro };
|
|
32817
|
+
export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateSetDefault, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateSetDefault, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, Alert as AlertElement, ApplyCouponButton, Auth0LoginButton, Badge, BankAuthenticationSuccess, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, EmailVerifyContainer, EmailVerifyModal, EmailVerifyResendButton, EmailVerifyView, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, IncludeFirstName, IncludeLastName, IncludePhone, Input, InvoiceDetailsContainer, InvoiceDetailsDownloadButton, InvoiceDetailsModal, InvoiceDetailsPayButton, InvoiceDetailsView, InvoicePaymentContainer, InvoicePaymentModal, InvoicePaymentView, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginRequestLoginToken, LoginUsername, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, NewsletterUpdateButton, NewsletterUpdateContainer, NewsletterUpdateList, NewsletterUpdateModal, NewsletterUpdateView, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateFreeButton, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PasswordlessRequestContainer, PasswordlessRequestEmail, PasswordlessRequestModal, PasswordlessRequestView, PasswordlessRequestViewButton, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, QrCodeModal, QrCodeView, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCancelModal, SubscriptionCreateContainer, SubscriptionCreateFreePlanButton, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionManageMembersButton, SubscriptionManageMembersContainer, SubscriptionManageMembersEmails, SubscriptionManageMembersList, SubscriptionManageMembersModal, SubscriptionManageMembersView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, SubscriptionSuspendContainer, SubscriptionSuspendModal, SubscriptionSuspendView, TaxAmount, TextArea, Tooltip, UserNameInput, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateTin, UserUpdateUsername, UserUpdateView, VerifyLinkTokenContainer, VerifyLinkTokenLoader, VerifyLinkTokenModal, VerifyLinkTokenView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify$1 as notify, unauthenticatedButtons, usePelcro };
|