@pelcro/react-pelcro-js 3.26.0-beta.14 → 3.26.0-beta.16
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 +221 -212
- package/dist/index.esm.js +221 -213
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -21184,14 +21184,12 @@ const DonationEmail = props => /*#__PURE__*/React__default['default'].createElem
|
|
|
21184
21184
|
store: store$k
|
|
21185
21185
|
}, props));
|
|
21186
21186
|
|
|
21187
|
-
/* eslint-disable no-undef */
|
|
21188
|
-
|
|
21189
21187
|
/**
|
|
21190
21188
|
* ApplePayButton component
|
|
21191
21189
|
* @return {JSX}
|
|
21192
21190
|
*/
|
|
21193
21191
|
const ApplePayButton = _ref => {
|
|
21194
|
-
var _window$Pelcro$site$r, _order
|
|
21192
|
+
var _window$Pelcro$site$r, _order$;
|
|
21195
21193
|
let {
|
|
21196
21194
|
onClick,
|
|
21197
21195
|
props,
|
|
@@ -21230,10 +21228,10 @@ const ApplePayButton = _ref => {
|
|
|
21230
21228
|
const orderPrice = getOrderItemsTotal();
|
|
21231
21229
|
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;
|
|
21232
21230
|
const orderLabel = !Array.isArray(order) ? order === null || order === void 0 ? void 0 : order.name : "Order";
|
|
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;
|
|
21234
21231
|
React.useEffect(() => {
|
|
21235
21232
|
if (window.ApplePaySession) {
|
|
21236
21233
|
// Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
|
|
21234
|
+
// eslint-disable-next-line no-undef
|
|
21237
21235
|
const promise = ApplePaySession.canMakePaymentsWithActiveCard(ApplePayMerchantId);
|
|
21238
21236
|
promise.then(function (canMakePayments) {
|
|
21239
21237
|
if (canMakePayments && ApplePayEnabled) {
|
|
@@ -21249,233 +21247,243 @@ const ApplePayButton = _ref => {
|
|
|
21249
21247
|
console.error("ApplePay is not available on this browser");
|
|
21250
21248
|
}
|
|
21251
21249
|
}, []);
|
|
21252
|
-
|
|
21253
|
-
|
|
21254
|
-
|
|
21255
|
-
|
|
21256
|
-
|
|
21257
|
-
|
|
21258
|
-
type: DISABLE_SUBMIT,
|
|
21259
|
-
payload: true
|
|
21260
|
-
});
|
|
21261
|
-
|
|
21262
|
-
// Define ApplePayPaymentRequest
|
|
21263
|
-
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/creating_an_apple_pay_session
|
|
21264
|
-
const ApplePayPaymentRequest = {
|
|
21265
|
-
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",
|
|
21266
|
-
currencyCode: (plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase()) || orderCurrency.toUpperCase() || (invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase()),
|
|
21267
|
-
merchantCapabilities: ["supports3DS"],
|
|
21268
|
-
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
21269
|
-
total: {
|
|
21270
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21271
|
-
type: "final",
|
|
21272
|
-
amount: updatedPrice / 100
|
|
21250
|
+
React.useEffect(() => {
|
|
21251
|
+
function onApplePayButtonClicked() {
|
|
21252
|
+
var _ref2, _ref3, _ref4, _ref5, _state$updatedPrice, _props$plan, _window, _window$Pelcro, _window$Pelcro$user, _window$Pelcro$user$l;
|
|
21253
|
+
// eslint-disable-next-line no-undef
|
|
21254
|
+
if (!ApplePaySession) {
|
|
21255
|
+
return;
|
|
21273
21256
|
}
|
|
21274
|
-
|
|
21275
|
-
|
|
21276
|
-
|
|
21277
|
-
|
|
21278
|
-
|
|
21279
|
-
|
|
21280
|
-
|
|
21281
|
-
// @todo - Detect whether web browser supports a particular Apple Pay version.
|
|
21282
|
-
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778014-supportsversion
|
|
21257
|
+
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
|
+
console.log(updatedPrice);
|
|
21259
|
+
dispatch({
|
|
21260
|
+
type: DISABLE_SUBMIT,
|
|
21261
|
+
payload: true
|
|
21262
|
+
});
|
|
21283
21263
|
|
|
21284
|
-
|
|
21285
|
-
|
|
21286
|
-
|
|
21287
|
-
|
|
21288
|
-
|
|
21289
|
-
|
|
21290
|
-
|
|
21291
|
-
|
|
21292
|
-
|
|
21293
|
-
|
|
21294
|
-
|
|
21295
|
-
if (err) {
|
|
21296
|
-
// Handle any errors during merchant validation
|
|
21297
|
-
console.error("Merchant validation SDK error: ", err);
|
|
21298
|
-
session.abort();
|
|
21299
|
-
return dispatch({
|
|
21300
|
-
type: SHOW_ALERT,
|
|
21301
|
-
payload: {
|
|
21302
|
-
type: "error",
|
|
21303
|
-
content: getErrorMessages(err)
|
|
21304
|
-
}
|
|
21305
|
-
});
|
|
21264
|
+
// Define ApplePayPaymentRequest
|
|
21265
|
+
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/creating_an_apple_pay_session
|
|
21266
|
+
const ApplePayPaymentRequest = {
|
|
21267
|
+
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: (plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase()) || orderCurrency.toUpperCase() || (invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase()),
|
|
21269
|
+
merchantCapabilities: ["supports3DS"],
|
|
21270
|
+
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
21271
|
+
total: {
|
|
21272
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21273
|
+
type: "final",
|
|
21274
|
+
amount: updatedPrice / 100
|
|
21306
21275
|
}
|
|
21307
|
-
// Complete merchant validation with the merchant session object
|
|
21308
|
-
console.log("Merchant validation SDK response: ", res);
|
|
21309
|
-
const merchantSession = res;
|
|
21310
|
-
session.completeMerchantValidation(merchantSession);
|
|
21311
|
-
});
|
|
21312
|
-
};
|
|
21313
|
-
session.onpaymentmethodselected = event => {
|
|
21314
|
-
console.log("payment method selected step", event);
|
|
21315
|
-
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
21316
|
-
// No updates or errors are needed, pass an empty object.
|
|
21317
|
-
const newTotal = {
|
|
21318
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21319
|
-
type: "final",
|
|
21320
|
-
amount: updatedPrice / 100
|
|
21321
21276
|
};
|
|
21322
|
-
|
|
21323
|
-
|
|
21324
|
-
|
|
21325
|
-
|
|
21326
|
-
|
|
21327
|
-
session.completePaymentMethodSelection(newTotal, newLineItems);
|
|
21328
|
-
};
|
|
21277
|
+
console.log(ApplePayPaymentRequest);
|
|
21278
|
+
// Create ApplePaySession
|
|
21279
|
+
// @todo - Clarify supported version parameter
|
|
21280
|
+
// @odo - Apple Pay demo uses version 6 (https://applepaydemo.apple.com/)
|
|
21281
|
+
const session = new ApplePaySession(3, ApplePayPaymentRequest); // eslint-disable-line no-undef
|
|
21329
21282
|
|
|
21330
|
-
|
|
21331
|
-
|
|
21332
|
-
|
|
21333
|
-
|
|
21334
|
-
|
|
21335
|
-
|
|
21336
|
-
|
|
21337
|
-
|
|
21338
|
-
|
|
21339
|
-
|
|
21340
|
-
|
|
21341
|
-
|
|
21342
|
-
|
|
21343
|
-
|
|
21344
|
-
|
|
21345
|
-
|
|
21346
|
-
|
|
21347
|
-
|
|
21348
|
-
|
|
21349
|
-
|
|
21350
|
-
|
|
21351
|
-
|
|
21352
|
-
|
|
21353
|
-
|
|
21354
|
-
|
|
21355
|
-
|
|
21356
|
-
|
|
21357
|
-
|
|
21358
|
-
|
|
21359
|
-
|
|
21360
|
-
|
|
21361
|
-
console.log("on payment authorized step", event);
|
|
21362
|
-
// Define ApplePayPaymentAuthorizationResult
|
|
21363
|
-
const result = {
|
|
21364
|
-
status: ApplePaySession.STATUS_SUCCESS
|
|
21365
|
-
};
|
|
21366
|
-
const {
|
|
21367
|
-
paymentData
|
|
21368
|
-
} = event.payment.token;
|
|
21369
|
-
const {
|
|
21370
|
-
data,
|
|
21371
|
-
signature,
|
|
21372
|
-
version
|
|
21373
|
-
} = paymentData;
|
|
21374
|
-
const {
|
|
21375
|
-
ephemeralPublicKey,
|
|
21376
|
-
publicKeyHash,
|
|
21377
|
-
transactionId
|
|
21378
|
-
} = paymentData.header;
|
|
21379
|
-
const applePayToken = {
|
|
21380
|
-
data: data,
|
|
21381
|
-
signature: signature,
|
|
21382
|
-
version: version,
|
|
21383
|
-
header: {
|
|
21384
|
-
ephemeralPublicKey: ephemeralPublicKey,
|
|
21385
|
-
publicKeyHash: publicKeyHash,
|
|
21386
|
-
transactionId: transactionId
|
|
21387
|
-
}
|
|
21283
|
+
// @todo - Detect whether web browser supports a particular Apple Pay version.
|
|
21284
|
+
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778014-supportsversion
|
|
21285
|
+
|
|
21286
|
+
session.onvalidatemerchant = async event => {
|
|
21287
|
+
const {
|
|
21288
|
+
validationURL
|
|
21289
|
+
} = event;
|
|
21290
|
+
console.log("then merchantSession step", event);
|
|
21291
|
+
// Call your own server to request a new merchant session.
|
|
21292
|
+
window.Pelcro.payment.startSession({
|
|
21293
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
21294
|
+
site_id: window.Pelcro.siteid,
|
|
21295
|
+
validation_url: validationURL
|
|
21296
|
+
}, (err, res) => {
|
|
21297
|
+
if (err) {
|
|
21298
|
+
// Handle any errors during merchant validation
|
|
21299
|
+
console.error("Merchant validation SDK error: ", err);
|
|
21300
|
+
session.abort();
|
|
21301
|
+
return dispatch({
|
|
21302
|
+
type: SHOW_ALERT,
|
|
21303
|
+
payload: {
|
|
21304
|
+
type: "error",
|
|
21305
|
+
content: getErrorMessages(err)
|
|
21306
|
+
}
|
|
21307
|
+
});
|
|
21308
|
+
}
|
|
21309
|
+
// Complete merchant validation with the merchant session object
|
|
21310
|
+
console.log("Merchant validation SDK response: ", res);
|
|
21311
|
+
const merchantSession = res;
|
|
21312
|
+
session.completeMerchantValidation(merchantSession);
|
|
21313
|
+
});
|
|
21388
21314
|
};
|
|
21389
|
-
|
|
21390
|
-
|
|
21391
|
-
|
|
21392
|
-
|
|
21393
|
-
|
|
21394
|
-
|
|
21395
|
-
|
|
21396
|
-
|
|
21397
|
-
|
|
21315
|
+
session.onpaymentmethodselected = event => {
|
|
21316
|
+
console.log("payment method selected step", event);
|
|
21317
|
+
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
21318
|
+
// No updates or errors are needed, pass an empty object.
|
|
21319
|
+
const newTotal = {
|
|
21320
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21321
|
+
type: "final",
|
|
21322
|
+
amount: updatedPrice / 100
|
|
21323
|
+
};
|
|
21324
|
+
const newLineItems = [{
|
|
21325
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21326
|
+
type: "final",
|
|
21327
|
+
amount: updatedPrice / 100
|
|
21328
|
+
}];
|
|
21329
|
+
session.completePaymentMethodSelection(newTotal, newLineItems);
|
|
21398
21330
|
};
|
|
21399
21331
|
|
|
21400
|
-
//
|
|
21401
|
-
|
|
21332
|
+
// TODO: Check if onshippingmethodselected it should be implemented
|
|
21333
|
+
// session.onshippingmethodselected = (event) => {
|
|
21334
|
+
// console.log("on shipping method selected step", event);
|
|
21335
|
+
// // Define ApplePayShippingMethodUpdate based on the selected shipping method.
|
|
21336
|
+
// // No updates or errors are needed, pass an empty object.
|
|
21337
|
+
// const newTotal = {
|
|
21338
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
21339
|
+
// type: "final",
|
|
21340
|
+
// amount: updatedPrice / 100
|
|
21341
|
+
// };
|
|
21342
|
+
|
|
21343
|
+
// const newLineItems = [
|
|
21344
|
+
// {
|
|
21345
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
21346
|
+
// type: "final",
|
|
21347
|
+
// amount: updatedPrice / 100
|
|
21348
|
+
// }
|
|
21349
|
+
// ];
|
|
21350
|
+
|
|
21351
|
+
// session.completeShippingMethodSelection(newTotal, newLineItems);
|
|
21352
|
+
// };
|
|
21353
|
+
|
|
21354
|
+
// TODO: Check if onshippingcontactselected it should be implemented
|
|
21355
|
+
// session.onshippingcontactselected = (event) => {
|
|
21356
|
+
// console.log("on shipping contact selected step", event);
|
|
21357
|
+
// // Define ApplePayShippingContactUpdate based on the selected shipping contact.
|
|
21358
|
+
// const update = {};
|
|
21359
|
+
// session.completeShippingContactSelection(update);
|
|
21360
|
+
// };
|
|
21361
|
+
|
|
21362
|
+
session.onpaymentauthorized = event => {
|
|
21363
|
+
console.log("on payment authorized step", event);
|
|
21364
|
+
// Define ApplePayPaymentAuthorizationResult
|
|
21365
|
+
const result = {
|
|
21366
|
+
status: ApplePaySession.STATUS_SUCCESS // eslint-disable-line no-undef
|
|
21367
|
+
};
|
|
21368
|
+
|
|
21402
21369
|
const {
|
|
21403
|
-
|
|
21404
|
-
} =
|
|
21405
|
-
|
|
21406
|
-
|
|
21407
|
-
|
|
21408
|
-
|
|
21409
|
-
|
|
21410
|
-
|
|
21411
|
-
|
|
21370
|
+
paymentData
|
|
21371
|
+
} = event.payment.token;
|
|
21372
|
+
const {
|
|
21373
|
+
data,
|
|
21374
|
+
signature,
|
|
21375
|
+
version
|
|
21376
|
+
} = paymentData;
|
|
21377
|
+
const {
|
|
21378
|
+
ephemeralPublicKey,
|
|
21379
|
+
publicKeyHash,
|
|
21380
|
+
transactionId
|
|
21381
|
+
} = paymentData.header;
|
|
21382
|
+
const applePayToken = {
|
|
21383
|
+
data: data,
|
|
21384
|
+
signature: signature,
|
|
21385
|
+
version: version,
|
|
21386
|
+
header: {
|
|
21387
|
+
ephemeralPublicKey: ephemeralPublicKey,
|
|
21388
|
+
publicKeyHash: publicKeyHash,
|
|
21389
|
+
transactionId: transactionId
|
|
21390
|
+
}
|
|
21412
21391
|
};
|
|
21392
|
+
console.log(applePayToken);
|
|
21393
|
+
const orderId = `pelcro-${new Date().getTime()}`;
|
|
21394
|
+
const eProtectRequest = {
|
|
21395
|
+
paypageId: payPageId,
|
|
21396
|
+
reportGroup: reportGroup,
|
|
21397
|
+
orderId: orderId,
|
|
21398
|
+
id: orderId,
|
|
21399
|
+
applepay: applePayToken,
|
|
21400
|
+
url: "https://request.eprotect.vantivprelive.com"
|
|
21401
|
+
};
|
|
21402
|
+
|
|
21403
|
+
// successCallback function to handle the response from WorldPay.
|
|
21404
|
+
function successCallback(vantivResponse) {
|
|
21405
|
+
const {
|
|
21406
|
+
expDate
|
|
21407
|
+
} = vantivResponse;
|
|
21408
|
+
console.log("Response:", vantivResponse);
|
|
21409
|
+
const expMonth = expDate.substring(0, 2);
|
|
21410
|
+
const expYear = expDate.substring(2);
|
|
21411
|
+
const vantivPaymentRequest = {
|
|
21412
|
+
...vantivResponse,
|
|
21413
|
+
expMonth: expMonth,
|
|
21414
|
+
expYear: expYear
|
|
21415
|
+
};
|
|
21413
21416
|
|
|
21414
|
-
|
|
21417
|
+
// Process the registrationId or continue with further payment processing.
|
|
21418
|
+
dispatch({
|
|
21419
|
+
type: HANDLE_APPLEPAY_SUBSCRIPTION,
|
|
21420
|
+
payload: vantivPaymentRequest
|
|
21421
|
+
});
|
|
21422
|
+
dispatch({
|
|
21423
|
+
type: LOADING,
|
|
21424
|
+
payload: true
|
|
21425
|
+
});
|
|
21426
|
+
session.completePayment(result);
|
|
21427
|
+
}
|
|
21428
|
+
|
|
21429
|
+
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
21430
|
+
function errorCallback(error) {
|
|
21431
|
+
console.error("Error retrieving Registration ID:", error);
|
|
21432
|
+
// Handle error appropriately.
|
|
21433
|
+
}
|
|
21434
|
+
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
21435
|
+
function timeoutCallback() {
|
|
21436
|
+
console.error("eProtect Timeout");
|
|
21437
|
+
// Handle error appropriately.
|
|
21438
|
+
}
|
|
21439
|
+
|
|
21440
|
+
// eslint-disable-next-line no-undef
|
|
21441
|
+
new eProtect().sendToEprotect(eProtectRequest, {}, successCallback, errorCallback, timeoutCallback, 15000);
|
|
21442
|
+
};
|
|
21443
|
+
|
|
21444
|
+
// TODO: Check if oncouponcodechanged it should be implemented
|
|
21445
|
+
// session.oncouponcodechanged = (event) => {
|
|
21446
|
+
// console.log("on coupon code changed step", event);
|
|
21447
|
+
// // Define ApplePayCouponCodeUpdate
|
|
21448
|
+
// const newTotal = calculateNewTotal(event.couponCode);
|
|
21449
|
+
// const newLineItems = calculateNewLineItems(event.couponCode);
|
|
21450
|
+
// const newShippingMethods = calculateNewShippingMethods(
|
|
21451
|
+
// event.couponCode
|
|
21452
|
+
// );
|
|
21453
|
+
// const errors = calculateErrors(event.couponCode);
|
|
21454
|
+
|
|
21455
|
+
// session.completeCouponCodeChange({
|
|
21456
|
+
// newTotal: newTotal,
|
|
21457
|
+
// newLineItems: newLineItems,
|
|
21458
|
+
// newShippingMethods: newShippingMethods,
|
|
21459
|
+
// errors: errors
|
|
21460
|
+
// });
|
|
21461
|
+
// };
|
|
21462
|
+
|
|
21463
|
+
session.oncancel = event => {
|
|
21464
|
+
// Payment cancelled by WebKit
|
|
21465
|
+
console.log("on cancel step", event);
|
|
21415
21466
|
dispatch({
|
|
21416
|
-
type:
|
|
21417
|
-
payload:
|
|
21467
|
+
type: LOADING,
|
|
21468
|
+
payload: false
|
|
21418
21469
|
});
|
|
21419
21470
|
dispatch({
|
|
21420
|
-
type:
|
|
21421
|
-
payload:
|
|
21471
|
+
type: DISABLE_SUBMIT,
|
|
21472
|
+
payload: false
|
|
21422
21473
|
});
|
|
21423
|
-
|
|
21424
|
-
|
|
21425
|
-
|
|
21426
|
-
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
21427
|
-
function errorCallback(error) {
|
|
21428
|
-
console.error("Error retrieving Registration ID:", error);
|
|
21429
|
-
// Handle error appropriately.
|
|
21430
|
-
}
|
|
21431
|
-
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
21432
|
-
function timeoutCallback() {
|
|
21433
|
-
console.error("eProtect Timeout");
|
|
21434
|
-
// Handle error appropriately.
|
|
21435
|
-
}
|
|
21436
|
-
|
|
21437
|
-
new eProtect().sendToEprotect(eProtectRequest, {}, successCallback, errorCallback, timeoutCallback, 15000);
|
|
21438
|
-
};
|
|
21439
|
-
|
|
21440
|
-
// TODO: Check if oncouponcodechanged it should be implemented
|
|
21441
|
-
// session.oncouponcodechanged = (event) => {
|
|
21442
|
-
// console.log("on coupon code changed step", event);
|
|
21443
|
-
// // Define ApplePayCouponCodeUpdate
|
|
21444
|
-
// const newTotal = calculateNewTotal(event.couponCode);
|
|
21445
|
-
// const newLineItems = calculateNewLineItems(event.couponCode);
|
|
21446
|
-
// const newShippingMethods = calculateNewShippingMethods(
|
|
21447
|
-
// event.couponCode
|
|
21448
|
-
// );
|
|
21449
|
-
// const errors = calculateErrors(event.couponCode);
|
|
21450
|
-
|
|
21451
|
-
// session.completeCouponCodeChange({
|
|
21452
|
-
// newTotal: newTotal,
|
|
21453
|
-
// newLineItems: newLineItems,
|
|
21454
|
-
// newShippingMethods: newShippingMethods,
|
|
21455
|
-
// errors: errors
|
|
21456
|
-
// });
|
|
21457
|
-
// };
|
|
21458
|
-
|
|
21459
|
-
session.oncancel = event => {
|
|
21460
|
-
// Payment cancelled by WebKit
|
|
21461
|
-
console.log("on cancel step", event);
|
|
21462
|
-
dispatch({
|
|
21463
|
-
type: LOADING,
|
|
21464
|
-
payload: false
|
|
21465
|
-
});
|
|
21466
|
-
dispatch({
|
|
21467
|
-
type: DISABLE_SUBMIT,
|
|
21468
|
-
payload: false
|
|
21469
|
-
});
|
|
21470
|
-
};
|
|
21471
|
-
session.begin();
|
|
21472
|
-
}
|
|
21473
|
-
React.useEffect(() => {
|
|
21474
|
+
};
|
|
21475
|
+
session.begin();
|
|
21476
|
+
}
|
|
21474
21477
|
const pelcroApplyPayButton = document.getElementById("pelcro-apple-pay-button");
|
|
21475
21478
|
if (pelcroApplyPayButton) {
|
|
21476
21479
|
pelcroApplyPayButton.addEventListener("click", onApplePayButtonClicked);
|
|
21477
21480
|
}
|
|
21478
|
-
|
|
21481
|
+
return () => {
|
|
21482
|
+
if (pelcroApplyPayButton) {
|
|
21483
|
+
pelcroApplyPayButton.removeEventListener("click", onApplePayButtonClicked);
|
|
21484
|
+
}
|
|
21485
|
+
};
|
|
21486
|
+
}, [state.updatedPrice]);
|
|
21479
21487
|
return /*#__PURE__*/React__default['default'].createElement("apple-pay-button", {
|
|
21480
21488
|
id: "pelcro-apple-pay-button",
|
|
21481
21489
|
style: {
|
|
@@ -35051,6 +35059,7 @@ exports.AddressUpdateTextInput = AddressUpdateTextInput;
|
|
|
35051
35059
|
exports.AddressUpdateView = AddressUpdateView;
|
|
35052
35060
|
exports.Alert = AlertWithContext;
|
|
35053
35061
|
exports.AlertElement = Alert;
|
|
35062
|
+
exports.ApplePayButton = ApplePayButton;
|
|
35054
35063
|
exports.ApplyCouponButton = ApplyCouponButton;
|
|
35055
35064
|
exports.Auth0LoginButton = Auth0LoginButton;
|
|
35056
35065
|
exports.Badge = Badge;
|
package/dist/index.esm.js
CHANGED
|
@@ -21154,14 +21154,12 @@ const DonationEmail = props => /*#__PURE__*/React__default.createElement(Email,
|
|
|
21154
21154
|
store: store$k
|
|
21155
21155
|
}, props));
|
|
21156
21156
|
|
|
21157
|
-
/* eslint-disable no-undef */
|
|
21158
|
-
|
|
21159
21157
|
/**
|
|
21160
21158
|
* ApplePayButton component
|
|
21161
21159
|
* @return {JSX}
|
|
21162
21160
|
*/
|
|
21163
21161
|
const ApplePayButton = _ref => {
|
|
21164
|
-
var _window$Pelcro$site$r, _order
|
|
21162
|
+
var _window$Pelcro$site$r, _order$;
|
|
21165
21163
|
let {
|
|
21166
21164
|
onClick,
|
|
21167
21165
|
props,
|
|
@@ -21200,10 +21198,10 @@ const ApplePayButton = _ref => {
|
|
|
21200
21198
|
const orderPrice = getOrderItemsTotal();
|
|
21201
21199
|
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;
|
|
21202
21200
|
const orderLabel = !Array.isArray(order) ? order === null || order === void 0 ? void 0 : order.name : "Order";
|
|
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;
|
|
21204
21201
|
useEffect(() => {
|
|
21205
21202
|
if (window.ApplePaySession) {
|
|
21206
21203
|
// Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
|
|
21204
|
+
// eslint-disable-next-line no-undef
|
|
21207
21205
|
const promise = ApplePaySession.canMakePaymentsWithActiveCard(ApplePayMerchantId);
|
|
21208
21206
|
promise.then(function (canMakePayments) {
|
|
21209
21207
|
if (canMakePayments && ApplePayEnabled) {
|
|
@@ -21219,233 +21217,243 @@ const ApplePayButton = _ref => {
|
|
|
21219
21217
|
console.error("ApplePay is not available on this browser");
|
|
21220
21218
|
}
|
|
21221
21219
|
}, []);
|
|
21222
|
-
|
|
21223
|
-
|
|
21224
|
-
|
|
21225
|
-
|
|
21226
|
-
|
|
21227
|
-
|
|
21228
|
-
type: DISABLE_SUBMIT,
|
|
21229
|
-
payload: true
|
|
21230
|
-
});
|
|
21231
|
-
|
|
21232
|
-
// Define ApplePayPaymentRequest
|
|
21233
|
-
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/creating_an_apple_pay_session
|
|
21234
|
-
const ApplePayPaymentRequest = {
|
|
21235
|
-
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",
|
|
21236
|
-
currencyCode: (plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase()) || orderCurrency.toUpperCase() || (invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase()),
|
|
21237
|
-
merchantCapabilities: ["supports3DS"],
|
|
21238
|
-
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
21239
|
-
total: {
|
|
21240
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21241
|
-
type: "final",
|
|
21242
|
-
amount: updatedPrice / 100
|
|
21220
|
+
useEffect(() => {
|
|
21221
|
+
function onApplePayButtonClicked() {
|
|
21222
|
+
var _ref2, _ref3, _ref4, _ref5, _state$updatedPrice, _props$plan, _window, _window$Pelcro, _window$Pelcro$user, _window$Pelcro$user$l;
|
|
21223
|
+
// eslint-disable-next-line no-undef
|
|
21224
|
+
if (!ApplePaySession) {
|
|
21225
|
+
return;
|
|
21243
21226
|
}
|
|
21244
|
-
|
|
21245
|
-
|
|
21246
|
-
|
|
21247
|
-
|
|
21248
|
-
|
|
21249
|
-
|
|
21250
|
-
|
|
21251
|
-
// @todo - Detect whether web browser supports a particular Apple Pay version.
|
|
21252
|
-
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778014-supportsversion
|
|
21227
|
+
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
|
+
console.log(updatedPrice);
|
|
21229
|
+
dispatch({
|
|
21230
|
+
type: DISABLE_SUBMIT,
|
|
21231
|
+
payload: true
|
|
21232
|
+
});
|
|
21253
21233
|
|
|
21254
|
-
|
|
21255
|
-
|
|
21256
|
-
|
|
21257
|
-
|
|
21258
|
-
|
|
21259
|
-
|
|
21260
|
-
|
|
21261
|
-
|
|
21262
|
-
|
|
21263
|
-
|
|
21264
|
-
|
|
21265
|
-
if (err) {
|
|
21266
|
-
// Handle any errors during merchant validation
|
|
21267
|
-
console.error("Merchant validation SDK error: ", err);
|
|
21268
|
-
session.abort();
|
|
21269
|
-
return dispatch({
|
|
21270
|
-
type: SHOW_ALERT,
|
|
21271
|
-
payload: {
|
|
21272
|
-
type: "error",
|
|
21273
|
-
content: getErrorMessages(err)
|
|
21274
|
-
}
|
|
21275
|
-
});
|
|
21234
|
+
// Define ApplePayPaymentRequest
|
|
21235
|
+
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/creating_an_apple_pay_session
|
|
21236
|
+
const ApplePayPaymentRequest = {
|
|
21237
|
+
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: (plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase()) || orderCurrency.toUpperCase() || (invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase()),
|
|
21239
|
+
merchantCapabilities: ["supports3DS"],
|
|
21240
|
+
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
21241
|
+
total: {
|
|
21242
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21243
|
+
type: "final",
|
|
21244
|
+
amount: updatedPrice / 100
|
|
21276
21245
|
}
|
|
21277
|
-
// Complete merchant validation with the merchant session object
|
|
21278
|
-
console.log("Merchant validation SDK response: ", res);
|
|
21279
|
-
const merchantSession = res;
|
|
21280
|
-
session.completeMerchantValidation(merchantSession);
|
|
21281
|
-
});
|
|
21282
|
-
};
|
|
21283
|
-
session.onpaymentmethodselected = event => {
|
|
21284
|
-
console.log("payment method selected step", event);
|
|
21285
|
-
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
21286
|
-
// No updates or errors are needed, pass an empty object.
|
|
21287
|
-
const newTotal = {
|
|
21288
|
-
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21289
|
-
type: "final",
|
|
21290
|
-
amount: updatedPrice / 100
|
|
21291
21246
|
};
|
|
21292
|
-
|
|
21293
|
-
|
|
21294
|
-
|
|
21295
|
-
|
|
21296
|
-
|
|
21297
|
-
session.completePaymentMethodSelection(newTotal, newLineItems);
|
|
21298
|
-
};
|
|
21247
|
+
console.log(ApplePayPaymentRequest);
|
|
21248
|
+
// Create ApplePaySession
|
|
21249
|
+
// @todo - Clarify supported version parameter
|
|
21250
|
+
// @odo - Apple Pay demo uses version 6 (https://applepaydemo.apple.com/)
|
|
21251
|
+
const session = new ApplePaySession(3, ApplePayPaymentRequest); // eslint-disable-line no-undef
|
|
21299
21252
|
|
|
21300
|
-
|
|
21301
|
-
|
|
21302
|
-
|
|
21303
|
-
|
|
21304
|
-
|
|
21305
|
-
|
|
21306
|
-
|
|
21307
|
-
|
|
21308
|
-
|
|
21309
|
-
|
|
21310
|
-
|
|
21311
|
-
|
|
21312
|
-
|
|
21313
|
-
|
|
21314
|
-
|
|
21315
|
-
|
|
21316
|
-
|
|
21317
|
-
|
|
21318
|
-
|
|
21319
|
-
|
|
21320
|
-
|
|
21321
|
-
|
|
21322
|
-
|
|
21323
|
-
|
|
21324
|
-
|
|
21325
|
-
|
|
21326
|
-
|
|
21327
|
-
|
|
21328
|
-
|
|
21329
|
-
|
|
21330
|
-
|
|
21331
|
-
console.log("on payment authorized step", event);
|
|
21332
|
-
// Define ApplePayPaymentAuthorizationResult
|
|
21333
|
-
const result = {
|
|
21334
|
-
status: ApplePaySession.STATUS_SUCCESS
|
|
21335
|
-
};
|
|
21336
|
-
const {
|
|
21337
|
-
paymentData
|
|
21338
|
-
} = event.payment.token;
|
|
21339
|
-
const {
|
|
21340
|
-
data,
|
|
21341
|
-
signature,
|
|
21342
|
-
version
|
|
21343
|
-
} = paymentData;
|
|
21344
|
-
const {
|
|
21345
|
-
ephemeralPublicKey,
|
|
21346
|
-
publicKeyHash,
|
|
21347
|
-
transactionId
|
|
21348
|
-
} = paymentData.header;
|
|
21349
|
-
const applePayToken = {
|
|
21350
|
-
data: data,
|
|
21351
|
-
signature: signature,
|
|
21352
|
-
version: version,
|
|
21353
|
-
header: {
|
|
21354
|
-
ephemeralPublicKey: ephemeralPublicKey,
|
|
21355
|
-
publicKeyHash: publicKeyHash,
|
|
21356
|
-
transactionId: transactionId
|
|
21357
|
-
}
|
|
21253
|
+
// @todo - Detect whether web browser supports a particular Apple Pay version.
|
|
21254
|
+
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778014-supportsversion
|
|
21255
|
+
|
|
21256
|
+
session.onvalidatemerchant = async event => {
|
|
21257
|
+
const {
|
|
21258
|
+
validationURL
|
|
21259
|
+
} = event;
|
|
21260
|
+
console.log("then merchantSession step", event);
|
|
21261
|
+
// Call your own server to request a new merchant session.
|
|
21262
|
+
window.Pelcro.payment.startSession({
|
|
21263
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
21264
|
+
site_id: window.Pelcro.siteid,
|
|
21265
|
+
validation_url: validationURL
|
|
21266
|
+
}, (err, res) => {
|
|
21267
|
+
if (err) {
|
|
21268
|
+
// Handle any errors during merchant validation
|
|
21269
|
+
console.error("Merchant validation SDK error: ", err);
|
|
21270
|
+
session.abort();
|
|
21271
|
+
return dispatch({
|
|
21272
|
+
type: SHOW_ALERT,
|
|
21273
|
+
payload: {
|
|
21274
|
+
type: "error",
|
|
21275
|
+
content: getErrorMessages(err)
|
|
21276
|
+
}
|
|
21277
|
+
});
|
|
21278
|
+
}
|
|
21279
|
+
// Complete merchant validation with the merchant session object
|
|
21280
|
+
console.log("Merchant validation SDK response: ", res);
|
|
21281
|
+
const merchantSession = res;
|
|
21282
|
+
session.completeMerchantValidation(merchantSession);
|
|
21283
|
+
});
|
|
21358
21284
|
};
|
|
21359
|
-
|
|
21360
|
-
|
|
21361
|
-
|
|
21362
|
-
|
|
21363
|
-
|
|
21364
|
-
|
|
21365
|
-
|
|
21366
|
-
|
|
21367
|
-
|
|
21285
|
+
session.onpaymentmethodselected = event => {
|
|
21286
|
+
console.log("payment method selected step", event);
|
|
21287
|
+
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
21288
|
+
// No updates or errors are needed, pass an empty object.
|
|
21289
|
+
const newTotal = {
|
|
21290
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21291
|
+
type: "final",
|
|
21292
|
+
amount: updatedPrice / 100
|
|
21293
|
+
};
|
|
21294
|
+
const newLineItems = [{
|
|
21295
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
21296
|
+
type: "final",
|
|
21297
|
+
amount: updatedPrice / 100
|
|
21298
|
+
}];
|
|
21299
|
+
session.completePaymentMethodSelection(newTotal, newLineItems);
|
|
21368
21300
|
};
|
|
21369
21301
|
|
|
21370
|
-
//
|
|
21371
|
-
|
|
21302
|
+
// TODO: Check if onshippingmethodselected it should be implemented
|
|
21303
|
+
// session.onshippingmethodselected = (event) => {
|
|
21304
|
+
// console.log("on shipping method selected step", event);
|
|
21305
|
+
// // Define ApplePayShippingMethodUpdate based on the selected shipping method.
|
|
21306
|
+
// // No updates or errors are needed, pass an empty object.
|
|
21307
|
+
// const newTotal = {
|
|
21308
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
21309
|
+
// type: "final",
|
|
21310
|
+
// amount: updatedPrice / 100
|
|
21311
|
+
// };
|
|
21312
|
+
|
|
21313
|
+
// const newLineItems = [
|
|
21314
|
+
// {
|
|
21315
|
+
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
21316
|
+
// type: "final",
|
|
21317
|
+
// amount: updatedPrice / 100
|
|
21318
|
+
// }
|
|
21319
|
+
// ];
|
|
21320
|
+
|
|
21321
|
+
// session.completeShippingMethodSelection(newTotal, newLineItems);
|
|
21322
|
+
// };
|
|
21323
|
+
|
|
21324
|
+
// TODO: Check if onshippingcontactselected it should be implemented
|
|
21325
|
+
// session.onshippingcontactselected = (event) => {
|
|
21326
|
+
// console.log("on shipping contact selected step", event);
|
|
21327
|
+
// // Define ApplePayShippingContactUpdate based on the selected shipping contact.
|
|
21328
|
+
// const update = {};
|
|
21329
|
+
// session.completeShippingContactSelection(update);
|
|
21330
|
+
// };
|
|
21331
|
+
|
|
21332
|
+
session.onpaymentauthorized = event => {
|
|
21333
|
+
console.log("on payment authorized step", event);
|
|
21334
|
+
// Define ApplePayPaymentAuthorizationResult
|
|
21335
|
+
const result = {
|
|
21336
|
+
status: ApplePaySession.STATUS_SUCCESS // eslint-disable-line no-undef
|
|
21337
|
+
};
|
|
21338
|
+
|
|
21372
21339
|
const {
|
|
21373
|
-
|
|
21374
|
-
} =
|
|
21375
|
-
|
|
21376
|
-
|
|
21377
|
-
|
|
21378
|
-
|
|
21379
|
-
|
|
21380
|
-
|
|
21381
|
-
|
|
21340
|
+
paymentData
|
|
21341
|
+
} = event.payment.token;
|
|
21342
|
+
const {
|
|
21343
|
+
data,
|
|
21344
|
+
signature,
|
|
21345
|
+
version
|
|
21346
|
+
} = paymentData;
|
|
21347
|
+
const {
|
|
21348
|
+
ephemeralPublicKey,
|
|
21349
|
+
publicKeyHash,
|
|
21350
|
+
transactionId
|
|
21351
|
+
} = paymentData.header;
|
|
21352
|
+
const applePayToken = {
|
|
21353
|
+
data: data,
|
|
21354
|
+
signature: signature,
|
|
21355
|
+
version: version,
|
|
21356
|
+
header: {
|
|
21357
|
+
ephemeralPublicKey: ephemeralPublicKey,
|
|
21358
|
+
publicKeyHash: publicKeyHash,
|
|
21359
|
+
transactionId: transactionId
|
|
21360
|
+
}
|
|
21382
21361
|
};
|
|
21362
|
+
console.log(applePayToken);
|
|
21363
|
+
const orderId = `pelcro-${new Date().getTime()}`;
|
|
21364
|
+
const eProtectRequest = {
|
|
21365
|
+
paypageId: payPageId,
|
|
21366
|
+
reportGroup: reportGroup,
|
|
21367
|
+
orderId: orderId,
|
|
21368
|
+
id: orderId,
|
|
21369
|
+
applepay: applePayToken,
|
|
21370
|
+
url: "https://request.eprotect.vantivprelive.com"
|
|
21371
|
+
};
|
|
21372
|
+
|
|
21373
|
+
// successCallback function to handle the response from WorldPay.
|
|
21374
|
+
function successCallback(vantivResponse) {
|
|
21375
|
+
const {
|
|
21376
|
+
expDate
|
|
21377
|
+
} = vantivResponse;
|
|
21378
|
+
console.log("Response:", vantivResponse);
|
|
21379
|
+
const expMonth = expDate.substring(0, 2);
|
|
21380
|
+
const expYear = expDate.substring(2);
|
|
21381
|
+
const vantivPaymentRequest = {
|
|
21382
|
+
...vantivResponse,
|
|
21383
|
+
expMonth: expMonth,
|
|
21384
|
+
expYear: expYear
|
|
21385
|
+
};
|
|
21383
21386
|
|
|
21384
|
-
|
|
21387
|
+
// Process the registrationId or continue with further payment processing.
|
|
21388
|
+
dispatch({
|
|
21389
|
+
type: HANDLE_APPLEPAY_SUBSCRIPTION,
|
|
21390
|
+
payload: vantivPaymentRequest
|
|
21391
|
+
});
|
|
21392
|
+
dispatch({
|
|
21393
|
+
type: LOADING,
|
|
21394
|
+
payload: true
|
|
21395
|
+
});
|
|
21396
|
+
session.completePayment(result);
|
|
21397
|
+
}
|
|
21398
|
+
|
|
21399
|
+
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
21400
|
+
function errorCallback(error) {
|
|
21401
|
+
console.error("Error retrieving Registration ID:", error);
|
|
21402
|
+
// Handle error appropriately.
|
|
21403
|
+
}
|
|
21404
|
+
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
21405
|
+
function timeoutCallback() {
|
|
21406
|
+
console.error("eProtect Timeout");
|
|
21407
|
+
// Handle error appropriately.
|
|
21408
|
+
}
|
|
21409
|
+
|
|
21410
|
+
// eslint-disable-next-line no-undef
|
|
21411
|
+
new eProtect().sendToEprotect(eProtectRequest, {}, successCallback, errorCallback, timeoutCallback, 15000);
|
|
21412
|
+
};
|
|
21413
|
+
|
|
21414
|
+
// TODO: Check if oncouponcodechanged it should be implemented
|
|
21415
|
+
// session.oncouponcodechanged = (event) => {
|
|
21416
|
+
// console.log("on coupon code changed step", event);
|
|
21417
|
+
// // Define ApplePayCouponCodeUpdate
|
|
21418
|
+
// const newTotal = calculateNewTotal(event.couponCode);
|
|
21419
|
+
// const newLineItems = calculateNewLineItems(event.couponCode);
|
|
21420
|
+
// const newShippingMethods = calculateNewShippingMethods(
|
|
21421
|
+
// event.couponCode
|
|
21422
|
+
// );
|
|
21423
|
+
// const errors = calculateErrors(event.couponCode);
|
|
21424
|
+
|
|
21425
|
+
// session.completeCouponCodeChange({
|
|
21426
|
+
// newTotal: newTotal,
|
|
21427
|
+
// newLineItems: newLineItems,
|
|
21428
|
+
// newShippingMethods: newShippingMethods,
|
|
21429
|
+
// errors: errors
|
|
21430
|
+
// });
|
|
21431
|
+
// };
|
|
21432
|
+
|
|
21433
|
+
session.oncancel = event => {
|
|
21434
|
+
// Payment cancelled by WebKit
|
|
21435
|
+
console.log("on cancel step", event);
|
|
21385
21436
|
dispatch({
|
|
21386
|
-
type:
|
|
21387
|
-
payload:
|
|
21437
|
+
type: LOADING,
|
|
21438
|
+
payload: false
|
|
21388
21439
|
});
|
|
21389
21440
|
dispatch({
|
|
21390
|
-
type:
|
|
21391
|
-
payload:
|
|
21441
|
+
type: DISABLE_SUBMIT,
|
|
21442
|
+
payload: false
|
|
21392
21443
|
});
|
|
21393
|
-
|
|
21394
|
-
|
|
21395
|
-
|
|
21396
|
-
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
21397
|
-
function errorCallback(error) {
|
|
21398
|
-
console.error("Error retrieving Registration ID:", error);
|
|
21399
|
-
// Handle error appropriately.
|
|
21400
|
-
}
|
|
21401
|
-
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
21402
|
-
function timeoutCallback() {
|
|
21403
|
-
console.error("eProtect Timeout");
|
|
21404
|
-
// Handle error appropriately.
|
|
21405
|
-
}
|
|
21406
|
-
|
|
21407
|
-
new eProtect().sendToEprotect(eProtectRequest, {}, successCallback, errorCallback, timeoutCallback, 15000);
|
|
21408
|
-
};
|
|
21409
|
-
|
|
21410
|
-
// TODO: Check if oncouponcodechanged it should be implemented
|
|
21411
|
-
// session.oncouponcodechanged = (event) => {
|
|
21412
|
-
// console.log("on coupon code changed step", event);
|
|
21413
|
-
// // Define ApplePayCouponCodeUpdate
|
|
21414
|
-
// const newTotal = calculateNewTotal(event.couponCode);
|
|
21415
|
-
// const newLineItems = calculateNewLineItems(event.couponCode);
|
|
21416
|
-
// const newShippingMethods = calculateNewShippingMethods(
|
|
21417
|
-
// event.couponCode
|
|
21418
|
-
// );
|
|
21419
|
-
// const errors = calculateErrors(event.couponCode);
|
|
21420
|
-
|
|
21421
|
-
// session.completeCouponCodeChange({
|
|
21422
|
-
// newTotal: newTotal,
|
|
21423
|
-
// newLineItems: newLineItems,
|
|
21424
|
-
// newShippingMethods: newShippingMethods,
|
|
21425
|
-
// errors: errors
|
|
21426
|
-
// });
|
|
21427
|
-
// };
|
|
21428
|
-
|
|
21429
|
-
session.oncancel = event => {
|
|
21430
|
-
// Payment cancelled by WebKit
|
|
21431
|
-
console.log("on cancel step", event);
|
|
21432
|
-
dispatch({
|
|
21433
|
-
type: LOADING,
|
|
21434
|
-
payload: false
|
|
21435
|
-
});
|
|
21436
|
-
dispatch({
|
|
21437
|
-
type: DISABLE_SUBMIT,
|
|
21438
|
-
payload: false
|
|
21439
|
-
});
|
|
21440
|
-
};
|
|
21441
|
-
session.begin();
|
|
21442
|
-
}
|
|
21443
|
-
useEffect(() => {
|
|
21444
|
+
};
|
|
21445
|
+
session.begin();
|
|
21446
|
+
}
|
|
21444
21447
|
const pelcroApplyPayButton = document.getElementById("pelcro-apple-pay-button");
|
|
21445
21448
|
if (pelcroApplyPayButton) {
|
|
21446
21449
|
pelcroApplyPayButton.addEventListener("click", onApplePayButtonClicked);
|
|
21447
21450
|
}
|
|
21448
|
-
|
|
21451
|
+
return () => {
|
|
21452
|
+
if (pelcroApplyPayButton) {
|
|
21453
|
+
pelcroApplyPayButton.removeEventListener("click", onApplePayButtonClicked);
|
|
21454
|
+
}
|
|
21455
|
+
};
|
|
21456
|
+
}, [state.updatedPrice]);
|
|
21449
21457
|
return /*#__PURE__*/React__default.createElement("apple-pay-button", {
|
|
21450
21458
|
id: "pelcro-apple-pay-button",
|
|
21451
21459
|
style: {
|
|
@@ -34986,4 +34994,4 @@ const QrCodeModal = _ref => {
|
|
|
34986
34994
|
};
|
|
34987
34995
|
QrCodeModal.viewId = "qrcode";
|
|
34988
34996
|
|
|
34989
|
-
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, DonationModalWithHook as DonationModal, 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, unauthenticatedButtons, usePelcro };
|
|
34997
|
+
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, ApplePayButton, ApplyCouponButton, Auth0LoginButton, Badge, BankAuthenticationSuccess, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, DonationModalWithHook as DonationModal, 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, unauthenticatedButtons, usePelcro };
|