@pelcro/react-pelcro-js 3.26.0-beta.10 → 3.26.0-beta.12
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 +59 -18
- package/dist/index.esm.js +59 -18
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -9518,6 +9518,17 @@ const calcAndFormatItemsTotal = (items, currency) => {
|
|
|
9518
9518
|
return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
|
|
9519
9519
|
};
|
|
9520
9520
|
|
|
9521
|
+
/**
|
|
9522
|
+
* @param {object[]} items
|
|
9523
|
+
* @returns {number} the total order price
|
|
9524
|
+
*/
|
|
9525
|
+
const calcOrderAmount = items => {
|
|
9526
|
+
if (!Array.isArray(items)) return;
|
|
9527
|
+
return items.reduce((prevAmount, item) => {
|
|
9528
|
+
return prevAmount + item.price * item.quantity;
|
|
9529
|
+
}, 0);
|
|
9530
|
+
};
|
|
9531
|
+
|
|
9521
9532
|
/**
|
|
9522
9533
|
* returns true if the URL contains a supported view trigger URL
|
|
9523
9534
|
* @param {string} viewID
|
|
@@ -11899,7 +11910,10 @@ const loadPaymentSDKs = () => {
|
|
|
11899
11910
|
window.Pelcro.helpers.loadSDK("https://code.jquery.com/jquery-3.6.0.slim.min.js", "vantiv-jquery-sdk");
|
|
11900
11911
|
}
|
|
11901
11912
|
window.Pelcro.helpers.loadSDK("https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "vantiv-jquery-sdk");
|
|
11902
|
-
|
|
11913
|
+
const eProtectApi3PreLiveURL = "https://request.eprotect.vantivprelive.com/eProtect/eProtect-api3.js";
|
|
11914
|
+
const eProtectApi3ProductionURL = "https://request.eprotect.vantivcnp.com/eProtect/eProtect-api3.js";
|
|
11915
|
+
const eProtectApi3scriptUrlToUse = window.Pelcro.site.read().vantiv_gateway_settings.environment === "production" ? eProtectApi3ProductionURL : eProtectApi3PreLiveURL;
|
|
11916
|
+
window.Pelcro.helpers.loadSDK(eProtectApi3scriptUrlToUse, "vantiv-eprotect-api");
|
|
11903
11917
|
if (!window.EprotectIframeClient) {
|
|
11904
11918
|
const PRELIVE_URL = "https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js";
|
|
11905
11919
|
const PRODUCTION_URL = "https://request.eprotect.vantivcnp.com/eProtect/js/eProtect-iframe-client3.min.js";
|
|
@@ -18211,7 +18225,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18211
18225
|
} else if (type === "orderCreate") {
|
|
18212
18226
|
purchase(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
|
|
18213
18227
|
} else if (type === "invoicePayment") {
|
|
18214
|
-
payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
|
|
18228
|
+
payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
|
|
18215
18229
|
} else if (type === "updatePaymentSource") {
|
|
18216
18230
|
createNewCybersourceCard();
|
|
18217
18231
|
}
|
|
@@ -18541,7 +18555,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18541
18555
|
} else if (type === "orderCreate") {
|
|
18542
18556
|
purchase(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
|
|
18543
18557
|
} else if (type === "invoicePayment") {
|
|
18544
|
-
payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
|
|
18558
|
+
payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
|
|
18545
18559
|
} else if (type === "updatePaymentSource") {
|
|
18546
18560
|
createNewTapCard();
|
|
18547
18561
|
}
|
|
@@ -18752,7 +18766,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18752
18766
|
} else if (type === "orderCreate") {
|
|
18753
18767
|
purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
|
|
18754
18768
|
} else if (type === "invoicePayment") {
|
|
18755
|
-
payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
|
|
18769
|
+
payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
|
|
18756
18770
|
} else if (type === "updatePaymentSource") {
|
|
18757
18771
|
createNewVantivCard();
|
|
18758
18772
|
}
|
|
@@ -19584,7 +19598,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19584
19598
|
});
|
|
19585
19599
|
});
|
|
19586
19600
|
};
|
|
19587
|
-
const payInvoice = (gatewayService, gatewayToken, dispatch)
|
|
19601
|
+
const payInvoice = function (gatewayService, gatewayToken, dispatch) {
|
|
19602
|
+
let cb = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
19588
19603
|
const payment = new Payment(gatewayService);
|
|
19589
19604
|
return payment.execute({
|
|
19590
19605
|
type: PAYMENT_TYPES.PAY_INVOICE,
|
|
@@ -19592,7 +19607,29 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19592
19607
|
isExistingSource: Boolean(selectedPaymentMethodId),
|
|
19593
19608
|
invoiceId: invoice.id
|
|
19594
19609
|
}, (err, res) => {
|
|
19595
|
-
|
|
19610
|
+
if (cb && typeof cb == "function") {
|
|
19611
|
+
cb(res, err);
|
|
19612
|
+
} else {
|
|
19613
|
+
dispatch({
|
|
19614
|
+
type: DISABLE_SUBMIT,
|
|
19615
|
+
payload: false
|
|
19616
|
+
});
|
|
19617
|
+
dispatch({
|
|
19618
|
+
type: LOADING,
|
|
19619
|
+
payload: false
|
|
19620
|
+
});
|
|
19621
|
+
if (err) {
|
|
19622
|
+
onFailure(err);
|
|
19623
|
+
return dispatch({
|
|
19624
|
+
type: SHOW_ALERT,
|
|
19625
|
+
payload: {
|
|
19626
|
+
type: "error",
|
|
19627
|
+
content: getErrorMessages(err)
|
|
19628
|
+
}
|
|
19629
|
+
});
|
|
19630
|
+
}
|
|
19631
|
+
onSuccess(res);
|
|
19632
|
+
}
|
|
19596
19633
|
});
|
|
19597
19634
|
};
|
|
19598
19635
|
const updatePaymentSource = (state, dispatch) => {
|
|
@@ -19836,7 +19873,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19836
19873
|
} else if (stripeSource && type === "orderCreate") {
|
|
19837
19874
|
purchase(new StripeGateway(), stripeSource.id, state, dispatch);
|
|
19838
19875
|
} else if (stripeSource && type === "invoicePayment") {
|
|
19839
|
-
payInvoice(new StripeGateway(), stripeSource.id);
|
|
19876
|
+
payInvoice(new StripeGateway(), stripeSource.id, dispatch, confirmStripeCardPayment);
|
|
19840
19877
|
}
|
|
19841
19878
|
};
|
|
19842
19879
|
const handlePaymentError = error => {
|
|
@@ -20008,7 +20045,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20008
20045
|
case HANDLE_PAYPAL_SUBSCRIPTION:
|
|
20009
20046
|
return lib_5(state, (state, dispatch) => {
|
|
20010
20047
|
if (type === "invoicePayment") {
|
|
20011
|
-
payInvoice(new PaypalGateway(), action.payload);
|
|
20048
|
+
payInvoice(new PaypalGateway(), action.payload, dispatch);
|
|
20012
20049
|
} else {
|
|
20013
20050
|
handlePaypalSubscription(state, action.payload);
|
|
20014
20051
|
}
|
|
@@ -21165,7 +21202,7 @@ const DonationEmail = props => /*#__PURE__*/React__default['default'].createElem
|
|
|
21165
21202
|
* @return {JSX}
|
|
21166
21203
|
*/
|
|
21167
21204
|
const ApplePayButton = _ref => {
|
|
21168
|
-
var _window$Pelcro$site$r, _ref2, _ref3, _state$updatedPrice, _props$plan;
|
|
21205
|
+
var _window$Pelcro$site$r, _order$, _ref2, _ref3, _ref4, _state$updatedPrice, _props$plan;
|
|
21169
21206
|
let {
|
|
21170
21207
|
onClick,
|
|
21171
21208
|
props,
|
|
@@ -21177,7 +21214,8 @@ const ApplePayButton = _ref => {
|
|
|
21177
21214
|
} = React.useContext(store$k);
|
|
21178
21215
|
const {
|
|
21179
21216
|
plan,
|
|
21180
|
-
invoice
|
|
21217
|
+
invoice,
|
|
21218
|
+
order
|
|
21181
21219
|
} = usePelcro();
|
|
21182
21220
|
const {
|
|
21183
21221
|
pay_page_id: payPageId,
|
|
@@ -21185,7 +21223,10 @@ const ApplePayButton = _ref => {
|
|
|
21185
21223
|
apple_pay_merchant_id: ApplePayMerchantId,
|
|
21186
21224
|
apple_pay_enabled: ApplePayEnabled
|
|
21187
21225
|
} = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings;
|
|
21188
|
-
const
|
|
21226
|
+
const orderPrice = !Array.isArray(order) ? order === null || order === void 0 ? void 0 : order.price : calcOrderAmount(order);
|
|
21227
|
+
const orderCurrency = !Array.isArray(order) ? order === null || order === void 0 ? void 0 : order.currency : (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency;
|
|
21228
|
+
const orderLabel = !Array.isArray(order) ? order === null || order === void 0 ? void 0 : order.name : "Order";
|
|
21229
|
+
const updatedPrice = (_ref2 = (_ref3 = (_ref4 = (_state$updatedPrice = state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : props === null || props === void 0 ? void 0 : (_props$plan = props.plan) === null || _props$plan === void 0 ? void 0 : _props$plan.amount) !== null && _ref4 !== void 0 ? _ref4 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref3 !== void 0 ? _ref3 : orderPrice) !== null && _ref2 !== void 0 ? _ref2 : invoice.amount_remaining;
|
|
21189
21230
|
React.useEffect(() => {
|
|
21190
21231
|
if (window.ApplePaySession) {
|
|
21191
21232
|
// Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
|
|
@@ -21218,11 +21259,11 @@ const ApplePayButton = _ref => {
|
|
|
21218
21259
|
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/creating_an_apple_pay_session
|
|
21219
21260
|
const ApplePayPaymentRequest = {
|
|
21220
21261
|
countryCode: ((_window = window) === null || _window === void 0 ? void 0 : (_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$l = _window$Pelcro$user.location) === null || _window$Pelcro$user$l === void 0 ? void 0 : _window$Pelcro$user$l.countryCode) || "US",
|
|
21221
|
-
currencyCode: (plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase()) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase()),
|
|
21262
|
+
currencyCode: (plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase()) || orderCurrency.toUpperCase() || (invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase()),
|
|
21222
21263
|
merchantCapabilities: ["supports3DS"],
|
|
21223
21264
|
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
21224
21265
|
total: {
|
|
21225
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
21266
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21226
21267
|
type: "final",
|
|
21227
21268
|
amount: updatedPrice / 100
|
|
21228
21269
|
}
|
|
@@ -21270,12 +21311,12 @@ const ApplePayButton = _ref => {
|
|
|
21270
21311
|
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
21271
21312
|
// No updates or errors are needed, pass an empty object.
|
|
21272
21313
|
const newTotal = {
|
|
21273
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
21314
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21274
21315
|
type: "final",
|
|
21275
21316
|
amount: updatedPrice / 100
|
|
21276
21317
|
};
|
|
21277
21318
|
const newLineItems = [{
|
|
21278
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
21319
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21279
21320
|
type: "final",
|
|
21280
21321
|
amount: updatedPrice / 100
|
|
21281
21322
|
}];
|
|
@@ -21288,14 +21329,14 @@ const ApplePayButton = _ref => {
|
|
|
21288
21329
|
// // Define ApplePayShippingMethodUpdate based on the selected shipping method.
|
|
21289
21330
|
// // No updates or errors are needed, pass an empty object.
|
|
21290
21331
|
// const newTotal = {
|
|
21291
|
-
// label: plan?.nickname || `invoice #${invoice.id}`,
|
|
21332
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice.id}`,
|
|
21292
21333
|
// type: "final",
|
|
21293
21334
|
// amount: updatedPrice / 100
|
|
21294
21335
|
// };
|
|
21295
21336
|
|
|
21296
21337
|
// const newLineItems = [
|
|
21297
21338
|
// {
|
|
21298
|
-
// label: plan?.nickname || `invoice #${invoice.id}`,
|
|
21339
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice.id}`,
|
|
21299
21340
|
// type: "final",
|
|
21300
21341
|
// amount: updatedPrice / 100
|
|
21301
21342
|
// }
|
|
@@ -26996,7 +27037,7 @@ const OrderCreateView = props => {
|
|
|
26996
27037
|
type: "orderCreate",
|
|
26997
27038
|
showCoupon: true,
|
|
26998
27039
|
showExternalPaymentMethods: false,
|
|
26999
|
-
showApplePayButton:
|
|
27040
|
+
showApplePayButton: true,
|
|
27000
27041
|
showOrderButton: showOrderButton,
|
|
27001
27042
|
order: order
|
|
27002
27043
|
}, props))));
|
package/dist/index.esm.js
CHANGED
|
@@ -9488,6 +9488,17 @@ const calcAndFormatItemsTotal = (items, currency) => {
|
|
|
9488
9488
|
return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
|
|
9489
9489
|
};
|
|
9490
9490
|
|
|
9491
|
+
/**
|
|
9492
|
+
* @param {object[]} items
|
|
9493
|
+
* @returns {number} the total order price
|
|
9494
|
+
*/
|
|
9495
|
+
const calcOrderAmount = items => {
|
|
9496
|
+
if (!Array.isArray(items)) return;
|
|
9497
|
+
return items.reduce((prevAmount, item) => {
|
|
9498
|
+
return prevAmount + item.price * item.quantity;
|
|
9499
|
+
}, 0);
|
|
9500
|
+
};
|
|
9501
|
+
|
|
9491
9502
|
/**
|
|
9492
9503
|
* returns true if the URL contains a supported view trigger URL
|
|
9493
9504
|
* @param {string} viewID
|
|
@@ -11869,7 +11880,10 @@ const loadPaymentSDKs = () => {
|
|
|
11869
11880
|
window.Pelcro.helpers.loadSDK("https://code.jquery.com/jquery-3.6.0.slim.min.js", "vantiv-jquery-sdk");
|
|
11870
11881
|
}
|
|
11871
11882
|
window.Pelcro.helpers.loadSDK("https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "vantiv-jquery-sdk");
|
|
11872
|
-
|
|
11883
|
+
const eProtectApi3PreLiveURL = "https://request.eprotect.vantivprelive.com/eProtect/eProtect-api3.js";
|
|
11884
|
+
const eProtectApi3ProductionURL = "https://request.eprotect.vantivcnp.com/eProtect/eProtect-api3.js";
|
|
11885
|
+
const eProtectApi3scriptUrlToUse = window.Pelcro.site.read().vantiv_gateway_settings.environment === "production" ? eProtectApi3ProductionURL : eProtectApi3PreLiveURL;
|
|
11886
|
+
window.Pelcro.helpers.loadSDK(eProtectApi3scriptUrlToUse, "vantiv-eprotect-api");
|
|
11873
11887
|
if (!window.EprotectIframeClient) {
|
|
11874
11888
|
const PRELIVE_URL = "https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js";
|
|
11875
11889
|
const PRODUCTION_URL = "https://request.eprotect.vantivcnp.com/eProtect/js/eProtect-iframe-client3.min.js";
|
|
@@ -18181,7 +18195,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18181
18195
|
} else if (type === "orderCreate") {
|
|
18182
18196
|
purchase(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
|
|
18183
18197
|
} else if (type === "invoicePayment") {
|
|
18184
|
-
payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
|
|
18198
|
+
payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
|
|
18185
18199
|
} else if (type === "updatePaymentSource") {
|
|
18186
18200
|
createNewCybersourceCard();
|
|
18187
18201
|
}
|
|
@@ -18511,7 +18525,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18511
18525
|
} else if (type === "orderCreate") {
|
|
18512
18526
|
purchase(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
|
|
18513
18527
|
} else if (type === "invoicePayment") {
|
|
18514
|
-
payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
|
|
18528
|
+
payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
|
|
18515
18529
|
} else if (type === "updatePaymentSource") {
|
|
18516
18530
|
createNewTapCard();
|
|
18517
18531
|
}
|
|
@@ -18722,7 +18736,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18722
18736
|
} else if (type === "orderCreate") {
|
|
18723
18737
|
purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
|
|
18724
18738
|
} else if (type === "invoicePayment") {
|
|
18725
|
-
payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
|
|
18739
|
+
payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
|
|
18726
18740
|
} else if (type === "updatePaymentSource") {
|
|
18727
18741
|
createNewVantivCard();
|
|
18728
18742
|
}
|
|
@@ -19554,7 +19568,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19554
19568
|
});
|
|
19555
19569
|
});
|
|
19556
19570
|
};
|
|
19557
|
-
const payInvoice = (gatewayService, gatewayToken, dispatch)
|
|
19571
|
+
const payInvoice = function (gatewayService, gatewayToken, dispatch) {
|
|
19572
|
+
let cb = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
19558
19573
|
const payment = new Payment(gatewayService);
|
|
19559
19574
|
return payment.execute({
|
|
19560
19575
|
type: PAYMENT_TYPES.PAY_INVOICE,
|
|
@@ -19562,7 +19577,29 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19562
19577
|
isExistingSource: Boolean(selectedPaymentMethodId),
|
|
19563
19578
|
invoiceId: invoice.id
|
|
19564
19579
|
}, (err, res) => {
|
|
19565
|
-
|
|
19580
|
+
if (cb && typeof cb == "function") {
|
|
19581
|
+
cb(res, err);
|
|
19582
|
+
} else {
|
|
19583
|
+
dispatch({
|
|
19584
|
+
type: DISABLE_SUBMIT,
|
|
19585
|
+
payload: false
|
|
19586
|
+
});
|
|
19587
|
+
dispatch({
|
|
19588
|
+
type: LOADING,
|
|
19589
|
+
payload: false
|
|
19590
|
+
});
|
|
19591
|
+
if (err) {
|
|
19592
|
+
onFailure(err);
|
|
19593
|
+
return dispatch({
|
|
19594
|
+
type: SHOW_ALERT,
|
|
19595
|
+
payload: {
|
|
19596
|
+
type: "error",
|
|
19597
|
+
content: getErrorMessages(err)
|
|
19598
|
+
}
|
|
19599
|
+
});
|
|
19600
|
+
}
|
|
19601
|
+
onSuccess(res);
|
|
19602
|
+
}
|
|
19566
19603
|
});
|
|
19567
19604
|
};
|
|
19568
19605
|
const updatePaymentSource = (state, dispatch) => {
|
|
@@ -19806,7 +19843,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19806
19843
|
} else if (stripeSource && type === "orderCreate") {
|
|
19807
19844
|
purchase(new StripeGateway(), stripeSource.id, state, dispatch);
|
|
19808
19845
|
} else if (stripeSource && type === "invoicePayment") {
|
|
19809
|
-
payInvoice(new StripeGateway(), stripeSource.id);
|
|
19846
|
+
payInvoice(new StripeGateway(), stripeSource.id, dispatch, confirmStripeCardPayment);
|
|
19810
19847
|
}
|
|
19811
19848
|
};
|
|
19812
19849
|
const handlePaymentError = error => {
|
|
@@ -19978,7 +20015,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19978
20015
|
case HANDLE_PAYPAL_SUBSCRIPTION:
|
|
19979
20016
|
return lib_5(state, (state, dispatch) => {
|
|
19980
20017
|
if (type === "invoicePayment") {
|
|
19981
|
-
payInvoice(new PaypalGateway(), action.payload);
|
|
20018
|
+
payInvoice(new PaypalGateway(), action.payload, dispatch);
|
|
19982
20019
|
} else {
|
|
19983
20020
|
handlePaypalSubscription(state, action.payload);
|
|
19984
20021
|
}
|
|
@@ -21135,7 +21172,7 @@ const DonationEmail = props => /*#__PURE__*/React__default.createElement(Email,
|
|
|
21135
21172
|
* @return {JSX}
|
|
21136
21173
|
*/
|
|
21137
21174
|
const ApplePayButton = _ref => {
|
|
21138
|
-
var _window$Pelcro$site$r, _ref2, _ref3, _state$updatedPrice, _props$plan;
|
|
21175
|
+
var _window$Pelcro$site$r, _order$, _ref2, _ref3, _ref4, _state$updatedPrice, _props$plan;
|
|
21139
21176
|
let {
|
|
21140
21177
|
onClick,
|
|
21141
21178
|
props,
|
|
@@ -21147,7 +21184,8 @@ const ApplePayButton = _ref => {
|
|
|
21147
21184
|
} = useContext(store$k);
|
|
21148
21185
|
const {
|
|
21149
21186
|
plan,
|
|
21150
|
-
invoice
|
|
21187
|
+
invoice,
|
|
21188
|
+
order
|
|
21151
21189
|
} = usePelcro();
|
|
21152
21190
|
const {
|
|
21153
21191
|
pay_page_id: payPageId,
|
|
@@ -21155,7 +21193,10 @@ const ApplePayButton = _ref => {
|
|
|
21155
21193
|
apple_pay_merchant_id: ApplePayMerchantId,
|
|
21156
21194
|
apple_pay_enabled: ApplePayEnabled
|
|
21157
21195
|
} = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings;
|
|
21158
|
-
const
|
|
21196
|
+
const orderPrice = !Array.isArray(order) ? order === null || order === void 0 ? void 0 : order.price : calcOrderAmount(order);
|
|
21197
|
+
const orderCurrency = !Array.isArray(order) ? order === null || order === void 0 ? void 0 : order.currency : (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency;
|
|
21198
|
+
const orderLabel = !Array.isArray(order) ? order === null || order === void 0 ? void 0 : order.name : "Order";
|
|
21199
|
+
const updatedPrice = (_ref2 = (_ref3 = (_ref4 = (_state$updatedPrice = state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : props === null || props === void 0 ? void 0 : (_props$plan = props.plan) === null || _props$plan === void 0 ? void 0 : _props$plan.amount) !== null && _ref4 !== void 0 ? _ref4 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref3 !== void 0 ? _ref3 : orderPrice) !== null && _ref2 !== void 0 ? _ref2 : invoice.amount_remaining;
|
|
21159
21200
|
useEffect(() => {
|
|
21160
21201
|
if (window.ApplePaySession) {
|
|
21161
21202
|
// Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
|
|
@@ -21188,11 +21229,11 @@ const ApplePayButton = _ref => {
|
|
|
21188
21229
|
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/creating_an_apple_pay_session
|
|
21189
21230
|
const ApplePayPaymentRequest = {
|
|
21190
21231
|
countryCode: ((_window = window) === null || _window === void 0 ? void 0 : (_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$l = _window$Pelcro$user.location) === null || _window$Pelcro$user$l === void 0 ? void 0 : _window$Pelcro$user$l.countryCode) || "US",
|
|
21191
|
-
currencyCode: (plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase()) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase()),
|
|
21232
|
+
currencyCode: (plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase()) || orderCurrency.toUpperCase() || (invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase()),
|
|
21192
21233
|
merchantCapabilities: ["supports3DS"],
|
|
21193
21234
|
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
21194
21235
|
total: {
|
|
21195
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
21236
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21196
21237
|
type: "final",
|
|
21197
21238
|
amount: updatedPrice / 100
|
|
21198
21239
|
}
|
|
@@ -21240,12 +21281,12 @@ const ApplePayButton = _ref => {
|
|
|
21240
21281
|
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
21241
21282
|
// No updates or errors are needed, pass an empty object.
|
|
21242
21283
|
const newTotal = {
|
|
21243
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
21284
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21244
21285
|
type: "final",
|
|
21245
21286
|
amount: updatedPrice / 100
|
|
21246
21287
|
};
|
|
21247
21288
|
const newLineItems = [{
|
|
21248
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
21289
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21249
21290
|
type: "final",
|
|
21250
21291
|
amount: updatedPrice / 100
|
|
21251
21292
|
}];
|
|
@@ -21258,14 +21299,14 @@ const ApplePayButton = _ref => {
|
|
|
21258
21299
|
// // Define ApplePayShippingMethodUpdate based on the selected shipping method.
|
|
21259
21300
|
// // No updates or errors are needed, pass an empty object.
|
|
21260
21301
|
// const newTotal = {
|
|
21261
|
-
// label: plan?.nickname || `invoice #${invoice.id}`,
|
|
21302
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice.id}`,
|
|
21262
21303
|
// type: "final",
|
|
21263
21304
|
// amount: updatedPrice / 100
|
|
21264
21305
|
// };
|
|
21265
21306
|
|
|
21266
21307
|
// const newLineItems = [
|
|
21267
21308
|
// {
|
|
21268
|
-
// label: plan?.nickname || `invoice #${invoice.id}`,
|
|
21309
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice.id}`,
|
|
21269
21310
|
// type: "final",
|
|
21270
21311
|
// amount: updatedPrice / 100
|
|
21271
21312
|
// }
|
|
@@ -26966,7 +27007,7 @@ const OrderCreateView = props => {
|
|
|
26966
27007
|
type: "orderCreate",
|
|
26967
27008
|
showCoupon: true,
|
|
26968
27009
|
showExternalPaymentMethods: false,
|
|
26969
|
-
showApplePayButton:
|
|
27010
|
+
showApplePayButton: true,
|
|
26970
27011
|
showOrderButton: showOrderButton,
|
|
26971
27012
|
order: order
|
|
26972
27013
|
}, props))));
|