@pelcro/react-pelcro-js 3.26.0-beta.12 → 3.26.0-beta.14
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 +23 -19
- package/dist/index.esm.js +23 -19
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -9518,17 +9518,6 @@ 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
|
-
|
|
9532
9521
|
/**
|
|
9533
9522
|
* returns true if the URL contains a supported view trigger URL
|
|
9534
9523
|
* @param {string} viewID
|
|
@@ -21202,7 +21191,7 @@ const DonationEmail = props => /*#__PURE__*/React__default['default'].createElem
|
|
|
21202
21191
|
* @return {JSX}
|
|
21203
21192
|
*/
|
|
21204
21193
|
const ApplePayButton = _ref => {
|
|
21205
|
-
var _window$Pelcro$site$r, _order$, _ref2, _ref3, _ref4, _state$updatedPrice, _props$plan;
|
|
21194
|
+
var _window$Pelcro$site$r, _order$, _ref2, _ref3, _ref4, _ref5, _state$updatedPrice, _props$plan;
|
|
21206
21195
|
let {
|
|
21207
21196
|
onClick,
|
|
21208
21197
|
props,
|
|
@@ -21223,10 +21212,25 @@ const ApplePayButton = _ref => {
|
|
|
21223
21212
|
apple_pay_merchant_id: ApplePayMerchantId,
|
|
21224
21213
|
apple_pay_enabled: ApplePayEnabled
|
|
21225
21214
|
} = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings;
|
|
21226
|
-
const
|
|
21215
|
+
const getOrderItemsTotal = () => {
|
|
21216
|
+
if (!order) {
|
|
21217
|
+
return null;
|
|
21218
|
+
}
|
|
21219
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
21220
|
+
if (isQuickPurchase) {
|
|
21221
|
+
return order.price * order.quantity;
|
|
21222
|
+
}
|
|
21223
|
+
if (order.length === 0) {
|
|
21224
|
+
return null;
|
|
21225
|
+
}
|
|
21226
|
+
return order.reduce((total, item) => {
|
|
21227
|
+
return total + item.price * item.quantity;
|
|
21228
|
+
}, 0);
|
|
21229
|
+
};
|
|
21230
|
+
const orderPrice = getOrderItemsTotal();
|
|
21227
21231
|
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
21232
|
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 &&
|
|
21233
|
+
const updatedPrice = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_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 && _ref5 !== void 0 ? _ref5 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref4 !== void 0 ? _ref4 : orderPrice) !== null && _ref3 !== void 0 ? _ref3 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref2 !== void 0 ? _ref2 : null;
|
|
21230
21234
|
React.useEffect(() => {
|
|
21231
21235
|
if (window.ApplePaySession) {
|
|
21232
21236
|
// Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
|
|
@@ -21263,7 +21267,7 @@ const ApplePayButton = _ref => {
|
|
|
21263
21267
|
merchantCapabilities: ["supports3DS"],
|
|
21264
21268
|
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
21265
21269
|
total: {
|
|
21266
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21270
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21267
21271
|
type: "final",
|
|
21268
21272
|
amount: updatedPrice / 100
|
|
21269
21273
|
}
|
|
@@ -21311,12 +21315,12 @@ const ApplePayButton = _ref => {
|
|
|
21311
21315
|
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
21312
21316
|
// No updates or errors are needed, pass an empty object.
|
|
21313
21317
|
const newTotal = {
|
|
21314
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21318
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21315
21319
|
type: "final",
|
|
21316
21320
|
amount: updatedPrice / 100
|
|
21317
21321
|
};
|
|
21318
21322
|
const newLineItems = [{
|
|
21319
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21323
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21320
21324
|
type: "final",
|
|
21321
21325
|
amount: updatedPrice / 100
|
|
21322
21326
|
}];
|
|
@@ -21329,14 +21333,14 @@ const ApplePayButton = _ref => {
|
|
|
21329
21333
|
// // Define ApplePayShippingMethodUpdate based on the selected shipping method.
|
|
21330
21334
|
// // No updates or errors are needed, pass an empty object.
|
|
21331
21335
|
// const newTotal = {
|
|
21332
|
-
// label: plan?.nickname || orderLabel || `invoice #${invoice
|
|
21336
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
21333
21337
|
// type: "final",
|
|
21334
21338
|
// amount: updatedPrice / 100
|
|
21335
21339
|
// };
|
|
21336
21340
|
|
|
21337
21341
|
// const newLineItems = [
|
|
21338
21342
|
// {
|
|
21339
|
-
// label: plan?.nickname || orderLabel || `invoice #${invoice
|
|
21343
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
21340
21344
|
// type: "final",
|
|
21341
21345
|
// amount: updatedPrice / 100
|
|
21342
21346
|
// }
|
package/dist/index.esm.js
CHANGED
|
@@ -9488,17 +9488,6 @@ 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
|
-
|
|
9502
9491
|
/**
|
|
9503
9492
|
* returns true if the URL contains a supported view trigger URL
|
|
9504
9493
|
* @param {string} viewID
|
|
@@ -21172,7 +21161,7 @@ const DonationEmail = props => /*#__PURE__*/React__default.createElement(Email,
|
|
|
21172
21161
|
* @return {JSX}
|
|
21173
21162
|
*/
|
|
21174
21163
|
const ApplePayButton = _ref => {
|
|
21175
|
-
var _window$Pelcro$site$r, _order$, _ref2, _ref3, _ref4, _state$updatedPrice, _props$plan;
|
|
21164
|
+
var _window$Pelcro$site$r, _order$, _ref2, _ref3, _ref4, _ref5, _state$updatedPrice, _props$plan;
|
|
21176
21165
|
let {
|
|
21177
21166
|
onClick,
|
|
21178
21167
|
props,
|
|
@@ -21193,10 +21182,25 @@ const ApplePayButton = _ref => {
|
|
|
21193
21182
|
apple_pay_merchant_id: ApplePayMerchantId,
|
|
21194
21183
|
apple_pay_enabled: ApplePayEnabled
|
|
21195
21184
|
} = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings;
|
|
21196
|
-
const
|
|
21185
|
+
const getOrderItemsTotal = () => {
|
|
21186
|
+
if (!order) {
|
|
21187
|
+
return null;
|
|
21188
|
+
}
|
|
21189
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
21190
|
+
if (isQuickPurchase) {
|
|
21191
|
+
return order.price * order.quantity;
|
|
21192
|
+
}
|
|
21193
|
+
if (order.length === 0) {
|
|
21194
|
+
return null;
|
|
21195
|
+
}
|
|
21196
|
+
return order.reduce((total, item) => {
|
|
21197
|
+
return total + item.price * item.quantity;
|
|
21198
|
+
}, 0);
|
|
21199
|
+
};
|
|
21200
|
+
const orderPrice = getOrderItemsTotal();
|
|
21197
21201
|
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
21202
|
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 &&
|
|
21203
|
+
const updatedPrice = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_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 && _ref5 !== void 0 ? _ref5 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref4 !== void 0 ? _ref4 : orderPrice) !== null && _ref3 !== void 0 ? _ref3 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref2 !== void 0 ? _ref2 : null;
|
|
21200
21204
|
useEffect(() => {
|
|
21201
21205
|
if (window.ApplePaySession) {
|
|
21202
21206
|
// Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
|
|
@@ -21233,7 +21237,7 @@ const ApplePayButton = _ref => {
|
|
|
21233
21237
|
merchantCapabilities: ["supports3DS"],
|
|
21234
21238
|
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
21235
21239
|
total: {
|
|
21236
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21240
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21237
21241
|
type: "final",
|
|
21238
21242
|
amount: updatedPrice / 100
|
|
21239
21243
|
}
|
|
@@ -21281,12 +21285,12 @@ const ApplePayButton = _ref => {
|
|
|
21281
21285
|
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
21282
21286
|
// No updates or errors are needed, pass an empty object.
|
|
21283
21287
|
const newTotal = {
|
|
21284
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21288
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21285
21289
|
type: "final",
|
|
21286
21290
|
amount: updatedPrice / 100
|
|
21287
21291
|
};
|
|
21288
21292
|
const newLineItems = [{
|
|
21289
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice.id}`,
|
|
21293
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21290
21294
|
type: "final",
|
|
21291
21295
|
amount: updatedPrice / 100
|
|
21292
21296
|
}];
|
|
@@ -21299,14 +21303,14 @@ const ApplePayButton = _ref => {
|
|
|
21299
21303
|
// // Define ApplePayShippingMethodUpdate based on the selected shipping method.
|
|
21300
21304
|
// // No updates or errors are needed, pass an empty object.
|
|
21301
21305
|
// const newTotal = {
|
|
21302
|
-
// label: plan?.nickname || orderLabel || `invoice #${invoice
|
|
21306
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
21303
21307
|
// type: "final",
|
|
21304
21308
|
// amount: updatedPrice / 100
|
|
21305
21309
|
// };
|
|
21306
21310
|
|
|
21307
21311
|
// const newLineItems = [
|
|
21308
21312
|
// {
|
|
21309
|
-
// label: plan?.nickname || orderLabel || `invoice #${invoice
|
|
21313
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
21310
21314
|
// type: "final",
|
|
21311
21315
|
// amount: updatedPrice / 100
|
|
21312
21316
|
// }
|