@pelcro/react-pelcro-js 3.26.0-beta.16 → 3.26.0-beta.18
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 +38 -14
- package/dist/index.esm.js +38 -14
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -21189,7 +21189,7 @@ const DonationEmail = props => /*#__PURE__*/React__default['default'].createElem
|
|
|
21189
21189
|
* @return {JSX}
|
|
21190
21190
|
*/
|
|
21191
21191
|
const ApplePayButton = _ref => {
|
|
21192
|
-
var _window$Pelcro$site$r
|
|
21192
|
+
var _window$Pelcro$site$r;
|
|
21193
21193
|
let {
|
|
21194
21194
|
onClick,
|
|
21195
21195
|
props,
|
|
@@ -21210,24 +21210,39 @@ const ApplePayButton = _ref => {
|
|
|
21210
21210
|
apple_pay_merchant_id: ApplePayMerchantId,
|
|
21211
21211
|
apple_pay_enabled: ApplePayEnabled
|
|
21212
21212
|
} = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings;
|
|
21213
|
-
const
|
|
21213
|
+
const getOrderInfo = () => {
|
|
21214
21214
|
if (!order) {
|
|
21215
|
-
return
|
|
21215
|
+
return {
|
|
21216
|
+
price: null,
|
|
21217
|
+
currency: null,
|
|
21218
|
+
label: null
|
|
21219
|
+
};
|
|
21216
21220
|
}
|
|
21217
21221
|
const isQuickPurchase = !Array.isArray(order);
|
|
21218
21222
|
if (isQuickPurchase) {
|
|
21219
|
-
return
|
|
21223
|
+
return {
|
|
21224
|
+
price: order.price * order.quantity,
|
|
21225
|
+
currency: order.currency,
|
|
21226
|
+
label: order.name
|
|
21227
|
+
};
|
|
21220
21228
|
}
|
|
21221
21229
|
if (order.length === 0) {
|
|
21222
|
-
return
|
|
21230
|
+
return {
|
|
21231
|
+
price: null,
|
|
21232
|
+
currency: null,
|
|
21233
|
+
label: null
|
|
21234
|
+
};
|
|
21223
21235
|
}
|
|
21224
|
-
|
|
21225
|
-
|
|
21226
|
-
|
|
21236
|
+
const price = order.reduce((total, item) => total + item.price * item.quantity, 0);
|
|
21237
|
+
return {
|
|
21238
|
+
price,
|
|
21239
|
+
currency: order[0].currency,
|
|
21240
|
+
label: "Order"
|
|
21241
|
+
};
|
|
21227
21242
|
};
|
|
21228
|
-
const orderPrice =
|
|
21229
|
-
const orderCurrency =
|
|
21230
|
-
const orderLabel =
|
|
21243
|
+
const orderPrice = getOrderInfo().price;
|
|
21244
|
+
const orderCurrency = getOrderInfo().currency;
|
|
21245
|
+
const orderLabel = getOrderInfo().label;
|
|
21231
21246
|
React.useEffect(() => {
|
|
21232
21247
|
if (window.ApplePaySession) {
|
|
21233
21248
|
// Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
|
|
@@ -21255,7 +21270,15 @@ const ApplePayButton = _ref => {
|
|
|
21255
21270
|
return;
|
|
21256
21271
|
}
|
|
21257
21272
|
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;
|
|
21258
|
-
|
|
21273
|
+
const getCurrencyCode = () => {
|
|
21274
|
+
if (plan) {
|
|
21275
|
+
return plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase();
|
|
21276
|
+
} else if (order) {
|
|
21277
|
+
return orderCurrency.toUpperCase();
|
|
21278
|
+
} else if (invoice) {
|
|
21279
|
+
return invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase();
|
|
21280
|
+
}
|
|
21281
|
+
};
|
|
21259
21282
|
dispatch({
|
|
21260
21283
|
type: DISABLE_SUBMIT,
|
|
21261
21284
|
payload: true
|
|
@@ -21265,7 +21288,7 @@ const ApplePayButton = _ref => {
|
|
|
21265
21288
|
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/creating_an_apple_pay_session
|
|
21266
21289
|
const ApplePayPaymentRequest = {
|
|
21267
21290
|
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",
|
|
21268
|
-
currencyCode: (
|
|
21291
|
+
currencyCode: getCurrencyCode(),
|
|
21269
21292
|
merchantCapabilities: ["supports3DS"],
|
|
21270
21293
|
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
21271
21294
|
total: {
|
|
@@ -21411,7 +21434,8 @@ const ApplePayButton = _ref => {
|
|
|
21411
21434
|
const vantivPaymentRequest = {
|
|
21412
21435
|
...vantivResponse,
|
|
21413
21436
|
expMonth: expMonth,
|
|
21414
|
-
expYear: expYear
|
|
21437
|
+
expYear: expYear,
|
|
21438
|
+
applePay: true
|
|
21415
21439
|
};
|
|
21416
21440
|
|
|
21417
21441
|
// Process the registrationId or continue with further payment processing.
|
package/dist/index.esm.js
CHANGED
|
@@ -21159,7 +21159,7 @@ const DonationEmail = props => /*#__PURE__*/React__default.createElement(Email,
|
|
|
21159
21159
|
* @return {JSX}
|
|
21160
21160
|
*/
|
|
21161
21161
|
const ApplePayButton = _ref => {
|
|
21162
|
-
var _window$Pelcro$site$r
|
|
21162
|
+
var _window$Pelcro$site$r;
|
|
21163
21163
|
let {
|
|
21164
21164
|
onClick,
|
|
21165
21165
|
props,
|
|
@@ -21180,24 +21180,39 @@ const ApplePayButton = _ref => {
|
|
|
21180
21180
|
apple_pay_merchant_id: ApplePayMerchantId,
|
|
21181
21181
|
apple_pay_enabled: ApplePayEnabled
|
|
21182
21182
|
} = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings;
|
|
21183
|
-
const
|
|
21183
|
+
const getOrderInfo = () => {
|
|
21184
21184
|
if (!order) {
|
|
21185
|
-
return
|
|
21185
|
+
return {
|
|
21186
|
+
price: null,
|
|
21187
|
+
currency: null,
|
|
21188
|
+
label: null
|
|
21189
|
+
};
|
|
21186
21190
|
}
|
|
21187
21191
|
const isQuickPurchase = !Array.isArray(order);
|
|
21188
21192
|
if (isQuickPurchase) {
|
|
21189
|
-
return
|
|
21193
|
+
return {
|
|
21194
|
+
price: order.price * order.quantity,
|
|
21195
|
+
currency: order.currency,
|
|
21196
|
+
label: order.name
|
|
21197
|
+
};
|
|
21190
21198
|
}
|
|
21191
21199
|
if (order.length === 0) {
|
|
21192
|
-
return
|
|
21200
|
+
return {
|
|
21201
|
+
price: null,
|
|
21202
|
+
currency: null,
|
|
21203
|
+
label: null
|
|
21204
|
+
};
|
|
21193
21205
|
}
|
|
21194
|
-
|
|
21195
|
-
|
|
21196
|
-
|
|
21206
|
+
const price = order.reduce((total, item) => total + item.price * item.quantity, 0);
|
|
21207
|
+
return {
|
|
21208
|
+
price,
|
|
21209
|
+
currency: order[0].currency,
|
|
21210
|
+
label: "Order"
|
|
21211
|
+
};
|
|
21197
21212
|
};
|
|
21198
|
-
const orderPrice =
|
|
21199
|
-
const orderCurrency =
|
|
21200
|
-
const orderLabel =
|
|
21213
|
+
const orderPrice = getOrderInfo().price;
|
|
21214
|
+
const orderCurrency = getOrderInfo().currency;
|
|
21215
|
+
const orderLabel = getOrderInfo().label;
|
|
21201
21216
|
useEffect(() => {
|
|
21202
21217
|
if (window.ApplePaySession) {
|
|
21203
21218
|
// Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
|
|
@@ -21225,7 +21240,15 @@ const ApplePayButton = _ref => {
|
|
|
21225
21240
|
return;
|
|
21226
21241
|
}
|
|
21227
21242
|
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;
|
|
21228
|
-
|
|
21243
|
+
const getCurrencyCode = () => {
|
|
21244
|
+
if (plan) {
|
|
21245
|
+
return plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase();
|
|
21246
|
+
} else if (order) {
|
|
21247
|
+
return orderCurrency.toUpperCase();
|
|
21248
|
+
} else if (invoice) {
|
|
21249
|
+
return invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase();
|
|
21250
|
+
}
|
|
21251
|
+
};
|
|
21229
21252
|
dispatch({
|
|
21230
21253
|
type: DISABLE_SUBMIT,
|
|
21231
21254
|
payload: true
|
|
@@ -21235,7 +21258,7 @@ const ApplePayButton = _ref => {
|
|
|
21235
21258
|
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/creating_an_apple_pay_session
|
|
21236
21259
|
const ApplePayPaymentRequest = {
|
|
21237
21260
|
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",
|
|
21238
|
-
currencyCode: (
|
|
21261
|
+
currencyCode: getCurrencyCode(),
|
|
21239
21262
|
merchantCapabilities: ["supports3DS"],
|
|
21240
21263
|
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
21241
21264
|
total: {
|
|
@@ -21381,7 +21404,8 @@ const ApplePayButton = _ref => {
|
|
|
21381
21404
|
const vantivPaymentRequest = {
|
|
21382
21405
|
...vantivResponse,
|
|
21383
21406
|
expMonth: expMonth,
|
|
21384
|
-
expYear: expYear
|
|
21407
|
+
expYear: expYear,
|
|
21408
|
+
applePay: true
|
|
21385
21409
|
};
|
|
21386
21410
|
|
|
21387
21411
|
// Process the registrationId or continue with further payment processing.
|