@pelcro/react-pelcro-js 4.0.0-alpha.118 → 4.0.0-alpha.119
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 +289 -34
- package/dist/index.esm.js +289 -34
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -46428,7 +46428,10 @@ axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormDat
|
|
|
46428
46428
|
|
|
46429
46429
|
axios.default = axios;
|
|
46430
46430
|
|
|
46431
|
-
const OrderCreateView =
|
|
46431
|
+
const OrderCreateView = ({
|
|
46432
|
+
showExternalPaymentMethods = false,
|
|
46433
|
+
...props
|
|
46434
|
+
}) => {
|
|
46432
46435
|
var _window$Pelcro, _window$Pelcro$uiSett, _window$Pelcro$user$r, _window, _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro$user$r2, _window2, _window2$Pelcro, _window2$Pelcro$user, _addresses$find, _addresses$find2;
|
|
46433
46436
|
const {
|
|
46434
46437
|
t
|
|
@@ -46517,7 +46520,7 @@ const OrderCreateView = props => {
|
|
|
46517
46520
|
}, address === null || address === void 0 ? void 0 : address.phone))), /*#__PURE__*/React__default['default'].createElement(PaymentMethodView, Object.assign({
|
|
46518
46521
|
type: "orderCreate",
|
|
46519
46522
|
showCoupon: true,
|
|
46520
|
-
showExternalPaymentMethods:
|
|
46523
|
+
showExternalPaymentMethods: showExternalPaymentMethods,
|
|
46521
46524
|
showApplePayButton: true,
|
|
46522
46525
|
showOrderButton: showOrderButton,
|
|
46523
46526
|
order: order,
|
|
@@ -49286,57 +49289,306 @@ function YearSelect({
|
|
|
49286
49289
|
}, placeholder), createYearsItems);
|
|
49287
49290
|
}
|
|
49288
49291
|
|
|
49289
|
-
const PelcroPaymentRequestButton =
|
|
49292
|
+
const PelcroPaymentRequestButton = ({
|
|
49293
|
+
type,
|
|
49294
|
+
onSuccess,
|
|
49295
|
+
onFailure,
|
|
49296
|
+
...props
|
|
49297
|
+
}) => {
|
|
49298
|
+
const stripe = useStripe();
|
|
49299
|
+
const [isInitializing, setIsInitializing] = React.useState(true);
|
|
49300
|
+
const [localPaymentRequest, setLocalPaymentRequest] = React.useState(null);
|
|
49290
49301
|
const {
|
|
49291
|
-
state
|
|
49292
|
-
|
|
49293
|
-
paymentRequest,
|
|
49294
|
-
currentPlan,
|
|
49295
|
-
updatedPrice
|
|
49296
|
-
}
|
|
49302
|
+
state,
|
|
49303
|
+
dispatch
|
|
49297
49304
|
} = React.useContext(store$m);
|
|
49298
|
-
const
|
|
49299
|
-
|
|
49300
|
-
|
|
49301
|
-
|
|
49302
|
-
|
|
49303
|
-
|
|
49305
|
+
const {
|
|
49306
|
+
canMakePayment,
|
|
49307
|
+
currentPlan,
|
|
49308
|
+
updatedPrice
|
|
49309
|
+
} = state;
|
|
49310
|
+
const {
|
|
49311
|
+
order,
|
|
49312
|
+
set,
|
|
49313
|
+
selectedPaymentMethodId
|
|
49314
|
+
} = usePelcro();
|
|
49315
|
+
const getOrderInfo = () => {
|
|
49316
|
+
if (!order) {
|
|
49317
|
+
return {
|
|
49318
|
+
price: null,
|
|
49319
|
+
currency: null,
|
|
49320
|
+
label: null
|
|
49321
|
+
};
|
|
49322
|
+
}
|
|
49323
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
49324
|
+
if (isQuickPurchase) {
|
|
49325
|
+
return {
|
|
49326
|
+
price: order.price * order.quantity,
|
|
49327
|
+
currency: order.currency,
|
|
49328
|
+
label: order.name
|
|
49329
|
+
};
|
|
49330
|
+
}
|
|
49331
|
+
if (order.length === 0) {
|
|
49332
|
+
return {
|
|
49333
|
+
price: null,
|
|
49334
|
+
currency: null,
|
|
49335
|
+
label: null
|
|
49336
|
+
};
|
|
49337
|
+
}
|
|
49338
|
+
const price = order.reduce((total, item) => total + item.price * item.quantity, 0);
|
|
49339
|
+
return {
|
|
49340
|
+
price,
|
|
49341
|
+
currency: order[0].currency,
|
|
49342
|
+
label: "Order"
|
|
49343
|
+
};
|
|
49344
|
+
};
|
|
49345
|
+
const orderPrice = getOrderInfo().price;
|
|
49346
|
+
const orderCurrency = getOrderInfo().currency;
|
|
49347
|
+
const orderLabel = getOrderInfo().label;
|
|
49348
|
+
const purchase = (gatewayService, gatewayToken, state, dispatch) => {
|
|
49349
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
49350
|
+
const mappedOrderItems = isQuickPurchase ? [{
|
|
49351
|
+
sku_id: order.id,
|
|
49352
|
+
quantity: order.quantity
|
|
49353
|
+
}] : order.map(item => ({
|
|
49354
|
+
sku_id: item.id,
|
|
49355
|
+
quantity: item.quantity
|
|
49356
|
+
}));
|
|
49357
|
+
const {
|
|
49358
|
+
couponCode
|
|
49359
|
+
} = state;
|
|
49360
|
+
const payment = new Payment(gatewayService);
|
|
49361
|
+
payment.execute({
|
|
49362
|
+
type: PAYMENT_TYPES.PURCHASE_ECOMMERCE_ORDER,
|
|
49363
|
+
token: gatewayToken,
|
|
49364
|
+
isExistingSource: Boolean(selectedPaymentMethodId),
|
|
49365
|
+
items: mappedOrderItems,
|
|
49366
|
+
addressId: state.selectedAddressId,
|
|
49367
|
+
couponCode
|
|
49368
|
+
}, (err, orderResponse) => {
|
|
49369
|
+
var _window$Pelcro, _window$Pelcro$user, _window$Pelcro$user$r;
|
|
49370
|
+
if (err) {
|
|
49371
|
+
toggleAuthenticationSuccessPendingView(false);
|
|
49372
|
+
dispatch({
|
|
49373
|
+
type: DISABLE_SUBMIT,
|
|
49374
|
+
payload: false
|
|
49375
|
+
});
|
|
49376
|
+
dispatch({
|
|
49377
|
+
type: LOADING,
|
|
49378
|
+
payload: false
|
|
49379
|
+
});
|
|
49380
|
+
onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
|
|
49381
|
+
return dispatch({
|
|
49382
|
+
type: SHOW_ALERT,
|
|
49383
|
+
payload: {
|
|
49384
|
+
type: "error",
|
|
49385
|
+
content: getErrorMessages(err)
|
|
49386
|
+
}
|
|
49387
|
+
});
|
|
49388
|
+
}
|
|
49389
|
+
if (isQuickPurchase) {
|
|
49390
|
+
set({
|
|
49391
|
+
order: null
|
|
49392
|
+
});
|
|
49393
|
+
} else {
|
|
49394
|
+
set({
|
|
49395
|
+
order: null,
|
|
49396
|
+
cartItems: []
|
|
49397
|
+
});
|
|
49304
49398
|
}
|
|
49399
|
+
window.Pelcro.user.refresh({
|
|
49400
|
+
auth_token: (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$user = _window$Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : (_window$Pelcro$user$r = _window$Pelcro$user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : _window$Pelcro$user$r.auth_token
|
|
49401
|
+
}, (err, res) => {
|
|
49402
|
+
dispatch({
|
|
49403
|
+
type: DISABLE_SUBMIT,
|
|
49404
|
+
payload: false
|
|
49405
|
+
});
|
|
49406
|
+
dispatch({
|
|
49407
|
+
type: LOADING,
|
|
49408
|
+
payload: false
|
|
49409
|
+
});
|
|
49410
|
+
toggleAuthenticationSuccessPendingView(false);
|
|
49411
|
+
if (err) {
|
|
49412
|
+
onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
|
|
49413
|
+
return dispatch({
|
|
49414
|
+
type: SHOW_ALERT,
|
|
49415
|
+
payload: {
|
|
49416
|
+
type: "error",
|
|
49417
|
+
content: getErrorMessages(err)
|
|
49418
|
+
}
|
|
49419
|
+
});
|
|
49420
|
+
}
|
|
49421
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(orderResponse);
|
|
49422
|
+
});
|
|
49305
49423
|
});
|
|
49306
49424
|
};
|
|
49307
|
-
|
|
49308
|
-
|
|
49309
|
-
|
|
49310
|
-
|
|
49311
|
-
|
|
49425
|
+
React.useEffect(() => {
|
|
49426
|
+
if (!stripe) {
|
|
49427
|
+
setIsInitializing(false);
|
|
49428
|
+
return;
|
|
49429
|
+
}
|
|
49430
|
+
let mounted = true;
|
|
49431
|
+
const initializePaymentRequest = async () => {
|
|
49432
|
+
try {
|
|
49433
|
+
var _ref;
|
|
49434
|
+
const pr = stripe.paymentRequest({
|
|
49435
|
+
country: window.Pelcro.user.location.countryCode || "US",
|
|
49436
|
+
currency: ((currentPlan === null || currentPlan === void 0 ? void 0 : currentPlan.currency) || orderCurrency).toLowerCase(),
|
|
49437
|
+
total: {
|
|
49438
|
+
label: (currentPlan === null || currentPlan === void 0 ? void 0 : currentPlan.nickname) || (currentPlan === null || currentPlan === void 0 ? void 0 : currentPlan.description) || orderLabel || "Payment",
|
|
49439
|
+
amount: (_ref = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : currentPlan === null || currentPlan === void 0 ? void 0 : currentPlan.amount) !== null && _ref !== void 0 ? _ref : orderPrice,
|
|
49440
|
+
pending: false
|
|
49441
|
+
},
|
|
49442
|
+
requestPayerEmail: false,
|
|
49443
|
+
requestPayerName: false,
|
|
49444
|
+
requestShipping: false
|
|
49445
|
+
});
|
|
49446
|
+
pr.on("source", async event => {
|
|
49447
|
+
try {
|
|
49448
|
+
var _event$source, _event$source$card;
|
|
49449
|
+
dispatch({
|
|
49450
|
+
type: DISABLE_COUPON_BUTTON,
|
|
49451
|
+
payload: true
|
|
49452
|
+
});
|
|
49453
|
+
dispatch({
|
|
49454
|
+
type: DISABLE_SUBMIT,
|
|
49455
|
+
payload: true
|
|
49456
|
+
});
|
|
49457
|
+
dispatch({
|
|
49458
|
+
type: LOADING,
|
|
49459
|
+
payload: true
|
|
49460
|
+
});
|
|
49461
|
+
event.complete("success");
|
|
49462
|
+
if (((_event$source = event.source) === null || _event$source === void 0 ? void 0 : (_event$source$card = _event$source.card) === null || _event$source$card === void 0 ? void 0 : _event$source$card.three_d_secure) === "required") {
|
|
49463
|
+
return generate3DSecureSource(event.source).then(({
|
|
49464
|
+
source,
|
|
49465
|
+
error
|
|
49466
|
+
}) => {
|
|
49467
|
+
if (error) {
|
|
49468
|
+
return handlePaymentError(error);
|
|
49469
|
+
}
|
|
49470
|
+
toggleAuthenticationPendingView(true, source);
|
|
49471
|
+
});
|
|
49472
|
+
}
|
|
49473
|
+
|
|
49474
|
+
// Handle different payment types
|
|
49475
|
+
if (type === "orderCreate") {
|
|
49476
|
+
purchase(new StripeGateway(), event.source.id, state, dispatch);
|
|
49477
|
+
} else {
|
|
49478
|
+
dispatch({
|
|
49479
|
+
type: SUBSCRIBE,
|
|
49480
|
+
payload: {
|
|
49481
|
+
id: event.source.id,
|
|
49482
|
+
isExistingSource: false
|
|
49483
|
+
}
|
|
49484
|
+
});
|
|
49485
|
+
}
|
|
49486
|
+
} catch (error) {
|
|
49487
|
+
dispatch({
|
|
49488
|
+
type: SHOW_ALERT,
|
|
49489
|
+
payload: {
|
|
49490
|
+
type: "error",
|
|
49491
|
+
content: error.message || "Payment failed. Please try again."
|
|
49492
|
+
}
|
|
49493
|
+
});
|
|
49494
|
+
event.complete("fail");
|
|
49495
|
+
dispatch({
|
|
49496
|
+
type: DISABLE_COUPON_BUTTON,
|
|
49497
|
+
payload: false
|
|
49498
|
+
});
|
|
49499
|
+
dispatch({
|
|
49500
|
+
type: DISABLE_SUBMIT,
|
|
49501
|
+
payload: false
|
|
49502
|
+
});
|
|
49503
|
+
dispatch({
|
|
49504
|
+
type: LOADING,
|
|
49505
|
+
payload: false
|
|
49506
|
+
});
|
|
49507
|
+
}
|
|
49508
|
+
});
|
|
49509
|
+
pr.on("cancel", () => {
|
|
49510
|
+
dispatch({
|
|
49511
|
+
type: DISABLE_COUPON_BUTTON,
|
|
49512
|
+
payload: false
|
|
49513
|
+
});
|
|
49514
|
+
dispatch({
|
|
49515
|
+
type: DISABLE_SUBMIT,
|
|
49516
|
+
payload: false
|
|
49517
|
+
});
|
|
49518
|
+
dispatch({
|
|
49519
|
+
type: LOADING,
|
|
49520
|
+
payload: false
|
|
49521
|
+
});
|
|
49522
|
+
});
|
|
49523
|
+
const result = await pr.canMakePayment();
|
|
49524
|
+
if (mounted && result) {
|
|
49525
|
+
setLocalPaymentRequest(pr);
|
|
49526
|
+
dispatch({
|
|
49527
|
+
type: SET_PAYMENT_REQUEST,
|
|
49528
|
+
payload: pr
|
|
49529
|
+
});
|
|
49530
|
+
dispatch({
|
|
49531
|
+
type: SET_CAN_MAKE_PAYMENT,
|
|
49532
|
+
payload: true
|
|
49533
|
+
});
|
|
49534
|
+
} else if (mounted) {
|
|
49535
|
+
dispatch({
|
|
49536
|
+
type: SET_CAN_MAKE_PAYMENT,
|
|
49537
|
+
payload: false
|
|
49538
|
+
});
|
|
49539
|
+
}
|
|
49540
|
+
} catch (error) {
|
|
49541
|
+
if (mounted) {
|
|
49542
|
+
dispatch({
|
|
49543
|
+
type: SET_CAN_MAKE_PAYMENT,
|
|
49544
|
+
payload: false
|
|
49545
|
+
});
|
|
49546
|
+
}
|
|
49547
|
+
} finally {
|
|
49548
|
+
if (mounted) {
|
|
49549
|
+
setIsInitializing(false);
|
|
49550
|
+
}
|
|
49551
|
+
}
|
|
49552
|
+
};
|
|
49553
|
+
initializePaymentRequest();
|
|
49554
|
+
return () => {
|
|
49555
|
+
mounted = false;
|
|
49556
|
+
};
|
|
49557
|
+
}, [stripe, currentPlan, updatedPrice, dispatch, order, type]);
|
|
49558
|
+
if (isInitializing || !canMakePayment || !localPaymentRequest) {
|
|
49559
|
+
return null;
|
|
49560
|
+
}
|
|
49561
|
+
return /*#__PURE__*/React__default['default'].createElement(PaymentRequestButtonElement, Object.assign({
|
|
49562
|
+
className: "StripeElement stripe-payment-request-btn",
|
|
49563
|
+
options: {
|
|
49564
|
+
paymentRequest: localPaymentRequest,
|
|
49312
49565
|
style: {
|
|
49313
49566
|
paymentRequestButton: {
|
|
49314
49567
|
theme: "dark",
|
|
49315
|
-
height: "40px"
|
|
49568
|
+
height: "40px",
|
|
49569
|
+
buttonType: "plain"
|
|
49316
49570
|
}
|
|
49317
49571
|
}
|
|
49318
|
-
}
|
|
49319
|
-
}
|
|
49320
|
-
return null;
|
|
49572
|
+
}
|
|
49573
|
+
}, props));
|
|
49321
49574
|
};
|
|
49322
49575
|
const CheckoutForm = ({
|
|
49323
49576
|
type
|
|
49324
49577
|
}) => {
|
|
49325
|
-
var _window, _window$
|
|
49578
|
+
var _window, _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$, _window2, _window2$Pelcro, _window2$Pelcro$user, _window2$Pelcro$user$, _window3, _window3$Pelcro, _window3$Pelcro$user, _window3$Pelcro$user$;
|
|
49326
49579
|
const {
|
|
49327
49580
|
selectedPaymentMethodId,
|
|
49328
49581
|
paymentMethodToEdit
|
|
49329
49582
|
} = usePelcro();
|
|
49330
49583
|
const cardProcessor = getSiteCardProcessor();
|
|
49331
49584
|
const billingDetails = {
|
|
49332
|
-
name: (_window = window) === null || _window === void 0 ? void 0 : (_window$
|
|
49585
|
+
name: (_window = window) === null || _window === void 0 ? void 0 : (_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$.name,
|
|
49333
49586
|
email: (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$Pelcro = _window2.Pelcro) === null || _window2$Pelcro === void 0 ? void 0 : (_window2$Pelcro$user = _window2$Pelcro.user) === null || _window2$Pelcro$user === void 0 ? void 0 : (_window2$Pelcro$user$ = _window2$Pelcro$user.read()) === null || _window2$Pelcro$user$ === void 0 ? void 0 : _window2$Pelcro$user$.email,
|
|
49334
49587
|
phone: (_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$Pelcro = _window3.Pelcro) === null || _window3$Pelcro === void 0 ? void 0 : (_window3$Pelcro$user = _window3$Pelcro.user) === null || _window3$Pelcro$user === void 0 ? void 0 : (_window3$Pelcro$user$ = _window3$Pelcro$user.read()) === null || _window3$Pelcro$user$ === void 0 ? void 0 : _window3$Pelcro$user$.phone
|
|
49335
49588
|
};
|
|
49336
49589
|
const paymentElementOptions = {
|
|
49337
49590
|
layout: {
|
|
49338
49591
|
type: "tabs",
|
|
49339
|
-
// or accordion
|
|
49340
49592
|
defaultCollapsed: false
|
|
49341
49593
|
},
|
|
49342
49594
|
defaultValues: {
|
|
@@ -49350,11 +49602,8 @@ const CheckoutForm = ({
|
|
|
49350
49602
|
address: "never"
|
|
49351
49603
|
}
|
|
49352
49604
|
},
|
|
49353
|
-
|
|
49354
|
-
applePay: "never"
|
|
49355
|
-
card: "never",
|
|
49356
|
-
googlePay: "never",
|
|
49357
|
-
paypal: "never"
|
|
49605
|
+
wallets: {
|
|
49606
|
+
applePay: "never"
|
|
49358
49607
|
}
|
|
49359
49608
|
};
|
|
49360
49609
|
if (selectedPaymentMethodId) {
|
|
@@ -50727,7 +50976,11 @@ function PaymentMethodView({
|
|
|
50727
50976
|
className: "plc-grid plc-mt-4 plc-gap-y-2"
|
|
50728
50977
|
}, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, {
|
|
50729
50978
|
isSubmitDisabled: isSubmitDisabled
|
|
50730
|
-
}), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton,
|
|
50979
|
+
}), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, {
|
|
50980
|
+
type: type,
|
|
50981
|
+
onSuccess: onSuccess,
|
|
50982
|
+
onFailure: onFailure
|
|
50983
|
+
}), /*#__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, showApplePayButton && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(ApplePayButton, null)) : null)))));
|
|
50731
50984
|
}
|
|
50732
50985
|
|
|
50733
50986
|
const SubscriptionRenewView = ({
|
|
@@ -56570,6 +56823,7 @@ const OrderCreateContainer = props => /*#__PURE__*/React__default['default'].cre
|
|
|
56570
56823
|
const OrderCreateModal = ({
|
|
56571
56824
|
onDisplay,
|
|
56572
56825
|
onClose,
|
|
56826
|
+
showExternalPaymentMethods = false,
|
|
56573
56827
|
...otherProps
|
|
56574
56828
|
}) => {
|
|
56575
56829
|
const {
|
|
@@ -56623,7 +56877,8 @@ const OrderCreateModal = ({
|
|
|
56623
56877
|
}, /*#__PURE__*/React__default['default'].createElement(SvgArrowLeft, null)), /*#__PURE__*/React__default['default'].createElement("h4", {
|
|
56624
56878
|
className: "plc-text-xl plc-font-bold plc-text-center"
|
|
56625
56879
|
}, t("labels.checkout.title")))), /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(OrderCreateView, Object.assign({}, otherProps, {
|
|
56626
|
-
onSuccess: onSuccess
|
|
56880
|
+
onSuccess: onSuccess,
|
|
56881
|
+
showExternalPaymentMethods: showExternalPaymentMethods
|
|
56627
56882
|
}))), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null));
|
|
56628
56883
|
};
|
|
56629
56884
|
OrderCreateModal.viewId = "order-create";
|
package/dist/index.esm.js
CHANGED
|
@@ -46386,7 +46386,10 @@ axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormDat
|
|
|
46386
46386
|
|
|
46387
46387
|
axios.default = axios;
|
|
46388
46388
|
|
|
46389
|
-
const OrderCreateView =
|
|
46389
|
+
const OrderCreateView = ({
|
|
46390
|
+
showExternalPaymentMethods = false,
|
|
46391
|
+
...props
|
|
46392
|
+
}) => {
|
|
46390
46393
|
var _window$Pelcro, _window$Pelcro$uiSett, _window$Pelcro$user$r, _window, _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro$user$r2, _window2, _window2$Pelcro, _window2$Pelcro$user, _addresses$find, _addresses$find2;
|
|
46391
46394
|
const {
|
|
46392
46395
|
t
|
|
@@ -46475,7 +46478,7 @@ const OrderCreateView = props => {
|
|
|
46475
46478
|
}, address === null || address === void 0 ? void 0 : address.phone))), /*#__PURE__*/React__default.createElement(PaymentMethodView, Object.assign({
|
|
46476
46479
|
type: "orderCreate",
|
|
46477
46480
|
showCoupon: true,
|
|
46478
|
-
showExternalPaymentMethods:
|
|
46481
|
+
showExternalPaymentMethods: showExternalPaymentMethods,
|
|
46479
46482
|
showApplePayButton: true,
|
|
46480
46483
|
showOrderButton: showOrderButton,
|
|
46481
46484
|
order: order,
|
|
@@ -49244,57 +49247,306 @@ function YearSelect({
|
|
|
49244
49247
|
}, placeholder), createYearsItems);
|
|
49245
49248
|
}
|
|
49246
49249
|
|
|
49247
|
-
const PelcroPaymentRequestButton =
|
|
49250
|
+
const PelcroPaymentRequestButton = ({
|
|
49251
|
+
type,
|
|
49252
|
+
onSuccess,
|
|
49253
|
+
onFailure,
|
|
49254
|
+
...props
|
|
49255
|
+
}) => {
|
|
49256
|
+
const stripe = useStripe();
|
|
49257
|
+
const [isInitializing, setIsInitializing] = useState(true);
|
|
49258
|
+
const [localPaymentRequest, setLocalPaymentRequest] = useState(null);
|
|
49248
49259
|
const {
|
|
49249
|
-
state
|
|
49250
|
-
|
|
49251
|
-
paymentRequest,
|
|
49252
|
-
currentPlan,
|
|
49253
|
-
updatedPrice
|
|
49254
|
-
}
|
|
49260
|
+
state,
|
|
49261
|
+
dispatch
|
|
49255
49262
|
} = useContext(store$m);
|
|
49256
|
-
const
|
|
49257
|
-
|
|
49258
|
-
|
|
49259
|
-
|
|
49260
|
-
|
|
49261
|
-
|
|
49263
|
+
const {
|
|
49264
|
+
canMakePayment,
|
|
49265
|
+
currentPlan,
|
|
49266
|
+
updatedPrice
|
|
49267
|
+
} = state;
|
|
49268
|
+
const {
|
|
49269
|
+
order,
|
|
49270
|
+
set,
|
|
49271
|
+
selectedPaymentMethodId
|
|
49272
|
+
} = usePelcro();
|
|
49273
|
+
const getOrderInfo = () => {
|
|
49274
|
+
if (!order) {
|
|
49275
|
+
return {
|
|
49276
|
+
price: null,
|
|
49277
|
+
currency: null,
|
|
49278
|
+
label: null
|
|
49279
|
+
};
|
|
49280
|
+
}
|
|
49281
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
49282
|
+
if (isQuickPurchase) {
|
|
49283
|
+
return {
|
|
49284
|
+
price: order.price * order.quantity,
|
|
49285
|
+
currency: order.currency,
|
|
49286
|
+
label: order.name
|
|
49287
|
+
};
|
|
49288
|
+
}
|
|
49289
|
+
if (order.length === 0) {
|
|
49290
|
+
return {
|
|
49291
|
+
price: null,
|
|
49292
|
+
currency: null,
|
|
49293
|
+
label: null
|
|
49294
|
+
};
|
|
49295
|
+
}
|
|
49296
|
+
const price = order.reduce((total, item) => total + item.price * item.quantity, 0);
|
|
49297
|
+
return {
|
|
49298
|
+
price,
|
|
49299
|
+
currency: order[0].currency,
|
|
49300
|
+
label: "Order"
|
|
49301
|
+
};
|
|
49302
|
+
};
|
|
49303
|
+
const orderPrice = getOrderInfo().price;
|
|
49304
|
+
const orderCurrency = getOrderInfo().currency;
|
|
49305
|
+
const orderLabel = getOrderInfo().label;
|
|
49306
|
+
const purchase = (gatewayService, gatewayToken, state, dispatch) => {
|
|
49307
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
49308
|
+
const mappedOrderItems = isQuickPurchase ? [{
|
|
49309
|
+
sku_id: order.id,
|
|
49310
|
+
quantity: order.quantity
|
|
49311
|
+
}] : order.map(item => ({
|
|
49312
|
+
sku_id: item.id,
|
|
49313
|
+
quantity: item.quantity
|
|
49314
|
+
}));
|
|
49315
|
+
const {
|
|
49316
|
+
couponCode
|
|
49317
|
+
} = state;
|
|
49318
|
+
const payment = new Payment(gatewayService);
|
|
49319
|
+
payment.execute({
|
|
49320
|
+
type: PAYMENT_TYPES.PURCHASE_ECOMMERCE_ORDER,
|
|
49321
|
+
token: gatewayToken,
|
|
49322
|
+
isExistingSource: Boolean(selectedPaymentMethodId),
|
|
49323
|
+
items: mappedOrderItems,
|
|
49324
|
+
addressId: state.selectedAddressId,
|
|
49325
|
+
couponCode
|
|
49326
|
+
}, (err, orderResponse) => {
|
|
49327
|
+
var _window$Pelcro, _window$Pelcro$user, _window$Pelcro$user$r;
|
|
49328
|
+
if (err) {
|
|
49329
|
+
toggleAuthenticationSuccessPendingView(false);
|
|
49330
|
+
dispatch({
|
|
49331
|
+
type: DISABLE_SUBMIT,
|
|
49332
|
+
payload: false
|
|
49333
|
+
});
|
|
49334
|
+
dispatch({
|
|
49335
|
+
type: LOADING,
|
|
49336
|
+
payload: false
|
|
49337
|
+
});
|
|
49338
|
+
onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
|
|
49339
|
+
return dispatch({
|
|
49340
|
+
type: SHOW_ALERT,
|
|
49341
|
+
payload: {
|
|
49342
|
+
type: "error",
|
|
49343
|
+
content: getErrorMessages(err)
|
|
49344
|
+
}
|
|
49345
|
+
});
|
|
49346
|
+
}
|
|
49347
|
+
if (isQuickPurchase) {
|
|
49348
|
+
set({
|
|
49349
|
+
order: null
|
|
49350
|
+
});
|
|
49351
|
+
} else {
|
|
49352
|
+
set({
|
|
49353
|
+
order: null,
|
|
49354
|
+
cartItems: []
|
|
49355
|
+
});
|
|
49262
49356
|
}
|
|
49357
|
+
window.Pelcro.user.refresh({
|
|
49358
|
+
auth_token: (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$user = _window$Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : (_window$Pelcro$user$r = _window$Pelcro$user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : _window$Pelcro$user$r.auth_token
|
|
49359
|
+
}, (err, res) => {
|
|
49360
|
+
dispatch({
|
|
49361
|
+
type: DISABLE_SUBMIT,
|
|
49362
|
+
payload: false
|
|
49363
|
+
});
|
|
49364
|
+
dispatch({
|
|
49365
|
+
type: LOADING,
|
|
49366
|
+
payload: false
|
|
49367
|
+
});
|
|
49368
|
+
toggleAuthenticationSuccessPendingView(false);
|
|
49369
|
+
if (err) {
|
|
49370
|
+
onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
|
|
49371
|
+
return dispatch({
|
|
49372
|
+
type: SHOW_ALERT,
|
|
49373
|
+
payload: {
|
|
49374
|
+
type: "error",
|
|
49375
|
+
content: getErrorMessages(err)
|
|
49376
|
+
}
|
|
49377
|
+
});
|
|
49378
|
+
}
|
|
49379
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(orderResponse);
|
|
49380
|
+
});
|
|
49263
49381
|
});
|
|
49264
49382
|
};
|
|
49265
|
-
|
|
49266
|
-
|
|
49267
|
-
|
|
49268
|
-
|
|
49269
|
-
|
|
49383
|
+
useEffect(() => {
|
|
49384
|
+
if (!stripe) {
|
|
49385
|
+
setIsInitializing(false);
|
|
49386
|
+
return;
|
|
49387
|
+
}
|
|
49388
|
+
let mounted = true;
|
|
49389
|
+
const initializePaymentRequest = async () => {
|
|
49390
|
+
try {
|
|
49391
|
+
var _ref;
|
|
49392
|
+
const pr = stripe.paymentRequest({
|
|
49393
|
+
country: window.Pelcro.user.location.countryCode || "US",
|
|
49394
|
+
currency: ((currentPlan === null || currentPlan === void 0 ? void 0 : currentPlan.currency) || orderCurrency).toLowerCase(),
|
|
49395
|
+
total: {
|
|
49396
|
+
label: (currentPlan === null || currentPlan === void 0 ? void 0 : currentPlan.nickname) || (currentPlan === null || currentPlan === void 0 ? void 0 : currentPlan.description) || orderLabel || "Payment",
|
|
49397
|
+
amount: (_ref = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : currentPlan === null || currentPlan === void 0 ? void 0 : currentPlan.amount) !== null && _ref !== void 0 ? _ref : orderPrice,
|
|
49398
|
+
pending: false
|
|
49399
|
+
},
|
|
49400
|
+
requestPayerEmail: false,
|
|
49401
|
+
requestPayerName: false,
|
|
49402
|
+
requestShipping: false
|
|
49403
|
+
});
|
|
49404
|
+
pr.on("source", async event => {
|
|
49405
|
+
try {
|
|
49406
|
+
var _event$source, _event$source$card;
|
|
49407
|
+
dispatch({
|
|
49408
|
+
type: DISABLE_COUPON_BUTTON,
|
|
49409
|
+
payload: true
|
|
49410
|
+
});
|
|
49411
|
+
dispatch({
|
|
49412
|
+
type: DISABLE_SUBMIT,
|
|
49413
|
+
payload: true
|
|
49414
|
+
});
|
|
49415
|
+
dispatch({
|
|
49416
|
+
type: LOADING,
|
|
49417
|
+
payload: true
|
|
49418
|
+
});
|
|
49419
|
+
event.complete("success");
|
|
49420
|
+
if (((_event$source = event.source) === null || _event$source === void 0 ? void 0 : (_event$source$card = _event$source.card) === null || _event$source$card === void 0 ? void 0 : _event$source$card.three_d_secure) === "required") {
|
|
49421
|
+
return generate3DSecureSource(event.source).then(({
|
|
49422
|
+
source,
|
|
49423
|
+
error
|
|
49424
|
+
}) => {
|
|
49425
|
+
if (error) {
|
|
49426
|
+
return handlePaymentError(error);
|
|
49427
|
+
}
|
|
49428
|
+
toggleAuthenticationPendingView(true, source);
|
|
49429
|
+
});
|
|
49430
|
+
}
|
|
49431
|
+
|
|
49432
|
+
// Handle different payment types
|
|
49433
|
+
if (type === "orderCreate") {
|
|
49434
|
+
purchase(new StripeGateway(), event.source.id, state, dispatch);
|
|
49435
|
+
} else {
|
|
49436
|
+
dispatch({
|
|
49437
|
+
type: SUBSCRIBE,
|
|
49438
|
+
payload: {
|
|
49439
|
+
id: event.source.id,
|
|
49440
|
+
isExistingSource: false
|
|
49441
|
+
}
|
|
49442
|
+
});
|
|
49443
|
+
}
|
|
49444
|
+
} catch (error) {
|
|
49445
|
+
dispatch({
|
|
49446
|
+
type: SHOW_ALERT,
|
|
49447
|
+
payload: {
|
|
49448
|
+
type: "error",
|
|
49449
|
+
content: error.message || "Payment failed. Please try again."
|
|
49450
|
+
}
|
|
49451
|
+
});
|
|
49452
|
+
event.complete("fail");
|
|
49453
|
+
dispatch({
|
|
49454
|
+
type: DISABLE_COUPON_BUTTON,
|
|
49455
|
+
payload: false
|
|
49456
|
+
});
|
|
49457
|
+
dispatch({
|
|
49458
|
+
type: DISABLE_SUBMIT,
|
|
49459
|
+
payload: false
|
|
49460
|
+
});
|
|
49461
|
+
dispatch({
|
|
49462
|
+
type: LOADING,
|
|
49463
|
+
payload: false
|
|
49464
|
+
});
|
|
49465
|
+
}
|
|
49466
|
+
});
|
|
49467
|
+
pr.on("cancel", () => {
|
|
49468
|
+
dispatch({
|
|
49469
|
+
type: DISABLE_COUPON_BUTTON,
|
|
49470
|
+
payload: false
|
|
49471
|
+
});
|
|
49472
|
+
dispatch({
|
|
49473
|
+
type: DISABLE_SUBMIT,
|
|
49474
|
+
payload: false
|
|
49475
|
+
});
|
|
49476
|
+
dispatch({
|
|
49477
|
+
type: LOADING,
|
|
49478
|
+
payload: false
|
|
49479
|
+
});
|
|
49480
|
+
});
|
|
49481
|
+
const result = await pr.canMakePayment();
|
|
49482
|
+
if (mounted && result) {
|
|
49483
|
+
setLocalPaymentRequest(pr);
|
|
49484
|
+
dispatch({
|
|
49485
|
+
type: SET_PAYMENT_REQUEST,
|
|
49486
|
+
payload: pr
|
|
49487
|
+
});
|
|
49488
|
+
dispatch({
|
|
49489
|
+
type: SET_CAN_MAKE_PAYMENT,
|
|
49490
|
+
payload: true
|
|
49491
|
+
});
|
|
49492
|
+
} else if (mounted) {
|
|
49493
|
+
dispatch({
|
|
49494
|
+
type: SET_CAN_MAKE_PAYMENT,
|
|
49495
|
+
payload: false
|
|
49496
|
+
});
|
|
49497
|
+
}
|
|
49498
|
+
} catch (error) {
|
|
49499
|
+
if (mounted) {
|
|
49500
|
+
dispatch({
|
|
49501
|
+
type: SET_CAN_MAKE_PAYMENT,
|
|
49502
|
+
payload: false
|
|
49503
|
+
});
|
|
49504
|
+
}
|
|
49505
|
+
} finally {
|
|
49506
|
+
if (mounted) {
|
|
49507
|
+
setIsInitializing(false);
|
|
49508
|
+
}
|
|
49509
|
+
}
|
|
49510
|
+
};
|
|
49511
|
+
initializePaymentRequest();
|
|
49512
|
+
return () => {
|
|
49513
|
+
mounted = false;
|
|
49514
|
+
};
|
|
49515
|
+
}, [stripe, currentPlan, updatedPrice, dispatch, order, type]);
|
|
49516
|
+
if (isInitializing || !canMakePayment || !localPaymentRequest) {
|
|
49517
|
+
return null;
|
|
49518
|
+
}
|
|
49519
|
+
return /*#__PURE__*/React__default.createElement(PaymentRequestButtonElement, Object.assign({
|
|
49520
|
+
className: "StripeElement stripe-payment-request-btn",
|
|
49521
|
+
options: {
|
|
49522
|
+
paymentRequest: localPaymentRequest,
|
|
49270
49523
|
style: {
|
|
49271
49524
|
paymentRequestButton: {
|
|
49272
49525
|
theme: "dark",
|
|
49273
|
-
height: "40px"
|
|
49526
|
+
height: "40px",
|
|
49527
|
+
buttonType: "plain"
|
|
49274
49528
|
}
|
|
49275
49529
|
}
|
|
49276
|
-
}
|
|
49277
|
-
}
|
|
49278
|
-
return null;
|
|
49530
|
+
}
|
|
49531
|
+
}, props));
|
|
49279
49532
|
};
|
|
49280
49533
|
const CheckoutForm = ({
|
|
49281
49534
|
type
|
|
49282
49535
|
}) => {
|
|
49283
|
-
var _window, _window$
|
|
49536
|
+
var _window, _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$, _window2, _window2$Pelcro, _window2$Pelcro$user, _window2$Pelcro$user$, _window3, _window3$Pelcro, _window3$Pelcro$user, _window3$Pelcro$user$;
|
|
49284
49537
|
const {
|
|
49285
49538
|
selectedPaymentMethodId,
|
|
49286
49539
|
paymentMethodToEdit
|
|
49287
49540
|
} = usePelcro();
|
|
49288
49541
|
const cardProcessor = getSiteCardProcessor();
|
|
49289
49542
|
const billingDetails = {
|
|
49290
|
-
name: (_window = window) === null || _window === void 0 ? void 0 : (_window$
|
|
49543
|
+
name: (_window = window) === null || _window === void 0 ? void 0 : (_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$.name,
|
|
49291
49544
|
email: (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$Pelcro = _window2.Pelcro) === null || _window2$Pelcro === void 0 ? void 0 : (_window2$Pelcro$user = _window2$Pelcro.user) === null || _window2$Pelcro$user === void 0 ? void 0 : (_window2$Pelcro$user$ = _window2$Pelcro$user.read()) === null || _window2$Pelcro$user$ === void 0 ? void 0 : _window2$Pelcro$user$.email,
|
|
49292
49545
|
phone: (_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$Pelcro = _window3.Pelcro) === null || _window3$Pelcro === void 0 ? void 0 : (_window3$Pelcro$user = _window3$Pelcro.user) === null || _window3$Pelcro$user === void 0 ? void 0 : (_window3$Pelcro$user$ = _window3$Pelcro$user.read()) === null || _window3$Pelcro$user$ === void 0 ? void 0 : _window3$Pelcro$user$.phone
|
|
49293
49546
|
};
|
|
49294
49547
|
const paymentElementOptions = {
|
|
49295
49548
|
layout: {
|
|
49296
49549
|
type: "tabs",
|
|
49297
|
-
// or accordion
|
|
49298
49550
|
defaultCollapsed: false
|
|
49299
49551
|
},
|
|
49300
49552
|
defaultValues: {
|
|
@@ -49308,11 +49560,8 @@ const CheckoutForm = ({
|
|
|
49308
49560
|
address: "never"
|
|
49309
49561
|
}
|
|
49310
49562
|
},
|
|
49311
|
-
|
|
49312
|
-
applePay: "never"
|
|
49313
|
-
card: "never",
|
|
49314
|
-
googlePay: "never",
|
|
49315
|
-
paypal: "never"
|
|
49563
|
+
wallets: {
|
|
49564
|
+
applePay: "never"
|
|
49316
49565
|
}
|
|
49317
49566
|
};
|
|
49318
49567
|
if (selectedPaymentMethodId) {
|
|
@@ -50685,7 +50934,11 @@ function PaymentMethodView({
|
|
|
50685
50934
|
className: "plc-grid plc-mt-4 plc-gap-y-2"
|
|
50686
50935
|
}, /*#__PURE__*/React__default.createElement(SubmitPaymentMethod, {
|
|
50687
50936
|
isSubmitDisabled: isSubmitDisabled
|
|
50688
|
-
}), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PelcroPaymentRequestButton,
|
|
50937
|
+
}), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PelcroPaymentRequestButton, {
|
|
50938
|
+
type: type,
|
|
50939
|
+
onSuccess: onSuccess,
|
|
50940
|
+
onFailure: onFailure
|
|
50941
|
+
}), /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : null, showApplePayButton && supportsVantiv ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ApplePayButton, null)) : null)))));
|
|
50689
50942
|
}
|
|
50690
50943
|
|
|
50691
50944
|
const SubscriptionRenewView = ({
|
|
@@ -56528,6 +56781,7 @@ const OrderCreateContainer = props => /*#__PURE__*/React__default.createElement(
|
|
|
56528
56781
|
const OrderCreateModal = ({
|
|
56529
56782
|
onDisplay,
|
|
56530
56783
|
onClose,
|
|
56784
|
+
showExternalPaymentMethods = false,
|
|
56531
56785
|
...otherProps
|
|
56532
56786
|
}) => {
|
|
56533
56787
|
const {
|
|
@@ -56581,7 +56835,8 @@ const OrderCreateModal = ({
|
|
|
56581
56835
|
}, /*#__PURE__*/React__default.createElement(SvgArrowLeft, null)), /*#__PURE__*/React__default.createElement("h4", {
|
|
56582
56836
|
className: "plc-text-xl plc-font-bold plc-text-center"
|
|
56583
56837
|
}, t("labels.checkout.title")))), /*#__PURE__*/React__default.createElement(ModalBody, null, /*#__PURE__*/React__default.createElement(OrderCreateView, Object.assign({}, otherProps, {
|
|
56584
|
-
onSuccess: onSuccess
|
|
56838
|
+
onSuccess: onSuccess,
|
|
56839
|
+
showExternalPaymentMethods: showExternalPaymentMethods
|
|
56585
56840
|
}))), /*#__PURE__*/React__default.createElement(ModalFooter, null));
|
|
56586
56841
|
};
|
|
56587
56842
|
OrderCreateModal.viewId = "order-create";
|