@pelcro/react-pelcro-js 3.26.0-sandbox.22 → 3.26.0-sandbox.24
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 +369 -29
- package/dist/index.esm.js +369 -29
- package/dist/pelcro.css +8 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -11561,21 +11561,31 @@ const initPaywalls = () => {
|
|
|
11561
11561
|
return;
|
|
11562
11562
|
}
|
|
11563
11563
|
const {
|
|
11564
|
-
switchView
|
|
11564
|
+
switchView,
|
|
11565
|
+
isAuthenticated
|
|
11565
11566
|
} = usePelcro.getStore();
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
|
|
11567
|
+
function displayPaywalls() {
|
|
11568
|
+
if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayMeterPaywall()) {
|
|
11569
|
+
/*
|
|
11570
|
+
showing both the meter and the entitlements notification doesn't make sense from
|
|
11571
|
+
a product prespective + they would take half the screen on mobile devies, so we're
|
|
11572
|
+
not showing the meter, and only showing the entitlements notification.
|
|
11573
|
+
*/
|
|
11574
|
+
if (!didBlurContent) {
|
|
11575
|
+
switchView("meter");
|
|
11576
|
+
}
|
|
11577
|
+
} else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayNewsletterPaywall()) {
|
|
11578
|
+
switchView("newsletter");
|
|
11579
|
+
} else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayPaywall()) {
|
|
11580
|
+
switchView("plan-select");
|
|
11574
11581
|
}
|
|
11575
|
-
}
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11582
|
+
}
|
|
11583
|
+
if (isAuthenticated()) {
|
|
11584
|
+
addEventListener("PelcroUserLoaded", function () {
|
|
11585
|
+
displayPaywalls();
|
|
11586
|
+
});
|
|
11587
|
+
} else {
|
|
11588
|
+
displayPaywalls();
|
|
11579
11589
|
}
|
|
11580
11590
|
}
|
|
11581
11591
|
};
|
|
@@ -11591,6 +11601,7 @@ const loadPaymentSDKs = () => {
|
|
|
11591
11601
|
pure_1(window.Pelcro.environment.stripe);
|
|
11592
11602
|
}
|
|
11593
11603
|
});
|
|
11604
|
+
window.Pelcro.helpers.loadSDK("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js", "apple-pay-sdk");
|
|
11594
11605
|
|
|
11595
11606
|
// Load PayPal SDKs
|
|
11596
11607
|
const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
|
|
@@ -11604,6 +11615,8 @@ const loadPaymentSDKs = () => {
|
|
|
11604
11615
|
if (!window.jQuery) {
|
|
11605
11616
|
window.Pelcro.helpers.loadSDK("https://code.jquery.com/jquery-3.6.0.slim.min.js", "vantiv-jquery-sdk");
|
|
11606
11617
|
}
|
|
11618
|
+
window.Pelcro.helpers.loadSDK("https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "vantiv-jquery-sdk");
|
|
11619
|
+
window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/eProtect-api3.js", "vantiv-eprotect-api");
|
|
11607
11620
|
if (!window.EprotectIframeClient) {
|
|
11608
11621
|
const PRELIVE_URL = "https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js";
|
|
11609
11622
|
const PRODUCTION_URL = "https://request.eprotect.vantivcnp.com/eProtect/js/eProtect-iframe-client3.min.js";
|
|
@@ -12404,6 +12417,7 @@ const LOADING = "LOADING";
|
|
|
12404
12417
|
const SUBMIT_PAYMENT = "SUBMIT_PAYMENT";
|
|
12405
12418
|
const SUBSCRIBE = "CREATE_SUBSCRIPTION";
|
|
12406
12419
|
const HANDLE_PAYPAL_SUBSCRIPTION = "HANDLE_PAYPAL_SUBSCRIPTION";
|
|
12420
|
+
const HANDLE_APPLEPAY_SUBSCRIPTION = "HANDLE_APPLEPAY_SUBSCRIPTION";
|
|
12407
12421
|
const DISABLE_COUPON_BUTTON = "DISABLE_COUPON_BUTTON";
|
|
12408
12422
|
const APPLY_COUPON_CODE = "APPLY_COUPON_CODE";
|
|
12409
12423
|
const REMOVE_APPLIED_COUPON = "REMOVE_APPLIED_COUPON";
|
|
@@ -17319,7 +17333,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17319
17333
|
updateTotalAmountWithTax();
|
|
17320
17334
|
}, []);
|
|
17321
17335
|
|
|
17322
|
-
|
|
17336
|
+
/* ====== Start Cybersource integration ======== */
|
|
17323
17337
|
const cybersourceErrorHandle = err => {
|
|
17324
17338
|
var _err$details, _err$details$response, _err$details$response2;
|
|
17325
17339
|
if ((err === null || err === void 0 ? void 0 : (_err$details = err.details) === null || _err$details === void 0 ? void 0 : (_err$details$response = _err$details.responseStatus) === null || _err$details$response === void 0 ? void 0 : (_err$details$response2 = _err$details$response.details) === null || _err$details$response2 === void 0 ? void 0 : _err$details$response2.length) > 0) {
|
|
@@ -17587,9 +17601,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17587
17601
|
});
|
|
17588
17602
|
};
|
|
17589
17603
|
|
|
17590
|
-
|
|
17604
|
+
/* ====== End Cybersource integration ======== */
|
|
17591
17605
|
|
|
17592
|
-
|
|
17606
|
+
/* ====== Start Tap integration ======== */
|
|
17593
17607
|
const submitUsingTap = state => {
|
|
17594
17608
|
var _ref3, _ref4, _ref5, _state$updatedPrice;
|
|
17595
17609
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
@@ -17853,28 +17867,28 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17853
17867
|
cardHolder: "Card Holder Name"
|
|
17854
17868
|
};
|
|
17855
17869
|
|
|
17856
|
-
//payment options
|
|
17870
|
+
// payment options
|
|
17857
17871
|
let paymentOptions = {
|
|
17858
17872
|
labels: labels,
|
|
17859
17873
|
TextDirection: "ltr"
|
|
17860
17874
|
};
|
|
17861
17875
|
|
|
17862
|
-
//create element, pass style and payment options
|
|
17876
|
+
// create element, pass style and payment options
|
|
17863
17877
|
let card = elements.create("card", {
|
|
17864
17878
|
style: style
|
|
17865
17879
|
}, paymentOptions);
|
|
17866
17880
|
|
|
17867
|
-
//mount element
|
|
17881
|
+
// mount element
|
|
17868
17882
|
card.mount("#tapPaymentIframe");
|
|
17869
17883
|
|
|
17870
|
-
//card change event listener
|
|
17884
|
+
// card change event listener
|
|
17871
17885
|
card.addEventListener("change", function (event) {
|
|
17872
|
-
//If needed
|
|
17886
|
+
// If needed
|
|
17873
17887
|
});
|
|
17874
17888
|
tapInstanceRef.current = tapKey;
|
|
17875
17889
|
tapInstanceCard.current = card;
|
|
17876
17890
|
};
|
|
17877
|
-
|
|
17891
|
+
/* ====== End Tap integration ======== */
|
|
17878
17892
|
|
|
17879
17893
|
const submitUsingVantiv = state => {
|
|
17880
17894
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
@@ -18062,7 +18076,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18062
18076
|
}
|
|
18063
18077
|
}, [selectedPaymentMethodId]);
|
|
18064
18078
|
|
|
18065
|
-
//Trigger the handleVantivPayment method when a
|
|
18079
|
+
// Trigger the handleVantivPayment method when a vantivPaymentRequest is present
|
|
18066
18080
|
React.useEffect(() => {
|
|
18067
18081
|
if (vantivPaymentRequest) {
|
|
18068
18082
|
handleVantivPayment(vantivPaymentRequest, updatedCouponCode);
|
|
@@ -18209,7 +18223,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18209
18223
|
if (err) {
|
|
18210
18224
|
onFailure(err);
|
|
18211
18225
|
|
|
18212
|
-
//reset the coupon code in local state
|
|
18226
|
+
// reset the coupon code in local state
|
|
18213
18227
|
setUpdatedCouponCode("");
|
|
18214
18228
|
dispatch({
|
|
18215
18229
|
type: SET_COUPON_ERROR,
|
|
@@ -18270,7 +18284,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18270
18284
|
payload: res.data.coupon
|
|
18271
18285
|
});
|
|
18272
18286
|
|
|
18273
|
-
//set the coupon code in local state to be able to use with Vantiv
|
|
18287
|
+
// set the coupon code in local state to be able to use with Vantiv
|
|
18274
18288
|
setUpdatedCouponCode(res.data.coupon.code);
|
|
18275
18289
|
dispatch({
|
|
18276
18290
|
type: SET_PERCENT_OFF,
|
|
@@ -18343,7 +18357,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18343
18357
|
const removeAppliedCoupon = state => {
|
|
18344
18358
|
state.couponCode = "";
|
|
18345
18359
|
|
|
18346
|
-
//reset the coupon code in local state
|
|
18360
|
+
// reset the coupon code in local state
|
|
18347
18361
|
setUpdatedCouponCode("");
|
|
18348
18362
|
dispatch({
|
|
18349
18363
|
type: SET_COUPON_ERROR,
|
|
@@ -19168,6 +19182,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19168
19182
|
handlePaypalSubscription(state, action.payload);
|
|
19169
19183
|
}
|
|
19170
19184
|
});
|
|
19185
|
+
case HANDLE_APPLEPAY_SUBSCRIPTION:
|
|
19186
|
+
return lib_5(state, (state, dispatch) => {
|
|
19187
|
+
setVantivPaymentRequest(action.payload);
|
|
19188
|
+
});
|
|
19171
19189
|
case SET_UPDATED_PRICE:
|
|
19172
19190
|
return lib_7({
|
|
19173
19191
|
...state,
|
|
@@ -20281,6 +20299,328 @@ const OrderCreateFreeButton = _ref => {
|
|
|
20281
20299
|
}, otherProps), t("labels.submit"));
|
|
20282
20300
|
};
|
|
20283
20301
|
|
|
20302
|
+
/* eslint-disable no-undef */
|
|
20303
|
+
|
|
20304
|
+
/**
|
|
20305
|
+
* ApplePayButton component
|
|
20306
|
+
* @return {JSX}
|
|
20307
|
+
*/
|
|
20308
|
+
const ApplePayButton = _ref => {
|
|
20309
|
+
var _ref2, _ref3, _state$updatedPrice, _props$plan;
|
|
20310
|
+
let {
|
|
20311
|
+
onClick,
|
|
20312
|
+
props,
|
|
20313
|
+
...otherProps
|
|
20314
|
+
} = _ref;
|
|
20315
|
+
const {
|
|
20316
|
+
dispatch,
|
|
20317
|
+
state
|
|
20318
|
+
} = React.useContext(store$k);
|
|
20319
|
+
const {
|
|
20320
|
+
plan,
|
|
20321
|
+
invoice
|
|
20322
|
+
} = usePelcro();
|
|
20323
|
+
const updatedPrice = (_ref2 = (_ref3 = (_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 && _ref3 !== void 0 ? _ref3 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref2 !== void 0 ? _ref2 : invoice.amount_remaining;
|
|
20324
|
+
React.useEffect(() => {
|
|
20325
|
+
if (window.ApplePaySession) {
|
|
20326
|
+
// TODO: Should not be hardcoded
|
|
20327
|
+
const merchantIdentifier = "merchant.pelcro.prelive";
|
|
20328
|
+
|
|
20329
|
+
// Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
|
|
20330
|
+
const promise = ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier);
|
|
20331
|
+
promise.then(function (canMakePayments) {
|
|
20332
|
+
if (canMakePayments) {
|
|
20333
|
+
// Display Apple Pay Buttons here…
|
|
20334
|
+
const pelcroApplyPayButton = document.getElementById("pelcro-apple-pay-button");
|
|
20335
|
+
if (pelcroApplyPayButton) {
|
|
20336
|
+
pelcroApplyPayButton.style.display = "block";
|
|
20337
|
+
}
|
|
20338
|
+
console.log("canMakePayments", canMakePayments);
|
|
20339
|
+
}
|
|
20340
|
+
});
|
|
20341
|
+
} else {
|
|
20342
|
+
console.error("ApplePay is not available on this browser");
|
|
20343
|
+
}
|
|
20344
|
+
}, []);
|
|
20345
|
+
function onApplePayButtonClicked() {
|
|
20346
|
+
var _window, _window$Pelcro, _window$Pelcro$user, _window$Pelcro$user$l;
|
|
20347
|
+
if (!ApplePaySession) {
|
|
20348
|
+
return;
|
|
20349
|
+
}
|
|
20350
|
+
dispatch({
|
|
20351
|
+
type: DISABLE_SUBMIT,
|
|
20352
|
+
payload: true
|
|
20353
|
+
});
|
|
20354
|
+
|
|
20355
|
+
// Define ApplePayPaymentRequest
|
|
20356
|
+
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/creating_an_apple_pay_session
|
|
20357
|
+
const ApplePayPaymentRequest = {
|
|
20358
|
+
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",
|
|
20359
|
+
currencyCode: (plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase()) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase()),
|
|
20360
|
+
merchantCapabilities: ["supports3DS"],
|
|
20361
|
+
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
20362
|
+
total: {
|
|
20363
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20364
|
+
amount: updatedPrice / 100
|
|
20365
|
+
},
|
|
20366
|
+
lineItems: [plan !== null && plan !== void 0 && plan.auto_renew ? {
|
|
20367
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20368
|
+
amount: updatedPrice / 100,
|
|
20369
|
+
paymentTiming: "recurring",
|
|
20370
|
+
recurringPaymentStartDate: new Date().toISOString(),
|
|
20371
|
+
recurringPaymentIntervalUnit: plan === null || plan === void 0 ? void 0 : plan.interval,
|
|
20372
|
+
recurringPaymentIntervalCount: plan === null || plan === void 0 ? void 0 : plan.interval_count
|
|
20373
|
+
} : {
|
|
20374
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20375
|
+
amount: updatedPrice / 100
|
|
20376
|
+
}],
|
|
20377
|
+
...((plan === null || plan === void 0 ? void 0 : plan.auto_renew) && {
|
|
20378
|
+
recurringPaymentRequest: {
|
|
20379
|
+
paymentDescription: "A description of the recurring payment to display to the user in the payment sheet.",
|
|
20380
|
+
regularBilling: {
|
|
20381
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20382
|
+
amount: updatedPrice / 100,
|
|
20383
|
+
paymentTiming: "recurring",
|
|
20384
|
+
recurringPaymentStartDate: new Date().toISOString(),
|
|
20385
|
+
recurringPaymentIntervalUnit: plan === null || plan === void 0 ? void 0 : plan.interval,
|
|
20386
|
+
recurringPaymentIntervalCount: plan === null || plan === void 0 ? void 0 : plan.interval_count
|
|
20387
|
+
},
|
|
20388
|
+
billingAgreement: "A localized billing agreement displayed to the user in the payment sheet prior to the payment authorization.",
|
|
20389
|
+
managementURL: "https://applepaydemo.apple.com",
|
|
20390
|
+
tokenNotificationURL: "https://applepaydemo.apple.com"
|
|
20391
|
+
}
|
|
20392
|
+
})
|
|
20393
|
+
};
|
|
20394
|
+
|
|
20395
|
+
// Create ApplePaySession
|
|
20396
|
+
// @todo - Clarify supported version parameter
|
|
20397
|
+
// @odo - Apple Pay demo uses version 6 (https://applepaydemo.apple.com/)
|
|
20398
|
+
const session = new ApplePaySession(3, ApplePayPaymentRequest);
|
|
20399
|
+
|
|
20400
|
+
// @todo - Detect whether web browser supports a particular Apple Pay version.
|
|
20401
|
+
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778014-supportsversion
|
|
20402
|
+
|
|
20403
|
+
session.onvalidatemerchant = async event => {
|
|
20404
|
+
const {
|
|
20405
|
+
validationURL
|
|
20406
|
+
} = event;
|
|
20407
|
+
console.log("then merchantSession step", event);
|
|
20408
|
+
// Call your own server to request a new merchant session.
|
|
20409
|
+
window.Pelcro.payment.startSession({
|
|
20410
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
20411
|
+
site_id: window.Pelcro.siteid,
|
|
20412
|
+
validation_url: validationURL
|
|
20413
|
+
}, (err, res) => {
|
|
20414
|
+
if (err) {
|
|
20415
|
+
// Handle any errors during merchant validation
|
|
20416
|
+
console.error("Merchant validation SDK error: ", err);
|
|
20417
|
+
session.abort();
|
|
20418
|
+
return dispatch({
|
|
20419
|
+
type: SHOW_ALERT,
|
|
20420
|
+
payload: {
|
|
20421
|
+
type: "error",
|
|
20422
|
+
content: getErrorMessages(err)
|
|
20423
|
+
}
|
|
20424
|
+
});
|
|
20425
|
+
}
|
|
20426
|
+
// Complete merchant validation with the merchant session object
|
|
20427
|
+
console.log("Merchant validation SDK response: ", res);
|
|
20428
|
+
const merchantSession = res;
|
|
20429
|
+
session.completeMerchantValidation(merchantSession);
|
|
20430
|
+
});
|
|
20431
|
+
};
|
|
20432
|
+
session.onpaymentmethodselected = event => {
|
|
20433
|
+
console.log("payment method selected step", event);
|
|
20434
|
+
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
20435
|
+
// No updates or errors are needed, pass an empty object.
|
|
20436
|
+
const newTotal = {
|
|
20437
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20438
|
+
amount: updatedPrice / 100
|
|
20439
|
+
};
|
|
20440
|
+
const newLineItems = [plan !== null && plan !== void 0 && plan.auto_renew ? {
|
|
20441
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20442
|
+
amount: updatedPrice / 100,
|
|
20443
|
+
paymentTiming: "recurring",
|
|
20444
|
+
recurringPaymentStartDate: new Date().toISOString(),
|
|
20445
|
+
recurringPaymentIntervalUnit: plan === null || plan === void 0 ? void 0 : plan.interval,
|
|
20446
|
+
recurringPaymentIntervalCount: plan === null || plan === void 0 ? void 0 : plan.interval_count
|
|
20447
|
+
} : {
|
|
20448
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20449
|
+
amount: updatedPrice / 100
|
|
20450
|
+
}];
|
|
20451
|
+
session.completePaymentMethodSelection(newTotal, newLineItems);
|
|
20452
|
+
};
|
|
20453
|
+
|
|
20454
|
+
// TODO: Check if onshippingmethodselected it should be implemented
|
|
20455
|
+
// session.onshippingmethodselected = (event) => {
|
|
20456
|
+
// console.log("on shipping method selected step", event);
|
|
20457
|
+
// // Define ApplePayShippingMethodUpdate based on the selected shipping method.
|
|
20458
|
+
// // No updates or errors are needed, pass an empty object.
|
|
20459
|
+
// const newTotal = {
|
|
20460
|
+
// label: plan?.nickname || `invoice #${invoice.id}`,
|
|
20461
|
+
// amount: updatedPrice / 100
|
|
20462
|
+
// };
|
|
20463
|
+
|
|
20464
|
+
// const newLineItems = [
|
|
20465
|
+
// plan?.auto_renew
|
|
20466
|
+
// ? {
|
|
20467
|
+
// label: plan?.nickname || `invoice #${invoice.id}`,
|
|
20468
|
+
// amount: updatedPrice / 100,
|
|
20469
|
+
// paymentTiming: "recurring",
|
|
20470
|
+
// recurringPaymentStartDate: new Date().toISOString(),
|
|
20471
|
+
// recurringPaymentIntervalUnit: plan?.interval,
|
|
20472
|
+
// recurringPaymentIntervalCount: plan?.interval_count
|
|
20473
|
+
// }
|
|
20474
|
+
// : {
|
|
20475
|
+
// label: plan?.nickname || `invoice #${invoice.id}`,
|
|
20476
|
+
// amount: updatedPrice / 100
|
|
20477
|
+
// }
|
|
20478
|
+
// ];
|
|
20479
|
+
|
|
20480
|
+
// session.completeShippingMethodSelection(newTotal, newLineItems);
|
|
20481
|
+
// };
|
|
20482
|
+
|
|
20483
|
+
// TODO: Check if onshippingcontactselected it should be implemented
|
|
20484
|
+
// session.onshippingcontactselected = (event) => {
|
|
20485
|
+
// console.log("on shipping contact selected step", event);
|
|
20486
|
+
// // Define ApplePayShippingContactUpdate based on the selected shipping contact.
|
|
20487
|
+
// const update = {};
|
|
20488
|
+
// session.completeShippingContactSelection(update);
|
|
20489
|
+
// };
|
|
20490
|
+
|
|
20491
|
+
session.onpaymentauthorized = event => {
|
|
20492
|
+
var _window$Pelcro$site$r, _window$Pelcro$site$r2;
|
|
20493
|
+
console.log("on payment authorized step", event);
|
|
20494
|
+
// Define ApplePayPaymentAuthorizationResult
|
|
20495
|
+
const result = {
|
|
20496
|
+
status: ApplePaySession.STATUS_SUCCESS
|
|
20497
|
+
};
|
|
20498
|
+
const {
|
|
20499
|
+
paymentData
|
|
20500
|
+
} = event.payment.token;
|
|
20501
|
+
const {
|
|
20502
|
+
data,
|
|
20503
|
+
signature,
|
|
20504
|
+
version
|
|
20505
|
+
} = paymentData;
|
|
20506
|
+
const {
|
|
20507
|
+
ephemeralPublicKey,
|
|
20508
|
+
publicKeyHash,
|
|
20509
|
+
transactionId
|
|
20510
|
+
} = paymentData.header;
|
|
20511
|
+
const applePayToken = {
|
|
20512
|
+
data: data,
|
|
20513
|
+
signature: signature,
|
|
20514
|
+
version: version,
|
|
20515
|
+
header: {
|
|
20516
|
+
ephemeralPublicKey: ephemeralPublicKey,
|
|
20517
|
+
publicKeyHash: publicKeyHash,
|
|
20518
|
+
transactionId: transactionId
|
|
20519
|
+
}
|
|
20520
|
+
};
|
|
20521
|
+
console.log(applePayToken);
|
|
20522
|
+
const payPageId = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings.pay_page_id;
|
|
20523
|
+
const reportGroup = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.vantiv_gateway_settings.report_group;
|
|
20524
|
+
const orderId = `pelcro-${new Date().getTime()}`;
|
|
20525
|
+
const eProtectRequest = {
|
|
20526
|
+
paypageId: payPageId,
|
|
20527
|
+
reportGroup: reportGroup,
|
|
20528
|
+
orderId: orderId,
|
|
20529
|
+
id: orderId,
|
|
20530
|
+
applepay: applePayToken,
|
|
20531
|
+
url: "https://request.eprotect.vantivprelive.com"
|
|
20532
|
+
};
|
|
20533
|
+
|
|
20534
|
+
// successCallback function to handle the response from WorldPay.
|
|
20535
|
+
function successCallback(vantivResponse) {
|
|
20536
|
+
const {
|
|
20537
|
+
expDate
|
|
20538
|
+
} = vantivResponse;
|
|
20539
|
+
console.log("Response:", vantivResponse);
|
|
20540
|
+
const expMonth = expDate.substring(0, 2);
|
|
20541
|
+
const expYear = expDate.substring(2);
|
|
20542
|
+
const vantivPaymentRequest = {
|
|
20543
|
+
...vantivResponse,
|
|
20544
|
+
expMonth: expMonth,
|
|
20545
|
+
expYear: expYear
|
|
20546
|
+
};
|
|
20547
|
+
|
|
20548
|
+
// Process the registrationId or continue with further payment processing.
|
|
20549
|
+
dispatch({
|
|
20550
|
+
type: HANDLE_APPLEPAY_SUBSCRIPTION,
|
|
20551
|
+
payload: vantivPaymentRequest
|
|
20552
|
+
});
|
|
20553
|
+
dispatch({
|
|
20554
|
+
type: LOADING,
|
|
20555
|
+
payload: true
|
|
20556
|
+
});
|
|
20557
|
+
session.completePayment(result);
|
|
20558
|
+
}
|
|
20559
|
+
|
|
20560
|
+
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
20561
|
+
function errorCallback(error) {
|
|
20562
|
+
console.error("Error retrieving Registration ID:", error);
|
|
20563
|
+
// Handle error appropriately.
|
|
20564
|
+
}
|
|
20565
|
+
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
20566
|
+
function timeoutCallback() {
|
|
20567
|
+
console.error("eProtect Timeout");
|
|
20568
|
+
// Handle error appropriately.
|
|
20569
|
+
}
|
|
20570
|
+
|
|
20571
|
+
new eProtect().sendToEprotect(eProtectRequest, {}, successCallback, errorCallback, timeoutCallback, 15000);
|
|
20572
|
+
};
|
|
20573
|
+
|
|
20574
|
+
// TODO: Check if oncouponcodechanged it should be implemented
|
|
20575
|
+
// session.oncouponcodechanged = (event) => {
|
|
20576
|
+
// console.log("on coupon code changed step", event);
|
|
20577
|
+
// // Define ApplePayCouponCodeUpdate
|
|
20578
|
+
// const newTotal = calculateNewTotal(event.couponCode);
|
|
20579
|
+
// const newLineItems = calculateNewLineItems(event.couponCode);
|
|
20580
|
+
// const newShippingMethods = calculateNewShippingMethods(
|
|
20581
|
+
// event.couponCode
|
|
20582
|
+
// );
|
|
20583
|
+
// const errors = calculateErrors(event.couponCode);
|
|
20584
|
+
|
|
20585
|
+
// session.completeCouponCodeChange({
|
|
20586
|
+
// newTotal: newTotal,
|
|
20587
|
+
// newLineItems: newLineItems,
|
|
20588
|
+
// newShippingMethods: newShippingMethods,
|
|
20589
|
+
// errors: errors
|
|
20590
|
+
// });
|
|
20591
|
+
// };
|
|
20592
|
+
|
|
20593
|
+
session.oncancel = event => {
|
|
20594
|
+
// Payment cancelled by WebKit
|
|
20595
|
+
console.log("on cancel step", event);
|
|
20596
|
+
dispatch({
|
|
20597
|
+
type: LOADING,
|
|
20598
|
+
payload: false
|
|
20599
|
+
});
|
|
20600
|
+
dispatch({
|
|
20601
|
+
type: DISABLE_SUBMIT,
|
|
20602
|
+
payload: false
|
|
20603
|
+
});
|
|
20604
|
+
};
|
|
20605
|
+
session.begin();
|
|
20606
|
+
}
|
|
20607
|
+
React.useEffect(() => {
|
|
20608
|
+
const pelcroApplyPayButton = document.getElementById("pelcro-apple-pay-button");
|
|
20609
|
+
if (pelcroApplyPayButton) {
|
|
20610
|
+
pelcroApplyPayButton.addEventListener("click", onApplePayButtonClicked);
|
|
20611
|
+
}
|
|
20612
|
+
}, []);
|
|
20613
|
+
return /*#__PURE__*/React__default['default'].createElement("apple-pay-button", {
|
|
20614
|
+
id: "pelcro-apple-pay-button",
|
|
20615
|
+
style: {
|
|
20616
|
+
display: "none"
|
|
20617
|
+
},
|
|
20618
|
+
buttonstyle: "black",
|
|
20619
|
+
type: "plain",
|
|
20620
|
+
locale: "en-US"
|
|
20621
|
+
});
|
|
20622
|
+
};
|
|
20623
|
+
|
|
20284
20624
|
/**
|
|
20285
20625
|
*
|
|
20286
20626
|
*/
|
|
@@ -20361,7 +20701,7 @@ function PaymentMethodView(_ref) {
|
|
|
20361
20701
|
className: "plc-mb-2"
|
|
20362
20702
|
}, /*#__PURE__*/React__default['default'].createElement(CouponCode, null), /*#__PURE__*/React__default['default'].createElement(DiscountedPrice, null)), /*#__PURE__*/React__default['default'].createElement(TaxAmount, null), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
20363
20703
|
className: "plc-grid plc-mt-4 plc-gap-y-2"
|
|
20364
|
-
}, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : null)))));
|
|
20704
|
+
}, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(ApplePayButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : null)))));
|
|
20365
20705
|
}
|
|
20366
20706
|
|
|
20367
20707
|
const SubscriptionRenewView = _ref => {
|
|
@@ -20735,7 +21075,7 @@ const SubscriptionCancelOptions = _ref => {
|
|
|
20735
21075
|
t
|
|
20736
21076
|
} = useTranslation("subscriptionCancel");
|
|
20737
21077
|
const phases = subscription === null || subscription === void 0 ? void 0 : (_subscription$schedul = subscription.schedule) === null || _subscription$schedul === void 0 ? void 0 : _subscription$schedul.phases;
|
|
20738
|
-
const lastPhase = phases[(phases === null || phases === void 0 ? void 0 : phases.length) - 1];
|
|
21078
|
+
const lastPhase = !phases ? [] : phases[(phases === null || phases === void 0 ? void 0 : phases.length) - 1];
|
|
20739
21079
|
const handleOptionSelect = event => {
|
|
20740
21080
|
dispatch({
|
|
20741
21081
|
type: SET_CANCEL_SUBSCRIPTION_OPTION,
|
|
@@ -20792,7 +21132,7 @@ const SubscriptionCancelView = props => {
|
|
|
20792
21132
|
};
|
|
20793
21133
|
const hasPhases = getPhases().length > 0;
|
|
20794
21134
|
const phases = subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : (_subscriptionToCancel7 = subscriptionToCancel.schedule) === null || _subscriptionToCancel7 === void 0 ? void 0 : _subscriptionToCancel7.phases;
|
|
20795
|
-
const lastPhase = phases[(phases === null || phases === void 0 ? void 0 : phases.length) - 1];
|
|
21135
|
+
const lastPhase = !phases ? [] : phases[(phases === null || phases === void 0 ? void 0 : phases.length) - 1];
|
|
20796
21136
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
20797
21137
|
id: "pelcro-subscription-cancel-view"
|
|
20798
21138
|
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
package/dist/index.esm.js
CHANGED
|
@@ -11531,21 +11531,31 @@ const initPaywalls = () => {
|
|
|
11531
11531
|
return;
|
|
11532
11532
|
}
|
|
11533
11533
|
const {
|
|
11534
|
-
switchView
|
|
11534
|
+
switchView,
|
|
11535
|
+
isAuthenticated
|
|
11535
11536
|
} = usePelcro.getStore();
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11537
|
+
function displayPaywalls() {
|
|
11538
|
+
if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayMeterPaywall()) {
|
|
11539
|
+
/*
|
|
11540
|
+
showing both the meter and the entitlements notification doesn't make sense from
|
|
11541
|
+
a product prespective + they would take half the screen on mobile devies, so we're
|
|
11542
|
+
not showing the meter, and only showing the entitlements notification.
|
|
11543
|
+
*/
|
|
11544
|
+
if (!didBlurContent) {
|
|
11545
|
+
switchView("meter");
|
|
11546
|
+
}
|
|
11547
|
+
} else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayNewsletterPaywall()) {
|
|
11548
|
+
switchView("newsletter");
|
|
11549
|
+
} else if (paywallMethods !== null && paywallMethods !== void 0 && paywallMethods.displayPaywall()) {
|
|
11550
|
+
switchView("plan-select");
|
|
11544
11551
|
}
|
|
11545
|
-
}
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11552
|
+
}
|
|
11553
|
+
if (isAuthenticated()) {
|
|
11554
|
+
addEventListener("PelcroUserLoaded", function () {
|
|
11555
|
+
displayPaywalls();
|
|
11556
|
+
});
|
|
11557
|
+
} else {
|
|
11558
|
+
displayPaywalls();
|
|
11549
11559
|
}
|
|
11550
11560
|
}
|
|
11551
11561
|
};
|
|
@@ -11561,6 +11571,7 @@ const loadPaymentSDKs = () => {
|
|
|
11561
11571
|
pure_1(window.Pelcro.environment.stripe);
|
|
11562
11572
|
}
|
|
11563
11573
|
});
|
|
11574
|
+
window.Pelcro.helpers.loadSDK("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js", "apple-pay-sdk");
|
|
11564
11575
|
|
|
11565
11576
|
// Load PayPal SDKs
|
|
11566
11577
|
const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
|
|
@@ -11574,6 +11585,8 @@ const loadPaymentSDKs = () => {
|
|
|
11574
11585
|
if (!window.jQuery) {
|
|
11575
11586
|
window.Pelcro.helpers.loadSDK("https://code.jquery.com/jquery-3.6.0.slim.min.js", "vantiv-jquery-sdk");
|
|
11576
11587
|
}
|
|
11588
|
+
window.Pelcro.helpers.loadSDK("https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "vantiv-jquery-sdk");
|
|
11589
|
+
window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/eProtect-api3.js", "vantiv-eprotect-api");
|
|
11577
11590
|
if (!window.EprotectIframeClient) {
|
|
11578
11591
|
const PRELIVE_URL = "https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js";
|
|
11579
11592
|
const PRODUCTION_URL = "https://request.eprotect.vantivcnp.com/eProtect/js/eProtect-iframe-client3.min.js";
|
|
@@ -12374,6 +12387,7 @@ const LOADING = "LOADING";
|
|
|
12374
12387
|
const SUBMIT_PAYMENT = "SUBMIT_PAYMENT";
|
|
12375
12388
|
const SUBSCRIBE = "CREATE_SUBSCRIPTION";
|
|
12376
12389
|
const HANDLE_PAYPAL_SUBSCRIPTION = "HANDLE_PAYPAL_SUBSCRIPTION";
|
|
12390
|
+
const HANDLE_APPLEPAY_SUBSCRIPTION = "HANDLE_APPLEPAY_SUBSCRIPTION";
|
|
12377
12391
|
const DISABLE_COUPON_BUTTON = "DISABLE_COUPON_BUTTON";
|
|
12378
12392
|
const APPLY_COUPON_CODE = "APPLY_COUPON_CODE";
|
|
12379
12393
|
const REMOVE_APPLIED_COUPON = "REMOVE_APPLIED_COUPON";
|
|
@@ -17289,7 +17303,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17289
17303
|
updateTotalAmountWithTax();
|
|
17290
17304
|
}, []);
|
|
17291
17305
|
|
|
17292
|
-
|
|
17306
|
+
/* ====== Start Cybersource integration ======== */
|
|
17293
17307
|
const cybersourceErrorHandle = err => {
|
|
17294
17308
|
var _err$details, _err$details$response, _err$details$response2;
|
|
17295
17309
|
if ((err === null || err === void 0 ? void 0 : (_err$details = err.details) === null || _err$details === void 0 ? void 0 : (_err$details$response = _err$details.responseStatus) === null || _err$details$response === void 0 ? void 0 : (_err$details$response2 = _err$details$response.details) === null || _err$details$response2 === void 0 ? void 0 : _err$details$response2.length) > 0) {
|
|
@@ -17557,9 +17571,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17557
17571
|
});
|
|
17558
17572
|
};
|
|
17559
17573
|
|
|
17560
|
-
|
|
17574
|
+
/* ====== End Cybersource integration ======== */
|
|
17561
17575
|
|
|
17562
|
-
|
|
17576
|
+
/* ====== Start Tap integration ======== */
|
|
17563
17577
|
const submitUsingTap = state => {
|
|
17564
17578
|
var _ref3, _ref4, _ref5, _state$updatedPrice;
|
|
17565
17579
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
@@ -17823,28 +17837,28 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17823
17837
|
cardHolder: "Card Holder Name"
|
|
17824
17838
|
};
|
|
17825
17839
|
|
|
17826
|
-
//payment options
|
|
17840
|
+
// payment options
|
|
17827
17841
|
let paymentOptions = {
|
|
17828
17842
|
labels: labels,
|
|
17829
17843
|
TextDirection: "ltr"
|
|
17830
17844
|
};
|
|
17831
17845
|
|
|
17832
|
-
//create element, pass style and payment options
|
|
17846
|
+
// create element, pass style and payment options
|
|
17833
17847
|
let card = elements.create("card", {
|
|
17834
17848
|
style: style
|
|
17835
17849
|
}, paymentOptions);
|
|
17836
17850
|
|
|
17837
|
-
//mount element
|
|
17851
|
+
// mount element
|
|
17838
17852
|
card.mount("#tapPaymentIframe");
|
|
17839
17853
|
|
|
17840
|
-
//card change event listener
|
|
17854
|
+
// card change event listener
|
|
17841
17855
|
card.addEventListener("change", function (event) {
|
|
17842
|
-
//If needed
|
|
17856
|
+
// If needed
|
|
17843
17857
|
});
|
|
17844
17858
|
tapInstanceRef.current = tapKey;
|
|
17845
17859
|
tapInstanceCard.current = card;
|
|
17846
17860
|
};
|
|
17847
|
-
|
|
17861
|
+
/* ====== End Tap integration ======== */
|
|
17848
17862
|
|
|
17849
17863
|
const submitUsingVantiv = state => {
|
|
17850
17864
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
@@ -18032,7 +18046,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18032
18046
|
}
|
|
18033
18047
|
}, [selectedPaymentMethodId]);
|
|
18034
18048
|
|
|
18035
|
-
//Trigger the handleVantivPayment method when a
|
|
18049
|
+
// Trigger the handleVantivPayment method when a vantivPaymentRequest is present
|
|
18036
18050
|
useEffect(() => {
|
|
18037
18051
|
if (vantivPaymentRequest) {
|
|
18038
18052
|
handleVantivPayment(vantivPaymentRequest, updatedCouponCode);
|
|
@@ -18179,7 +18193,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18179
18193
|
if (err) {
|
|
18180
18194
|
onFailure(err);
|
|
18181
18195
|
|
|
18182
|
-
//reset the coupon code in local state
|
|
18196
|
+
// reset the coupon code in local state
|
|
18183
18197
|
setUpdatedCouponCode("");
|
|
18184
18198
|
dispatch({
|
|
18185
18199
|
type: SET_COUPON_ERROR,
|
|
@@ -18240,7 +18254,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18240
18254
|
payload: res.data.coupon
|
|
18241
18255
|
});
|
|
18242
18256
|
|
|
18243
|
-
//set the coupon code in local state to be able to use with Vantiv
|
|
18257
|
+
// set the coupon code in local state to be able to use with Vantiv
|
|
18244
18258
|
setUpdatedCouponCode(res.data.coupon.code);
|
|
18245
18259
|
dispatch({
|
|
18246
18260
|
type: SET_PERCENT_OFF,
|
|
@@ -18313,7 +18327,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18313
18327
|
const removeAppliedCoupon = state => {
|
|
18314
18328
|
state.couponCode = "";
|
|
18315
18329
|
|
|
18316
|
-
//reset the coupon code in local state
|
|
18330
|
+
// reset the coupon code in local state
|
|
18317
18331
|
setUpdatedCouponCode("");
|
|
18318
18332
|
dispatch({
|
|
18319
18333
|
type: SET_COUPON_ERROR,
|
|
@@ -19138,6 +19152,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19138
19152
|
handlePaypalSubscription(state, action.payload);
|
|
19139
19153
|
}
|
|
19140
19154
|
});
|
|
19155
|
+
case HANDLE_APPLEPAY_SUBSCRIPTION:
|
|
19156
|
+
return lib_5(state, (state, dispatch) => {
|
|
19157
|
+
setVantivPaymentRequest(action.payload);
|
|
19158
|
+
});
|
|
19141
19159
|
case SET_UPDATED_PRICE:
|
|
19142
19160
|
return lib_7({
|
|
19143
19161
|
...state,
|
|
@@ -20251,6 +20269,328 @@ const OrderCreateFreeButton = _ref => {
|
|
|
20251
20269
|
}, otherProps), t("labels.submit"));
|
|
20252
20270
|
};
|
|
20253
20271
|
|
|
20272
|
+
/* eslint-disable no-undef */
|
|
20273
|
+
|
|
20274
|
+
/**
|
|
20275
|
+
* ApplePayButton component
|
|
20276
|
+
* @return {JSX}
|
|
20277
|
+
*/
|
|
20278
|
+
const ApplePayButton = _ref => {
|
|
20279
|
+
var _ref2, _ref3, _state$updatedPrice, _props$plan;
|
|
20280
|
+
let {
|
|
20281
|
+
onClick,
|
|
20282
|
+
props,
|
|
20283
|
+
...otherProps
|
|
20284
|
+
} = _ref;
|
|
20285
|
+
const {
|
|
20286
|
+
dispatch,
|
|
20287
|
+
state
|
|
20288
|
+
} = useContext(store$k);
|
|
20289
|
+
const {
|
|
20290
|
+
plan,
|
|
20291
|
+
invoice
|
|
20292
|
+
} = usePelcro();
|
|
20293
|
+
const updatedPrice = (_ref2 = (_ref3 = (_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 && _ref3 !== void 0 ? _ref3 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref2 !== void 0 ? _ref2 : invoice.amount_remaining;
|
|
20294
|
+
useEffect(() => {
|
|
20295
|
+
if (window.ApplePaySession) {
|
|
20296
|
+
// TODO: Should not be hardcoded
|
|
20297
|
+
const merchantIdentifier = "merchant.pelcro.prelive";
|
|
20298
|
+
|
|
20299
|
+
// Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
|
|
20300
|
+
const promise = ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier);
|
|
20301
|
+
promise.then(function (canMakePayments) {
|
|
20302
|
+
if (canMakePayments) {
|
|
20303
|
+
// Display Apple Pay Buttons here…
|
|
20304
|
+
const pelcroApplyPayButton = document.getElementById("pelcro-apple-pay-button");
|
|
20305
|
+
if (pelcroApplyPayButton) {
|
|
20306
|
+
pelcroApplyPayButton.style.display = "block";
|
|
20307
|
+
}
|
|
20308
|
+
console.log("canMakePayments", canMakePayments);
|
|
20309
|
+
}
|
|
20310
|
+
});
|
|
20311
|
+
} else {
|
|
20312
|
+
console.error("ApplePay is not available on this browser");
|
|
20313
|
+
}
|
|
20314
|
+
}, []);
|
|
20315
|
+
function onApplePayButtonClicked() {
|
|
20316
|
+
var _window, _window$Pelcro, _window$Pelcro$user, _window$Pelcro$user$l;
|
|
20317
|
+
if (!ApplePaySession) {
|
|
20318
|
+
return;
|
|
20319
|
+
}
|
|
20320
|
+
dispatch({
|
|
20321
|
+
type: DISABLE_SUBMIT,
|
|
20322
|
+
payload: true
|
|
20323
|
+
});
|
|
20324
|
+
|
|
20325
|
+
// Define ApplePayPaymentRequest
|
|
20326
|
+
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/creating_an_apple_pay_session
|
|
20327
|
+
const ApplePayPaymentRequest = {
|
|
20328
|
+
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",
|
|
20329
|
+
currencyCode: (plan === null || plan === void 0 ? void 0 : plan.currency.toUpperCase()) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency.toUpperCase()),
|
|
20330
|
+
merchantCapabilities: ["supports3DS"],
|
|
20331
|
+
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
20332
|
+
total: {
|
|
20333
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20334
|
+
amount: updatedPrice / 100
|
|
20335
|
+
},
|
|
20336
|
+
lineItems: [plan !== null && plan !== void 0 && plan.auto_renew ? {
|
|
20337
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20338
|
+
amount: updatedPrice / 100,
|
|
20339
|
+
paymentTiming: "recurring",
|
|
20340
|
+
recurringPaymentStartDate: new Date().toISOString(),
|
|
20341
|
+
recurringPaymentIntervalUnit: plan === null || plan === void 0 ? void 0 : plan.interval,
|
|
20342
|
+
recurringPaymentIntervalCount: plan === null || plan === void 0 ? void 0 : plan.interval_count
|
|
20343
|
+
} : {
|
|
20344
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20345
|
+
amount: updatedPrice / 100
|
|
20346
|
+
}],
|
|
20347
|
+
...((plan === null || plan === void 0 ? void 0 : plan.auto_renew) && {
|
|
20348
|
+
recurringPaymentRequest: {
|
|
20349
|
+
paymentDescription: "A description of the recurring payment to display to the user in the payment sheet.",
|
|
20350
|
+
regularBilling: {
|
|
20351
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20352
|
+
amount: updatedPrice / 100,
|
|
20353
|
+
paymentTiming: "recurring",
|
|
20354
|
+
recurringPaymentStartDate: new Date().toISOString(),
|
|
20355
|
+
recurringPaymentIntervalUnit: plan === null || plan === void 0 ? void 0 : plan.interval,
|
|
20356
|
+
recurringPaymentIntervalCount: plan === null || plan === void 0 ? void 0 : plan.interval_count
|
|
20357
|
+
},
|
|
20358
|
+
billingAgreement: "A localized billing agreement displayed to the user in the payment sheet prior to the payment authorization.",
|
|
20359
|
+
managementURL: "https://applepaydemo.apple.com",
|
|
20360
|
+
tokenNotificationURL: "https://applepaydemo.apple.com"
|
|
20361
|
+
}
|
|
20362
|
+
})
|
|
20363
|
+
};
|
|
20364
|
+
|
|
20365
|
+
// Create ApplePaySession
|
|
20366
|
+
// @todo - Clarify supported version parameter
|
|
20367
|
+
// @odo - Apple Pay demo uses version 6 (https://applepaydemo.apple.com/)
|
|
20368
|
+
const session = new ApplePaySession(3, ApplePayPaymentRequest);
|
|
20369
|
+
|
|
20370
|
+
// @todo - Detect whether web browser supports a particular Apple Pay version.
|
|
20371
|
+
// @see https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778014-supportsversion
|
|
20372
|
+
|
|
20373
|
+
session.onvalidatemerchant = async event => {
|
|
20374
|
+
const {
|
|
20375
|
+
validationURL
|
|
20376
|
+
} = event;
|
|
20377
|
+
console.log("then merchantSession step", event);
|
|
20378
|
+
// Call your own server to request a new merchant session.
|
|
20379
|
+
window.Pelcro.payment.startSession({
|
|
20380
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
20381
|
+
site_id: window.Pelcro.siteid,
|
|
20382
|
+
validation_url: validationURL
|
|
20383
|
+
}, (err, res) => {
|
|
20384
|
+
if (err) {
|
|
20385
|
+
// Handle any errors during merchant validation
|
|
20386
|
+
console.error("Merchant validation SDK error: ", err);
|
|
20387
|
+
session.abort();
|
|
20388
|
+
return dispatch({
|
|
20389
|
+
type: SHOW_ALERT,
|
|
20390
|
+
payload: {
|
|
20391
|
+
type: "error",
|
|
20392
|
+
content: getErrorMessages(err)
|
|
20393
|
+
}
|
|
20394
|
+
});
|
|
20395
|
+
}
|
|
20396
|
+
// Complete merchant validation with the merchant session object
|
|
20397
|
+
console.log("Merchant validation SDK response: ", res);
|
|
20398
|
+
const merchantSession = res;
|
|
20399
|
+
session.completeMerchantValidation(merchantSession);
|
|
20400
|
+
});
|
|
20401
|
+
};
|
|
20402
|
+
session.onpaymentmethodselected = event => {
|
|
20403
|
+
console.log("payment method selected step", event);
|
|
20404
|
+
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
20405
|
+
// No updates or errors are needed, pass an empty object.
|
|
20406
|
+
const newTotal = {
|
|
20407
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20408
|
+
amount: updatedPrice / 100
|
|
20409
|
+
};
|
|
20410
|
+
const newLineItems = [plan !== null && plan !== void 0 && plan.auto_renew ? {
|
|
20411
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20412
|
+
amount: updatedPrice / 100,
|
|
20413
|
+
paymentTiming: "recurring",
|
|
20414
|
+
recurringPaymentStartDate: new Date().toISOString(),
|
|
20415
|
+
recurringPaymentIntervalUnit: plan === null || plan === void 0 ? void 0 : plan.interval,
|
|
20416
|
+
recurringPaymentIntervalCount: plan === null || plan === void 0 ? void 0 : plan.interval_count
|
|
20417
|
+
} : {
|
|
20418
|
+
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || `invoice #${invoice.id}`,
|
|
20419
|
+
amount: updatedPrice / 100
|
|
20420
|
+
}];
|
|
20421
|
+
session.completePaymentMethodSelection(newTotal, newLineItems);
|
|
20422
|
+
};
|
|
20423
|
+
|
|
20424
|
+
// TODO: Check if onshippingmethodselected it should be implemented
|
|
20425
|
+
// session.onshippingmethodselected = (event) => {
|
|
20426
|
+
// console.log("on shipping method selected step", event);
|
|
20427
|
+
// // Define ApplePayShippingMethodUpdate based on the selected shipping method.
|
|
20428
|
+
// // No updates or errors are needed, pass an empty object.
|
|
20429
|
+
// const newTotal = {
|
|
20430
|
+
// label: plan?.nickname || `invoice #${invoice.id}`,
|
|
20431
|
+
// amount: updatedPrice / 100
|
|
20432
|
+
// };
|
|
20433
|
+
|
|
20434
|
+
// const newLineItems = [
|
|
20435
|
+
// plan?.auto_renew
|
|
20436
|
+
// ? {
|
|
20437
|
+
// label: plan?.nickname || `invoice #${invoice.id}`,
|
|
20438
|
+
// amount: updatedPrice / 100,
|
|
20439
|
+
// paymentTiming: "recurring",
|
|
20440
|
+
// recurringPaymentStartDate: new Date().toISOString(),
|
|
20441
|
+
// recurringPaymentIntervalUnit: plan?.interval,
|
|
20442
|
+
// recurringPaymentIntervalCount: plan?.interval_count
|
|
20443
|
+
// }
|
|
20444
|
+
// : {
|
|
20445
|
+
// label: plan?.nickname || `invoice #${invoice.id}`,
|
|
20446
|
+
// amount: updatedPrice / 100
|
|
20447
|
+
// }
|
|
20448
|
+
// ];
|
|
20449
|
+
|
|
20450
|
+
// session.completeShippingMethodSelection(newTotal, newLineItems);
|
|
20451
|
+
// };
|
|
20452
|
+
|
|
20453
|
+
// TODO: Check if onshippingcontactselected it should be implemented
|
|
20454
|
+
// session.onshippingcontactselected = (event) => {
|
|
20455
|
+
// console.log("on shipping contact selected step", event);
|
|
20456
|
+
// // Define ApplePayShippingContactUpdate based on the selected shipping contact.
|
|
20457
|
+
// const update = {};
|
|
20458
|
+
// session.completeShippingContactSelection(update);
|
|
20459
|
+
// };
|
|
20460
|
+
|
|
20461
|
+
session.onpaymentauthorized = event => {
|
|
20462
|
+
var _window$Pelcro$site$r, _window$Pelcro$site$r2;
|
|
20463
|
+
console.log("on payment authorized step", event);
|
|
20464
|
+
// Define ApplePayPaymentAuthorizationResult
|
|
20465
|
+
const result = {
|
|
20466
|
+
status: ApplePaySession.STATUS_SUCCESS
|
|
20467
|
+
};
|
|
20468
|
+
const {
|
|
20469
|
+
paymentData
|
|
20470
|
+
} = event.payment.token;
|
|
20471
|
+
const {
|
|
20472
|
+
data,
|
|
20473
|
+
signature,
|
|
20474
|
+
version
|
|
20475
|
+
} = paymentData;
|
|
20476
|
+
const {
|
|
20477
|
+
ephemeralPublicKey,
|
|
20478
|
+
publicKeyHash,
|
|
20479
|
+
transactionId
|
|
20480
|
+
} = paymentData.header;
|
|
20481
|
+
const applePayToken = {
|
|
20482
|
+
data: data,
|
|
20483
|
+
signature: signature,
|
|
20484
|
+
version: version,
|
|
20485
|
+
header: {
|
|
20486
|
+
ephemeralPublicKey: ephemeralPublicKey,
|
|
20487
|
+
publicKeyHash: publicKeyHash,
|
|
20488
|
+
transactionId: transactionId
|
|
20489
|
+
}
|
|
20490
|
+
};
|
|
20491
|
+
console.log(applePayToken);
|
|
20492
|
+
const payPageId = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings.pay_page_id;
|
|
20493
|
+
const reportGroup = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.vantiv_gateway_settings.report_group;
|
|
20494
|
+
const orderId = `pelcro-${new Date().getTime()}`;
|
|
20495
|
+
const eProtectRequest = {
|
|
20496
|
+
paypageId: payPageId,
|
|
20497
|
+
reportGroup: reportGroup,
|
|
20498
|
+
orderId: orderId,
|
|
20499
|
+
id: orderId,
|
|
20500
|
+
applepay: applePayToken,
|
|
20501
|
+
url: "https://request.eprotect.vantivprelive.com"
|
|
20502
|
+
};
|
|
20503
|
+
|
|
20504
|
+
// successCallback function to handle the response from WorldPay.
|
|
20505
|
+
function successCallback(vantivResponse) {
|
|
20506
|
+
const {
|
|
20507
|
+
expDate
|
|
20508
|
+
} = vantivResponse;
|
|
20509
|
+
console.log("Response:", vantivResponse);
|
|
20510
|
+
const expMonth = expDate.substring(0, 2);
|
|
20511
|
+
const expYear = expDate.substring(2);
|
|
20512
|
+
const vantivPaymentRequest = {
|
|
20513
|
+
...vantivResponse,
|
|
20514
|
+
expMonth: expMonth,
|
|
20515
|
+
expYear: expYear
|
|
20516
|
+
};
|
|
20517
|
+
|
|
20518
|
+
// Process the registrationId or continue with further payment processing.
|
|
20519
|
+
dispatch({
|
|
20520
|
+
type: HANDLE_APPLEPAY_SUBSCRIPTION,
|
|
20521
|
+
payload: vantivPaymentRequest
|
|
20522
|
+
});
|
|
20523
|
+
dispatch({
|
|
20524
|
+
type: LOADING,
|
|
20525
|
+
payload: true
|
|
20526
|
+
});
|
|
20527
|
+
session.completePayment(result);
|
|
20528
|
+
}
|
|
20529
|
+
|
|
20530
|
+
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
20531
|
+
function errorCallback(error) {
|
|
20532
|
+
console.error("Error retrieving Registration ID:", error);
|
|
20533
|
+
// Handle error appropriately.
|
|
20534
|
+
}
|
|
20535
|
+
// errorCallback function to handle any errors that may occur during the tokenization process.
|
|
20536
|
+
function timeoutCallback() {
|
|
20537
|
+
console.error("eProtect Timeout");
|
|
20538
|
+
// Handle error appropriately.
|
|
20539
|
+
}
|
|
20540
|
+
|
|
20541
|
+
new eProtect().sendToEprotect(eProtectRequest, {}, successCallback, errorCallback, timeoutCallback, 15000);
|
|
20542
|
+
};
|
|
20543
|
+
|
|
20544
|
+
// TODO: Check if oncouponcodechanged it should be implemented
|
|
20545
|
+
// session.oncouponcodechanged = (event) => {
|
|
20546
|
+
// console.log("on coupon code changed step", event);
|
|
20547
|
+
// // Define ApplePayCouponCodeUpdate
|
|
20548
|
+
// const newTotal = calculateNewTotal(event.couponCode);
|
|
20549
|
+
// const newLineItems = calculateNewLineItems(event.couponCode);
|
|
20550
|
+
// const newShippingMethods = calculateNewShippingMethods(
|
|
20551
|
+
// event.couponCode
|
|
20552
|
+
// );
|
|
20553
|
+
// const errors = calculateErrors(event.couponCode);
|
|
20554
|
+
|
|
20555
|
+
// session.completeCouponCodeChange({
|
|
20556
|
+
// newTotal: newTotal,
|
|
20557
|
+
// newLineItems: newLineItems,
|
|
20558
|
+
// newShippingMethods: newShippingMethods,
|
|
20559
|
+
// errors: errors
|
|
20560
|
+
// });
|
|
20561
|
+
// };
|
|
20562
|
+
|
|
20563
|
+
session.oncancel = event => {
|
|
20564
|
+
// Payment cancelled by WebKit
|
|
20565
|
+
console.log("on cancel step", event);
|
|
20566
|
+
dispatch({
|
|
20567
|
+
type: LOADING,
|
|
20568
|
+
payload: false
|
|
20569
|
+
});
|
|
20570
|
+
dispatch({
|
|
20571
|
+
type: DISABLE_SUBMIT,
|
|
20572
|
+
payload: false
|
|
20573
|
+
});
|
|
20574
|
+
};
|
|
20575
|
+
session.begin();
|
|
20576
|
+
}
|
|
20577
|
+
useEffect(() => {
|
|
20578
|
+
const pelcroApplyPayButton = document.getElementById("pelcro-apple-pay-button");
|
|
20579
|
+
if (pelcroApplyPayButton) {
|
|
20580
|
+
pelcroApplyPayButton.addEventListener("click", onApplePayButtonClicked);
|
|
20581
|
+
}
|
|
20582
|
+
}, []);
|
|
20583
|
+
return /*#__PURE__*/React__default.createElement("apple-pay-button", {
|
|
20584
|
+
id: "pelcro-apple-pay-button",
|
|
20585
|
+
style: {
|
|
20586
|
+
display: "none"
|
|
20587
|
+
},
|
|
20588
|
+
buttonstyle: "black",
|
|
20589
|
+
type: "plain",
|
|
20590
|
+
locale: "en-US"
|
|
20591
|
+
});
|
|
20592
|
+
};
|
|
20593
|
+
|
|
20254
20594
|
/**
|
|
20255
20595
|
*
|
|
20256
20596
|
*/
|
|
@@ -20331,7 +20671,7 @@ function PaymentMethodView(_ref) {
|
|
|
20331
20671
|
className: "plc-mb-2"
|
|
20332
20672
|
}, /*#__PURE__*/React__default.createElement(CouponCode, null), /*#__PURE__*/React__default.createElement(DiscountedPrice, null)), /*#__PURE__*/React__default.createElement(TaxAmount, null), /*#__PURE__*/React__default.createElement("div", {
|
|
20333
20673
|
className: "plc-grid plc-mt-4 plc-gap-y-2"
|
|
20334
|
-
}, /*#__PURE__*/React__default.createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : null)))));
|
|
20674
|
+
}, /*#__PURE__*/React__default.createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ApplePayButton, null), /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : null)))));
|
|
20335
20675
|
}
|
|
20336
20676
|
|
|
20337
20677
|
const SubscriptionRenewView = _ref => {
|
|
@@ -20705,7 +21045,7 @@ const SubscriptionCancelOptions = _ref => {
|
|
|
20705
21045
|
t
|
|
20706
21046
|
} = useTranslation("subscriptionCancel");
|
|
20707
21047
|
const phases = subscription === null || subscription === void 0 ? void 0 : (_subscription$schedul = subscription.schedule) === null || _subscription$schedul === void 0 ? void 0 : _subscription$schedul.phases;
|
|
20708
|
-
const lastPhase = phases[(phases === null || phases === void 0 ? void 0 : phases.length) - 1];
|
|
21048
|
+
const lastPhase = !phases ? [] : phases[(phases === null || phases === void 0 ? void 0 : phases.length) - 1];
|
|
20709
21049
|
const handleOptionSelect = event => {
|
|
20710
21050
|
dispatch({
|
|
20711
21051
|
type: SET_CANCEL_SUBSCRIPTION_OPTION,
|
|
@@ -20762,7 +21102,7 @@ const SubscriptionCancelView = props => {
|
|
|
20762
21102
|
};
|
|
20763
21103
|
const hasPhases = getPhases().length > 0;
|
|
20764
21104
|
const phases = subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : (_subscriptionToCancel7 = subscriptionToCancel.schedule) === null || _subscriptionToCancel7 === void 0 ? void 0 : _subscriptionToCancel7.phases;
|
|
20765
|
-
const lastPhase = phases[(phases === null || phases === void 0 ? void 0 : phases.length) - 1];
|
|
21105
|
+
const lastPhase = !phases ? [] : phases[(phases === null || phases === void 0 ? void 0 : phases.length) - 1];
|
|
20766
21106
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
20767
21107
|
id: "pelcro-subscription-cancel-view"
|
|
20768
21108
|
}, /*#__PURE__*/React__default.createElement("div", {
|
package/dist/pelcro.css
CHANGED
|
@@ -1722,6 +1722,14 @@ in order to scope selectors under pelcro-root
|
|
|
1722
1722
|
border-right: 0;
|
|
1723
1723
|
}
|
|
1724
1724
|
|
|
1725
|
+
apple-pay-button {
|
|
1726
|
+
--apple-pay-button-width: 100%;
|
|
1727
|
+
--apple-pay-button-height: 48px;
|
|
1728
|
+
--apple-pay-button-border-radius: 0.25rem;
|
|
1729
|
+
--apple-pay-button-padding: 0px 0px;
|
|
1730
|
+
--apple-pay-button-box-sizing: border-box;
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1725
1733
|
/* utilities */
|
|
1726
1734
|
|
|
1727
1735
|
.pelcro-root .plc-space-x-0 > :not([hidden]) ~ :not([hidden]) {
|