@pelcro/react-pelcro-js 3.49.0 → 3.51.0
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 +544 -228
- package/dist/index.esm.js +544 -228
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -11652,6 +11652,101 @@ function getFourDigitYear(lastTwoDigits) {
|
|
|
11652
11652
|
return fourDigitYear;
|
|
11653
11653
|
}
|
|
11654
11654
|
|
|
11655
|
+
/**
|
|
11656
|
+
* Loads Braintree Drop-in UI script
|
|
11657
|
+
* @returns {Promise} Promise that resolves when script is loaded
|
|
11658
|
+
*/
|
|
11659
|
+
function loadBraintreeScript() {
|
|
11660
|
+
return new Promise((resolve, reject) => {
|
|
11661
|
+
// Check if script is already loaded
|
|
11662
|
+
if (window.braintree) {
|
|
11663
|
+
console.log("Braintree script already loaded");
|
|
11664
|
+
resolve(window.braintree);
|
|
11665
|
+
return;
|
|
11666
|
+
}
|
|
11667
|
+
console.log("Loading Braintree script...");
|
|
11668
|
+
const script = document.createElement("script");
|
|
11669
|
+
script.src = "https://js.braintreegateway.com/web/dropin/1.45.1/js/dropin.js";
|
|
11670
|
+
script.onload = () => {
|
|
11671
|
+
console.log("Braintree script loaded successfully");
|
|
11672
|
+
resolve(window.braintree);
|
|
11673
|
+
};
|
|
11674
|
+
script.onerror = error => {
|
|
11675
|
+
console.error("Failed to load Braintree script:", error);
|
|
11676
|
+
reject(new Error("Failed to load Braintree script"));
|
|
11677
|
+
};
|
|
11678
|
+
document.head.appendChild(script);
|
|
11679
|
+
});
|
|
11680
|
+
}
|
|
11681
|
+
|
|
11682
|
+
/**
|
|
11683
|
+
* Creates Braintree Drop-in UI instance
|
|
11684
|
+
* @param {string} authorization - Braintree authorization token
|
|
11685
|
+
* @param {string} selector - CSS selector for the container
|
|
11686
|
+
* @param {Object} options - Additional options for dropin creation
|
|
11687
|
+
* @returns {Promise} Promise that resolves with the dropin instance
|
|
11688
|
+
*/
|
|
11689
|
+
function createBraintreeDropin(authorization, selector) {
|
|
11690
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
11691
|
+
console.log("Creating Braintree Drop-in with:", {
|
|
11692
|
+
authorization: authorization ? "present" : "missing",
|
|
11693
|
+
selector,
|
|
11694
|
+
options
|
|
11695
|
+
});
|
|
11696
|
+
return loadBraintreeScript().then(() => {
|
|
11697
|
+
console.log("Braintree script loaded, creating dropin...");
|
|
11698
|
+
return new Promise((resolve, reject) => {
|
|
11699
|
+
window.braintree.dropin.create({
|
|
11700
|
+
authorization,
|
|
11701
|
+
selector,
|
|
11702
|
+
...options
|
|
11703
|
+
}, (err, instance) => {
|
|
11704
|
+
if (err) {
|
|
11705
|
+
console.error("Braintree dropin creation failed:", err);
|
|
11706
|
+
reject(err);
|
|
11707
|
+
} else {
|
|
11708
|
+
console.log("Braintree dropin created successfully:", instance);
|
|
11709
|
+
resolve(instance);
|
|
11710
|
+
}
|
|
11711
|
+
});
|
|
11712
|
+
});
|
|
11713
|
+
});
|
|
11714
|
+
}
|
|
11715
|
+
|
|
11716
|
+
/**
|
|
11717
|
+
* Requests payment method from Braintree Drop-in UI
|
|
11718
|
+
* @param {Object} instance - Braintree dropin instance
|
|
11719
|
+
* @returns {Promise} Promise that resolves with payment method payload
|
|
11720
|
+
*/
|
|
11721
|
+
function requestBraintreePaymentMethod(instance) {
|
|
11722
|
+
return new Promise((resolve, reject) => {
|
|
11723
|
+
instance.requestPaymentMethod((err, payload) => {
|
|
11724
|
+
if (err) {
|
|
11725
|
+
reject(err);
|
|
11726
|
+
} else {
|
|
11727
|
+
resolve(payload);
|
|
11728
|
+
}
|
|
11729
|
+
});
|
|
11730
|
+
});
|
|
11731
|
+
}
|
|
11732
|
+
|
|
11733
|
+
/**
|
|
11734
|
+
* Requests payment method from Braintree Hosted Fields
|
|
11735
|
+
* @param {Object} hostedFieldsInstance - Braintree hosted fields instance
|
|
11736
|
+
* @returns {Promise} Promise that resolves with payment method payload
|
|
11737
|
+
*/
|
|
11738
|
+
function requestBraintreeHostedFieldsPaymentMethod(hostedFieldsInstance) {
|
|
11739
|
+
return new Promise((resolve, reject) => {
|
|
11740
|
+
hostedFieldsInstance.tokenize((err, payload) => {
|
|
11741
|
+
if (err) {
|
|
11742
|
+
reject(err);
|
|
11743
|
+
} else {
|
|
11744
|
+
resolve(payload);
|
|
11745
|
+
}
|
|
11746
|
+
});
|
|
11747
|
+
});
|
|
11748
|
+
}
|
|
11749
|
+
|
|
11655
11750
|
/**
|
|
11656
11751
|
* @typedef {Object} OptionsType
|
|
11657
11752
|
* @property {boolean} loadPaymentSDKs
|
|
@@ -11762,6 +11857,7 @@ const loadPaymentSDKs = () => {
|
|
|
11762
11857
|
// "braintree-3D-secure-sdk"
|
|
11763
11858
|
// );
|
|
11764
11859
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.99.0/js/hosted-fields.min.js", "braintree-hosted-fields-sdk");
|
|
11860
|
+
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/dropin/1.45.1/js/dropin.js", "braintree-dropin-sdk");
|
|
11765
11861
|
}
|
|
11766
11862
|
|
|
11767
11863
|
// Load Vantiv SDKs
|
|
@@ -11806,16 +11902,16 @@ const initSecuritySdk = () => {
|
|
|
11806
11902
|
});
|
|
11807
11903
|
};
|
|
11808
11904
|
const initGATracking = () => {
|
|
11809
|
-
var _window, _window$Pelcro, _window$Pelcro$uiSett;
|
|
11905
|
+
var _window, _window$Pelcro, _window$Pelcro$uiSett, _window2, _window2$Pelcro, _window2$Pelcro$uiSet;
|
|
11810
11906
|
const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
|
|
11907
|
+
// Respect disablePageViewEvents flag from uiSettings
|
|
11908
|
+
const disablePageViewEvents = ((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$Pelcro = _window2.Pelcro) === null || _window2$Pelcro === void 0 ? void 0 : (_window2$Pelcro$uiSet = _window2$Pelcro.uiSettings) === null || _window2$Pelcro$uiSet === void 0 ? void 0 : _window2$Pelcro$uiSet.disablePageViewEvents) || false;
|
|
11811
11909
|
if (window.Pelcro.site.read().google_analytics_id) {
|
|
11812
11910
|
if (enableReactGA4) {
|
|
11813
|
-
// Initialize ReactGA4 with your tracking ID
|
|
11814
|
-
ReactGA4.initialize(window.Pelcro.site.read().google_analytics_id);
|
|
11815
|
-
// Enable e-commerce tracking
|
|
11911
|
+
// Initialize ReactGA4 with your tracking ID and options, only once
|
|
11816
11912
|
ReactGA4.initialize(window.Pelcro.site.read().google_analytics_id, {
|
|
11817
11913
|
gaOptions: {
|
|
11818
|
-
send_page_view: true,
|
|
11914
|
+
send_page_view: disablePageViewEvents ? false : true,
|
|
11819
11915
|
ecommerce: {
|
|
11820
11916
|
enabled: true
|
|
11821
11917
|
}
|
|
@@ -11829,8 +11925,8 @@ const initGATracking = () => {
|
|
|
11829
11925
|
}
|
|
11830
11926
|
};
|
|
11831
11927
|
const dispatchModalDisplayEvents = modalName => {
|
|
11832
|
-
var
|
|
11833
|
-
const enableReactGA4 = (
|
|
11928
|
+
var _window3, _window3$Pelcro, _window3$Pelcro$uiSet, _modalName$replace, _modalName$replace2;
|
|
11929
|
+
const enableReactGA4 = (_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$Pelcro = _window3.Pelcro) === null || _window3$Pelcro === void 0 ? void 0 : (_window3$Pelcro$uiSet = _window3$Pelcro.uiSettings) === null || _window3$Pelcro$uiSet === void 0 ? void 0 : _window3$Pelcro$uiSet.enableReactGA4;
|
|
11834
11930
|
const formattedAction = modalName === null || modalName === void 0 ? void 0 : (_modalName$replace = modalName.replace("pelcro-", "")) === null || _modalName$replace === void 0 ? void 0 : _modalName$replace.replaceAll("-", " ");
|
|
11835
11931
|
if (enableReactGA4) {
|
|
11836
11932
|
ReactGA4.event(`${formattedAction} viewed`, {
|
|
@@ -16424,10 +16520,6 @@ var es_13 = es.StripeProvider;
|
|
|
16424
16520
|
|
|
16425
16521
|
function _classPrivateFieldInitSpec$1(obj, privateMap, value) { _checkPrivateRedeclaration$1(obj, privateMap); privateMap.set(obj, value); }
|
|
16426
16522
|
function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
16427
|
-
/**
|
|
16428
|
-
* @TODO: All payment related business logic should end up moving
|
|
16429
|
-
* to this service, and out of react components.
|
|
16430
|
-
*/
|
|
16431
16523
|
|
|
16432
16524
|
/**
|
|
16433
16525
|
* Enum for payment types
|
|
@@ -16563,6 +16655,16 @@ class StripeGateway {
|
|
|
16563
16655
|
console.error("Unsupported payment method: Stripe Gateway");
|
|
16564
16656
|
}
|
|
16565
16657
|
});
|
|
16658
|
+
_defineProperty$3(this, "createDropin", function (authorization, selector) {
|
|
16659
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
16660
|
+
return createBraintreeDropin(authorization, selector, options);
|
|
16661
|
+
});
|
|
16662
|
+
_defineProperty$3(this, "requestPaymentMethod", instance => {
|
|
16663
|
+
return requestBraintreePaymentMethod(instance);
|
|
16664
|
+
});
|
|
16665
|
+
_defineProperty$3(this, "loadScript", () => {
|
|
16666
|
+
return loadBraintreeScript();
|
|
16667
|
+
});
|
|
16566
16668
|
_classPrivateFieldInitSpec$1(this, _createSubscription, {
|
|
16567
16669
|
writable: true,
|
|
16568
16670
|
value: (options, callback) => {
|
|
@@ -17243,6 +17345,9 @@ class TapGateway {
|
|
|
17243
17345
|
}
|
|
17244
17346
|
}
|
|
17245
17347
|
|
|
17348
|
+
/**
|
|
17349
|
+
* Cybersource gateway strategy
|
|
17350
|
+
*/
|
|
17246
17351
|
/**
|
|
17247
17352
|
* Cybersource gateway strategy
|
|
17248
17353
|
*/
|
|
@@ -17289,7 +17394,9 @@ class CybersourceGateway {
|
|
|
17289
17394
|
quantity = 1,
|
|
17290
17395
|
addressId,
|
|
17291
17396
|
isExistingSource,
|
|
17292
|
-
fingerprint_session_id
|
|
17397
|
+
fingerprint_session_id,
|
|
17398
|
+
cardExpirationMonth,
|
|
17399
|
+
cardExpirationYear
|
|
17293
17400
|
} = options;
|
|
17294
17401
|
const params = isExistingSource ? {
|
|
17295
17402
|
source_id: token
|
|
@@ -17305,6 +17412,8 @@ class CybersourceGateway {
|
|
|
17305
17412
|
coupon_code: couponCode,
|
|
17306
17413
|
address_id: product.address_required ? addressId : null,
|
|
17307
17414
|
fingerprint_session_id: fingerprint_session_id,
|
|
17415
|
+
card_expiration_month: cardExpirationMonth,
|
|
17416
|
+
card_expiration_year: cardExpirationYear,
|
|
17308
17417
|
...params
|
|
17309
17418
|
}, (err, res) => {
|
|
17310
17419
|
callback(err, res);
|
|
@@ -17321,7 +17430,9 @@ class CybersourceGateway {
|
|
|
17321
17430
|
couponCode,
|
|
17322
17431
|
product,
|
|
17323
17432
|
addressId,
|
|
17324
|
-
isExistingSource
|
|
17433
|
+
isExistingSource,
|
|
17434
|
+
cardExpirationMonth,
|
|
17435
|
+
cardExpirationYear
|
|
17325
17436
|
} = options;
|
|
17326
17437
|
const params = isExistingSource ? {
|
|
17327
17438
|
source_id: token
|
|
@@ -17336,6 +17447,8 @@ class CybersourceGateway {
|
|
|
17336
17447
|
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
17337
17448
|
subscription_id: subscriptionIdToRenew,
|
|
17338
17449
|
address_id: product.address_required ? addressId : null,
|
|
17450
|
+
card_expiration_month: cardExpirationMonth,
|
|
17451
|
+
card_expiration_year: cardExpirationYear,
|
|
17339
17452
|
...params
|
|
17340
17453
|
}, (err, res) => {
|
|
17341
17454
|
callback(err, res);
|
|
@@ -17353,7 +17466,9 @@ class CybersourceGateway {
|
|
|
17353
17466
|
giftRecipient,
|
|
17354
17467
|
quantity = 1,
|
|
17355
17468
|
addressId,
|
|
17356
|
-
isExistingSource
|
|
17469
|
+
isExistingSource,
|
|
17470
|
+
cardExpirationMonth,
|
|
17471
|
+
cardExpirationYear
|
|
17357
17472
|
} = options;
|
|
17358
17473
|
const params = isExistingSource ? {
|
|
17359
17474
|
source_id: token
|
|
@@ -17373,6 +17488,8 @@ class CybersourceGateway {
|
|
|
17373
17488
|
gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
|
|
17374
17489
|
gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
|
|
17375
17490
|
address_id: product.address_required ? addressId : null,
|
|
17491
|
+
card_expiration_month: cardExpirationMonth,
|
|
17492
|
+
card_expiration_year: cardExpirationYear,
|
|
17376
17493
|
...params
|
|
17377
17494
|
}, (err, res) => {
|
|
17378
17495
|
callback(err, res);
|
|
@@ -17389,7 +17506,9 @@ class CybersourceGateway {
|
|
|
17389
17506
|
plan,
|
|
17390
17507
|
couponCode,
|
|
17391
17508
|
addressId,
|
|
17392
|
-
isExistingSource
|
|
17509
|
+
isExistingSource,
|
|
17510
|
+
cardExpirationMonth,
|
|
17511
|
+
cardExpirationYear
|
|
17393
17512
|
} = options;
|
|
17394
17513
|
const params = isExistingSource ? {
|
|
17395
17514
|
source_id: token
|
|
@@ -17403,6 +17522,8 @@ class CybersourceGateway {
|
|
|
17403
17522
|
coupon_code: couponCode,
|
|
17404
17523
|
subscription_id: subscriptionIdToRenew,
|
|
17405
17524
|
address_id: product.address_required ? addressId : null,
|
|
17525
|
+
card_expiration_month: cardExpirationMonth,
|
|
17526
|
+
card_expiration_year: cardExpirationYear,
|
|
17406
17527
|
...params
|
|
17407
17528
|
}, (err, res) => {
|
|
17408
17529
|
callback(err, res);
|
|
@@ -17417,7 +17538,9 @@ class CybersourceGateway {
|
|
|
17417
17538
|
items,
|
|
17418
17539
|
couponCode,
|
|
17419
17540
|
addressId,
|
|
17420
|
-
isExistingSource
|
|
17541
|
+
isExistingSource,
|
|
17542
|
+
cardExpirationMonth,
|
|
17543
|
+
cardExpirationYear
|
|
17421
17544
|
} = options;
|
|
17422
17545
|
const params = isExistingSource ? {
|
|
17423
17546
|
source_id: token
|
|
@@ -17432,7 +17555,9 @@ class CybersourceGateway {
|
|
|
17432
17555
|
...params,
|
|
17433
17556
|
...(addressId && {
|
|
17434
17557
|
address_id: addressId
|
|
17435
|
-
})
|
|
17558
|
+
}),
|
|
17559
|
+
card_expiration_month: cardExpirationMonth,
|
|
17560
|
+
card_expiration_year: cardExpirationYear
|
|
17436
17561
|
}, (err, res) => {
|
|
17437
17562
|
callback(err, res);
|
|
17438
17563
|
});
|
|
@@ -17783,6 +17908,79 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17783
17908
|
});
|
|
17784
17909
|
updateTotalAmountWithTax();
|
|
17785
17910
|
}, []);
|
|
17911
|
+
// Helper function to calculate total amount for payment methods
|
|
17912
|
+
const calculateTotalAmount = (state, plan, invoice, order) => {
|
|
17913
|
+
var _ref2, _ref3, _state$updatedPrice;
|
|
17914
|
+
const getOrderItemsTotal = () => {
|
|
17915
|
+
if (!order) {
|
|
17916
|
+
return null;
|
|
17917
|
+
}
|
|
17918
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
17919
|
+
if (isQuickPurchase) {
|
|
17920
|
+
return order.price * order.quantity;
|
|
17921
|
+
}
|
|
17922
|
+
if (order.length === 0) {
|
|
17923
|
+
return null;
|
|
17924
|
+
}
|
|
17925
|
+
return order.reduce((total, item) => {
|
|
17926
|
+
return total + item.price * item.quantity;
|
|
17927
|
+
}, 0);
|
|
17928
|
+
};
|
|
17929
|
+
return (_ref2 = (_ref3 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref3 !== void 0 ? _ref3 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref2 !== void 0 ? _ref2 : getOrderItemsTotal();
|
|
17930
|
+
};
|
|
17931
|
+
|
|
17932
|
+
// Helper function to get currency from the appropriate source
|
|
17933
|
+
const getCurrencyFromPaymentType = (plan, order, invoice) => {
|
|
17934
|
+
if (plan) {
|
|
17935
|
+
return plan.currency;
|
|
17936
|
+
} else if (order) {
|
|
17937
|
+
var _order$;
|
|
17938
|
+
// Handle both single order and array of orders
|
|
17939
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
17940
|
+
return isQuickPurchase ? order.currency : (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency;
|
|
17941
|
+
} else if (invoice) {
|
|
17942
|
+
return invoice.currency;
|
|
17943
|
+
}
|
|
17944
|
+
return "USD"; // Default fallback
|
|
17945
|
+
};
|
|
17946
|
+
|
|
17947
|
+
// Helper function to get payment label
|
|
17948
|
+
const getPaymentLabel = (plan, order, invoice) => {
|
|
17949
|
+
var _window$Pelcro$site$r;
|
|
17950
|
+
if (plan) {
|
|
17951
|
+
return plan.nickname || plan.description || "Subscription";
|
|
17952
|
+
} else if (order) {
|
|
17953
|
+
// Handle both single order and array of orders
|
|
17954
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
17955
|
+
if (isQuickPurchase) {
|
|
17956
|
+
return order.name || "Order";
|
|
17957
|
+
} else {
|
|
17958
|
+
return order.length === 1 ? order[0].name : "Order";
|
|
17959
|
+
}
|
|
17960
|
+
} else if (invoice) {
|
|
17961
|
+
return `Invoice #${invoice.id}`;
|
|
17962
|
+
}
|
|
17963
|
+
return ((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.name) || "Payment";
|
|
17964
|
+
};
|
|
17965
|
+
|
|
17966
|
+
// Helper function to format amount for payment methods (Apple Pay, Google Pay)
|
|
17967
|
+
const formatPaymentAmount = function (totalAmount, currency) {
|
|
17968
|
+
var _window$Pelcro2, _window$Pelcro2$utils, _window$Pelcro2$utils2, _currency$toUpperCase;
|
|
17969
|
+
let paymentMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
17970
|
+
if (!totalAmount) return "0.00";
|
|
17971
|
+
const isZeroDecimal = ((_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$utils = _window$Pelcro2.utils) === null || _window$Pelcro2$utils === void 0 ? void 0 : (_window$Pelcro2$utils2 = _window$Pelcro2$utils.isCurrencyZeroDecimal) === null || _window$Pelcro2$utils2 === void 0 ? void 0 : _window$Pelcro2$utils2.call(_window$Pelcro2$utils, currency)) || ["BIF", "CLP", "DJF", "GNF", "JPY", "KMF", "KRW", "MGA", "PYG", "RWF", "UGX", "VND", "VUV", "XAF", "XOF", "XPF"].includes(currency === null || currency === void 0 ? void 0 : (_currency$toUpperCase = currency.toUpperCase) === null || _currency$toUpperCase === void 0 ? void 0 : _currency$toUpperCase.call(currency));
|
|
17972
|
+
|
|
17973
|
+
// Payment methods expect amount in major currency unit (dollars, not cents)
|
|
17974
|
+
let finalAmount;
|
|
17975
|
+
if (isZeroDecimal) {
|
|
17976
|
+
finalAmount = Math.round(totalAmount).toString();
|
|
17977
|
+
} else {
|
|
17978
|
+
// Convert from cents to dollars and format with 2 decimal places
|
|
17979
|
+
finalAmount = (totalAmount / 100).toFixed(2);
|
|
17980
|
+
}
|
|
17981
|
+
console.log(`${paymentMethod} amount:`, finalAmount, "currency:", currency, "type:", type);
|
|
17982
|
+
return String(finalAmount);
|
|
17983
|
+
};
|
|
17786
17984
|
|
|
17787
17985
|
/* ====== Start Cybersource integration ======== */
|
|
17788
17986
|
const cybersourceErrorHandle = err => {
|
|
@@ -17792,10 +17990,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17792
17990
|
const errorMessages = [];
|
|
17793
17991
|
|
|
17794
17992
|
// enumerable error (ex: validation errors)
|
|
17795
|
-
Object.values(err === null || err === void 0 ? void 0 : (_err$details2 = err.details) === null || _err$details2 === void 0 ? void 0 : (_err$details2$respons = _err$details2.responseStatus) === null || _err$details2$respons === void 0 ? void 0 : _err$details2$respons.details).forEach(
|
|
17993
|
+
Object.values(err === null || err === void 0 ? void 0 : (_err$details2 = err.details) === null || _err$details2 === void 0 ? void 0 : (_err$details2$respons = _err$details2.responseStatus) === null || _err$details2$respons === void 0 ? void 0 : _err$details2$respons.details).forEach(_ref4 => {
|
|
17796
17994
|
let {
|
|
17797
17995
|
message
|
|
17798
|
-
} =
|
|
17996
|
+
} = _ref4;
|
|
17799
17997
|
errorMessages.push(message);
|
|
17800
17998
|
});
|
|
17801
17999
|
|
|
@@ -17839,7 +18037,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17839
18037
|
}
|
|
17840
18038
|
});
|
|
17841
18039
|
}
|
|
17842
|
-
handleCybersourcePayment(response
|
|
18040
|
+
handleCybersourcePayment(response, state);
|
|
17843
18041
|
});
|
|
17844
18042
|
};
|
|
17845
18043
|
function handleCybersourcePayment(paymentRequest, state) {
|
|
@@ -17857,7 +18055,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17857
18055
|
window.Pelcro.source.create({
|
|
17858
18056
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
17859
18057
|
token: paymentRequest,
|
|
17860
|
-
gateway: "cybersource"
|
|
18058
|
+
gateway: "cybersource",
|
|
18059
|
+
cardExpirationMonth: state.month,
|
|
18060
|
+
cardExpirationYear: state.year
|
|
17861
18061
|
}, (err, res) => {
|
|
17862
18062
|
dispatch({
|
|
17863
18063
|
type: DISABLE_SUBMIT,
|
|
@@ -17885,6 +18085,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17885
18085
|
content: t("messages.sourceUpdated")
|
|
17886
18086
|
}
|
|
17887
18087
|
});
|
|
18088
|
+
|
|
18089
|
+
// Reinitialize Cybersource microform after successful payment
|
|
18090
|
+
setTimeout(() => {
|
|
18091
|
+
cybersourceInstanceRef.current = null;
|
|
18092
|
+
initCybersourceScript();
|
|
18093
|
+
}, 1000);
|
|
17888
18094
|
onSuccess(res);
|
|
17889
18095
|
} //
|
|
17890
18096
|
);
|
|
@@ -17908,11 +18114,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17908
18114
|
product,
|
|
17909
18115
|
isExistingSource: isUsingExistingPaymentMethod,
|
|
17910
18116
|
subscriptionIdToRenew,
|
|
17911
|
-
addressId: selectedAddressId
|
|
18117
|
+
addressId: selectedAddressId,
|
|
18118
|
+
cardExpirationMonth: state.month,
|
|
18119
|
+
cardExpirationYear: state.year
|
|
17912
18120
|
}, (err, res) => {
|
|
17913
18121
|
if (err) {
|
|
17914
18122
|
return handlePaymentError(err);
|
|
17915
18123
|
}
|
|
18124
|
+
|
|
18125
|
+
// Reinitialize Cybersource microform after successful payment
|
|
18126
|
+
setTimeout(() => {
|
|
18127
|
+
cybersourceInstanceRef.current = null;
|
|
18128
|
+
initCybersourceScript();
|
|
18129
|
+
}, 1000);
|
|
17916
18130
|
onSuccess(res);
|
|
17917
18131
|
});
|
|
17918
18132
|
} else if (giftSubscriprition) {
|
|
@@ -17925,11 +18139,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17925
18139
|
product,
|
|
17926
18140
|
isExistingSource: isUsingExistingPaymentMethod,
|
|
17927
18141
|
giftRecipient,
|
|
17928
|
-
addressId: selectedAddressId
|
|
18142
|
+
addressId: selectedAddressId,
|
|
18143
|
+
cardExpirationMonth: state.month,
|
|
18144
|
+
cardExpirationYear: state.year
|
|
17929
18145
|
}, (err, res) => {
|
|
17930
18146
|
if (err) {
|
|
17931
18147
|
return handlePaymentError(err);
|
|
17932
18148
|
}
|
|
18149
|
+
|
|
18150
|
+
// Reinitialize Cybersource microform after successful payment
|
|
18151
|
+
setTimeout(() => {
|
|
18152
|
+
cybersourceInstanceRef.current = null;
|
|
18153
|
+
initCybersourceScript();
|
|
18154
|
+
}, 1000);
|
|
17933
18155
|
onSuccess(res);
|
|
17934
18156
|
});
|
|
17935
18157
|
} else if (renewSubscription) {
|
|
@@ -17942,11 +18164,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17942
18164
|
product,
|
|
17943
18165
|
isExistingSource: isUsingExistingPaymentMethod,
|
|
17944
18166
|
subscriptionIdToRenew,
|
|
17945
|
-
addressId: selectedAddressId
|
|
18167
|
+
addressId: selectedAddressId,
|
|
18168
|
+
cardExpirationMonth: state.month,
|
|
18169
|
+
cardExpirationYear: state.year
|
|
17946
18170
|
}, (err, res) => {
|
|
17947
18171
|
if (err) {
|
|
17948
18172
|
return handlePaymentError(err);
|
|
17949
18173
|
}
|
|
18174
|
+
|
|
18175
|
+
// Reinitialize Cybersource microform after successful payment
|
|
18176
|
+
setTimeout(() => {
|
|
18177
|
+
cybersourceInstanceRef.current = null;
|
|
18178
|
+
initCybersourceScript();
|
|
18179
|
+
}, 1000);
|
|
17950
18180
|
onSuccess(res);
|
|
17951
18181
|
});
|
|
17952
18182
|
} else if (createSubscription) {
|
|
@@ -17959,27 +18189,32 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17959
18189
|
product,
|
|
17960
18190
|
isExistingSource: isUsingExistingPaymentMethod,
|
|
17961
18191
|
addressId: selectedAddressId,
|
|
17962
|
-
fingerprint_session_id: state.cyberSourceSessionId
|
|
18192
|
+
fingerprint_session_id: state.cyberSourceSessionId,
|
|
18193
|
+
cardExpirationMonth: state.month,
|
|
18194
|
+
cardExpirationYear: state.year
|
|
17963
18195
|
}, (err, res) => {
|
|
17964
18196
|
if (err) {
|
|
17965
18197
|
return handlePaymentError(err);
|
|
17966
18198
|
}
|
|
18199
|
+
|
|
18200
|
+
// Reinitialize Cybersource microform after successful payment
|
|
18201
|
+
setTimeout(() => {
|
|
18202
|
+
cybersourceInstanceRef.current = null;
|
|
18203
|
+
initCybersourceScript();
|
|
18204
|
+
}, 1000);
|
|
17967
18205
|
onSuccess(res);
|
|
17968
18206
|
});
|
|
17969
18207
|
}
|
|
17970
18208
|
}
|
|
17971
18209
|
}
|
|
17972
|
-
|
|
17973
|
-
|
|
17974
|
-
|
|
17975
|
-
}
|
|
17976
|
-
cybersourceInstanceRef.current = microformInstance;
|
|
17977
|
-
};
|
|
18210
|
+
|
|
18211
|
+
// No longer needed - microform instance is stored directly in initCybersourceScript
|
|
18212
|
+
|
|
17978
18213
|
const appendCybersourceFingerprintScripts = () => {
|
|
17979
|
-
var _window$Pelcro$site$
|
|
18214
|
+
var _window$Pelcro$site$r2, _window$Pelcro$site$r3, _window$Pelcro$site$r4, _window$Pelcro$site$r5;
|
|
17980
18215
|
const uniqueId = crypto.randomUUID();
|
|
17981
|
-
const sessionID = ((_window$Pelcro$site$
|
|
17982
|
-
const orgID = (_window$Pelcro$site$
|
|
18216
|
+
const sessionID = ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : (_window$Pelcro$site$r3 = _window$Pelcro$site$r2.cybersource_gateway_settings) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.merchant_id) + uniqueId;
|
|
18217
|
+
const orgID = (_window$Pelcro$site$r4 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : (_window$Pelcro$site$r5 = _window$Pelcro$site$r4.cybersource_gateway_settings) === null || _window$Pelcro$site$r5 === void 0 ? void 0 : _window$Pelcro$site$r5.org_id;
|
|
17983
18218
|
const fingerPrintScript = document.querySelector(`script[src="https://h.online-metrix.net/fp/tags.js?org_id=${orgID}&session_id=${sessionID}"]`);
|
|
17984
18219
|
const fingerPringIframe = document.querySelector(`iframe[src="https://h.online-metrix.net/fp/tags?org_id=${orgID}&session_id=${sessionID}"]`);
|
|
17985
18220
|
if (!fingerPrintScript && !fingerPringIframe) {
|
|
@@ -17998,6 +18233,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17998
18233
|
}
|
|
17999
18234
|
};
|
|
18000
18235
|
const initCybersourceScript = () => {
|
|
18236
|
+
// Clear existing card number field before reinitializing
|
|
18237
|
+
const cardNumberElement = document.querySelector("#cybersourceCardNumber");
|
|
18238
|
+
if (cardNumberElement) {
|
|
18239
|
+
cardNumberElement.innerHTML = "";
|
|
18240
|
+
}
|
|
18241
|
+
|
|
18001
18242
|
// jwk api call
|
|
18002
18243
|
window.Pelcro.payment.getJWK({
|
|
18003
18244
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
@@ -18022,34 +18263,56 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18022
18263
|
});
|
|
18023
18264
|
}
|
|
18024
18265
|
const {
|
|
18025
|
-
key: jwk
|
|
18266
|
+
key: jwk,
|
|
18267
|
+
captureContext,
|
|
18268
|
+
js_client
|
|
18026
18269
|
} = res;
|
|
18027
|
-
|
|
18028
|
-
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
|
|
18032
|
-
|
|
18033
|
-
|
|
18034
|
-
|
|
18035
|
-
|
|
18036
|
-
|
|
18037
|
-
|
|
18038
|
-
|
|
18039
|
-
|
|
18040
|
-
|
|
18041
|
-
|
|
18042
|
-
|
|
18043
|
-
|
|
18044
|
-
|
|
18045
|
-
|
|
18046
|
-
|
|
18047
|
-
|
|
18048
|
-
|
|
18049
|
-
|
|
18270
|
+
|
|
18271
|
+
// Load the SDK from the dynamic URL (if not already loaded)
|
|
18272
|
+
const existingScript = document.querySelector(`script[src="${js_client}"]`);
|
|
18273
|
+
if (!existingScript) {
|
|
18274
|
+
window.Pelcro.helpers.loadSDK(js_client, "cybersource-cdn");
|
|
18275
|
+
}
|
|
18276
|
+
const initializeMicroform = () => {
|
|
18277
|
+
// SETUP MICROFORM
|
|
18278
|
+
// eslint-disable-next-line no-undef
|
|
18279
|
+
const flex = new Flex(captureContext);
|
|
18280
|
+
const microform = flex.microform({
|
|
18281
|
+
styles: {
|
|
18282
|
+
input: {
|
|
18283
|
+
"font-size": "14px",
|
|
18284
|
+
"font-family": "helvetica, tahoma, calibri, sans-serif",
|
|
18285
|
+
color: "#555"
|
|
18286
|
+
},
|
|
18287
|
+
":focus": {
|
|
18288
|
+
color: "blue"
|
|
18289
|
+
},
|
|
18290
|
+
":disabled": {
|
|
18291
|
+
cursor: "not-allowed"
|
|
18292
|
+
},
|
|
18293
|
+
valid: {
|
|
18294
|
+
color: "#3c763d"
|
|
18295
|
+
},
|
|
18296
|
+
invalid: {
|
|
18297
|
+
color: "#a94442"
|
|
18298
|
+
}
|
|
18050
18299
|
}
|
|
18051
|
-
}
|
|
18052
|
-
|
|
18300
|
+
});
|
|
18301
|
+
const number = microform.createField("number", {
|
|
18302
|
+
placeholder: "Enter your card number"
|
|
18303
|
+
});
|
|
18304
|
+
number.load("#cybersourceCardNumber");
|
|
18305
|
+
cybersourceInstanceRef.current = microform;
|
|
18306
|
+
};
|
|
18307
|
+
|
|
18308
|
+
// Wait for SDK to load then initialize microform
|
|
18309
|
+
if (existingScript) {
|
|
18310
|
+
// Script already loaded, initialize immediately
|
|
18311
|
+
initializeMicroform();
|
|
18312
|
+
} else {
|
|
18313
|
+
// Wait for new script to load
|
|
18314
|
+
document.querySelector(`script[src="${js_client}"]`).addEventListener("load", initializeMicroform);
|
|
18315
|
+
}
|
|
18053
18316
|
});
|
|
18054
18317
|
};
|
|
18055
18318
|
|
|
@@ -18057,7 +18320,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18057
18320
|
|
|
18058
18321
|
/* ====== Start Tap integration ======== */
|
|
18059
18322
|
const submitUsingTap = state => {
|
|
18060
|
-
var
|
|
18323
|
+
var _ref5, _ref6, _ref7, _state$updatedPrice2;
|
|
18061
18324
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
18062
18325
|
if (isUsingExistingPaymentMethod) {
|
|
18063
18326
|
// no need to create a new source using tap
|
|
@@ -18081,7 +18344,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18081
18344
|
return total + item.price * item.quantity;
|
|
18082
18345
|
}, 0);
|
|
18083
18346
|
};
|
|
18084
|
-
const totalAmount = (
|
|
18347
|
+
const totalAmount = (_ref5 = (_ref6 = (_ref7 = (_state$updatedPrice2 = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice2 !== void 0 ? _state$updatedPrice2 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref7 !== void 0 ? _ref7 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref6 !== void 0 ? _ref6 : getOrderItemsTotal()) !== null && _ref5 !== void 0 ? _ref5 : 10;
|
|
18085
18348
|
tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
|
|
18086
18349
|
if (result.error) {
|
|
18087
18350
|
// Inform the user if there was an error
|
|
@@ -18291,8 +18554,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18291
18554
|
}
|
|
18292
18555
|
}
|
|
18293
18556
|
const initTapScript = () => {
|
|
18294
|
-
var _window$Pelcro$site$
|
|
18295
|
-
const tapKey = window.Tapjsli((_window$Pelcro$site$
|
|
18557
|
+
var _window$Pelcro$site$r6;
|
|
18558
|
+
const tapKey = window.Tapjsli((_window$Pelcro$site$r6 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r6 === void 0 ? void 0 : _window$Pelcro$site$r6.tap_gateway_settings.publishable_key);
|
|
18296
18559
|
let elements = tapKey.elements({});
|
|
18297
18560
|
let style = {
|
|
18298
18561
|
base: {
|
|
@@ -18342,8 +18605,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18342
18605
|
};
|
|
18343
18606
|
/* ====== End Tap integration ======== */
|
|
18344
18607
|
|
|
18345
|
-
/* ====== Start Braintree integration
|
|
18346
|
-
const
|
|
18608
|
+
/* ====== Start Braintree Drop-in UI integration ======== */
|
|
18609
|
+
const braintreeDropinRef = React__default.useRef(null);
|
|
18347
18610
|
function getClientToken() {
|
|
18348
18611
|
return new Promise((resolve, reject) => {
|
|
18349
18612
|
window.Pelcro.payment.generateClientToken({
|
|
@@ -18362,18 +18625,46 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18362
18625
|
async function initializeBraintree() {
|
|
18363
18626
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
18364
18627
|
if (cardProcessor === "braintree" && !selectedPaymentMethodId) {
|
|
18628
|
+
// Clear container before initializing
|
|
18629
|
+
const dropinContainer = document.getElementById("dropin-container");
|
|
18630
|
+
if (dropinContainer) dropinContainer.innerHTML = "";
|
|
18365
18631
|
const braintreeToken = await getClientToken();
|
|
18366
18632
|
const isBraintreeEnabled = Boolean(braintreeToken);
|
|
18367
18633
|
if (!isBraintreeEnabled) {
|
|
18368
18634
|
console.error("Braintree integration is currently not enabled on this site's config");
|
|
18369
18635
|
return;
|
|
18370
18636
|
}
|
|
18637
|
+
console.log("braintreeToken", plan);
|
|
18371
18638
|
if (type !== "updatePaymentSource") {
|
|
18372
|
-
|
|
18373
|
-
|
|
18374
|
-
|
|
18375
|
-
|
|
18376
|
-
|
|
18639
|
+
console.log("Setting skeleton loader to true at start of Braintree initialization");
|
|
18640
|
+
dispatch({
|
|
18641
|
+
type: SKELETON_LOADER,
|
|
18642
|
+
payload: true
|
|
18643
|
+
});
|
|
18644
|
+
try {
|
|
18645
|
+
var _window$Pelcro$site$r7, _window$Pelcro$site$r8;
|
|
18646
|
+
// Ensure the DOM element exists before creating Drop-in UI
|
|
18647
|
+
const dropinContainer = document.querySelector("#dropin-container");
|
|
18648
|
+
if (!dropinContainer) {
|
|
18649
|
+
console.error("Drop-in container not found. Waiting for DOM to be ready...");
|
|
18650
|
+
dispatch({
|
|
18651
|
+
type: SKELETON_LOADER,
|
|
18652
|
+
payload: false
|
|
18653
|
+
});
|
|
18654
|
+
return;
|
|
18655
|
+
}
|
|
18656
|
+
|
|
18657
|
+
// Small delay to ensure DOM is fully rendered
|
|
18658
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
18659
|
+
|
|
18660
|
+
// Calculate Google Pay amount using the same logic as Apple Pay
|
|
18661
|
+
const totalAmount = calculateTotalAmount(state, plan, invoice, order);
|
|
18662
|
+
const currency = getCurrencyFromPaymentType(plan, order, invoice);
|
|
18663
|
+
const googlePayAmount = formatPaymentAmount(totalAmount, currency, "Google Pay");
|
|
18664
|
+
|
|
18665
|
+
// Create Braintree Drop-in UI instance
|
|
18666
|
+
braintreeDropinRef.current = await createBraintreeDropin(braintreeToken, "#dropin-container", {
|
|
18667
|
+
// Customize the Drop-in UI appearance
|
|
18377
18668
|
styles: {
|
|
18378
18669
|
input: {
|
|
18379
18670
|
"font-size": "14px"
|
|
@@ -18385,48 +18676,85 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18385
18676
|
color: "green"
|
|
18386
18677
|
}
|
|
18387
18678
|
},
|
|
18388
|
-
|
|
18389
|
-
|
|
18390
|
-
|
|
18391
|
-
|
|
18392
|
-
|
|
18393
|
-
|
|
18394
|
-
|
|
18395
|
-
|
|
18679
|
+
// Disable PayPal to avoid conflicts with existing PayPal SDK
|
|
18680
|
+
// paypal: {
|
|
18681
|
+
// flow: "vault"
|
|
18682
|
+
// },
|
|
18683
|
+
// Enable Apple Pay if available
|
|
18684
|
+
applePay: {
|
|
18685
|
+
displayName: ((_window$Pelcro$site$r7 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r7 === void 0 ? void 0 : _window$Pelcro$site$r7.name) || "Pelcro",
|
|
18686
|
+
paymentRequest: {
|
|
18687
|
+
total: {
|
|
18688
|
+
label: getPaymentLabel(plan, order, invoice),
|
|
18689
|
+
amount: (() => {
|
|
18690
|
+
const totalAmount = calculateTotalAmount(state, plan, invoice, order);
|
|
18691
|
+
const currency = getCurrencyFromPaymentType(plan, order, invoice);
|
|
18692
|
+
return formatPaymentAmount(totalAmount, currency, "Apple Pay");
|
|
18693
|
+
})()
|
|
18694
|
+
}
|
|
18695
|
+
}
|
|
18696
|
+
},
|
|
18697
|
+
// Enable Google Pay for both orders and subscriptions
|
|
18698
|
+
googlePay: {
|
|
18699
|
+
googlePayVersion: 2,
|
|
18700
|
+
merchantId: (_window$Pelcro$site$r8 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r8 === void 0 ? void 0 : _window$Pelcro$site$r8.google_merchant_id,
|
|
18701
|
+
transactionInfo: {
|
|
18702
|
+
totalPriceStatus: "FINAL",
|
|
18703
|
+
totalPrice: googlePayAmount,
|
|
18704
|
+
currencyCode: (() => {
|
|
18705
|
+
const currency = getCurrencyFromPaymentType(plan, order, invoice);
|
|
18706
|
+
return (currency === null || currency === void 0 ? void 0 : currency.toUpperCase()) || "USD";
|
|
18707
|
+
})()
|
|
18396
18708
|
},
|
|
18397
|
-
|
|
18398
|
-
|
|
18399
|
-
|
|
18709
|
+
// Add button configuration
|
|
18710
|
+
button: {
|
|
18711
|
+
color: "black",
|
|
18712
|
+
type: type === "createPayment" ? "subscribe" : "buy"
|
|
18400
18713
|
}
|
|
18401
18714
|
}
|
|
18402
|
-
};
|
|
18715
|
+
});
|
|
18716
|
+
console.log("Setting skeleton loader to false after successful Braintree initialization");
|
|
18403
18717
|
dispatch({
|
|
18404
18718
|
type: SKELETON_LOADER,
|
|
18405
|
-
payload:
|
|
18719
|
+
payload: false
|
|
18406
18720
|
});
|
|
18407
|
-
|
|
18408
|
-
|
|
18409
|
-
|
|
18410
|
-
|
|
18411
|
-
|
|
18412
|
-
|
|
18413
|
-
|
|
18721
|
+
|
|
18722
|
+
// Clear any error alerts that were shown during initialization
|
|
18723
|
+
dispatch({
|
|
18724
|
+
type: SHOW_ALERT,
|
|
18725
|
+
payload: {
|
|
18726
|
+
type: "error",
|
|
18727
|
+
content: ""
|
|
18414
18728
|
}
|
|
18415
18729
|
});
|
|
18416
|
-
|
|
18417
|
-
|
|
18418
|
-
|
|
18419
|
-
|
|
18420
|
-
|
|
18421
|
-
|
|
18422
|
-
|
|
18423
|
-
|
|
18424
|
-
|
|
18425
|
-
|
|
18426
|
-
|
|
18730
|
+
} catch (error) {
|
|
18731
|
+
var _error$message, _error$message2, _error$message3, _error$message4;
|
|
18732
|
+
console.error("Failed to initialize Braintree Drop-in UI:", error);
|
|
18733
|
+
|
|
18734
|
+
// Check if it's a Google Pay specific error
|
|
18735
|
+
if (error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes("OR_BIBED_06") || error !== null && error !== void 0 && (_error$message2 = error.message) !== null && _error$message2 !== void 0 && _error$message2.includes("Google Pay")) {
|
|
18736
|
+
console.warn("Google Pay configuration issue detected. " + `Transaction type: ${type}. ` + "This might be due to merchant settings or unsupported payment flow.");
|
|
18737
|
+
}
|
|
18738
|
+
dispatch({
|
|
18739
|
+
type: SKELETON_LOADER,
|
|
18740
|
+
payload: false
|
|
18427
18741
|
});
|
|
18428
|
-
|
|
18742
|
+
|
|
18743
|
+
// Don't show error to user for Google Pay configuration issues
|
|
18744
|
+
// as it's expected for subscriptions
|
|
18745
|
+
if (!(error !== null && error !== void 0 && (_error$message3 = error.message) !== null && _error$message3 !== void 0 && _error$message3.includes("OR_BIBED_06")) && !(error !== null && error !== void 0 && (_error$message4 = error.message) !== null && _error$message4 !== void 0 && _error$message4.includes("Google Pay"))) {
|
|
18746
|
+
dispatch({
|
|
18747
|
+
type: SHOW_ALERT,
|
|
18748
|
+
payload: {
|
|
18749
|
+
type: "error",
|
|
18750
|
+
content: "Failed to initialize payment form. Please refresh and try again."
|
|
18751
|
+
}
|
|
18752
|
+
});
|
|
18753
|
+
}
|
|
18754
|
+
}
|
|
18429
18755
|
} else if (type == "updatePaymentSource" && paymentMethodToEdit) {
|
|
18756
|
+
// For updating payment methods, we still use hosted fields
|
|
18757
|
+
// as Drop-in UI doesn't support partial updates
|
|
18430
18758
|
const {
|
|
18431
18759
|
properties
|
|
18432
18760
|
} = paymentMethodToEdit !== null && paymentMethodToEdit !== void 0 ? paymentMethodToEdit : {};
|
|
@@ -18434,9 +18762,14 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18434
18762
|
exp_month: expMonth,
|
|
18435
18763
|
exp_year: expYear
|
|
18436
18764
|
} = properties !== null && properties !== void 0 ? properties : {};
|
|
18437
|
-
|
|
18438
|
-
|
|
18439
|
-
|
|
18765
|
+
dispatch({
|
|
18766
|
+
type: SKELETON_LOADER,
|
|
18767
|
+
payload: true
|
|
18768
|
+
});
|
|
18769
|
+
try {
|
|
18770
|
+
const clientInstance = await new window.braintree.client.create({
|
|
18771
|
+
authorization: braintreeToken
|
|
18772
|
+
});
|
|
18440
18773
|
const options = {
|
|
18441
18774
|
client: clientInstance,
|
|
18442
18775
|
styles: {
|
|
@@ -18458,41 +18791,28 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18458
18791
|
expirationYear: {
|
|
18459
18792
|
container: "#expiration-year",
|
|
18460
18793
|
prefill: expYear
|
|
18794
|
+
},
|
|
18795
|
+
cvv: {
|
|
18796
|
+
container: "#cvv"
|
|
18461
18797
|
}
|
|
18462
18798
|
}
|
|
18463
18799
|
};
|
|
18800
|
+
braintreeDropinRef.current = await window.braintree.hostedFields.create(options);
|
|
18801
|
+
|
|
18802
|
+
// dispatch({
|
|
18803
|
+
// type: SKELETON_LOADER,
|
|
18804
|
+
// payload: false
|
|
18805
|
+
// });
|
|
18806
|
+
} catch (error) {
|
|
18807
|
+
console.error("Failed to initialize Braintree hosted fields:", error);
|
|
18464
18808
|
dispatch({
|
|
18465
18809
|
type: SKELETON_LOADER,
|
|
18466
|
-
payload:
|
|
18467
|
-
});
|
|
18468
|
-
return window.braintree.hostedFields.create(options);
|
|
18469
|
-
});
|
|
18470
|
-
braintreeInstanceRef.current.then(hostedFieldInstance => {
|
|
18471
|
-
hostedFieldInstance.on("notEmpty", function (event) {
|
|
18472
|
-
const field = event.fields[event.emittedBy];
|
|
18473
|
-
if (field.isPotentiallyValid) {
|
|
18474
|
-
field.container.classList.remove("pelcro-input-invalid");
|
|
18475
|
-
}
|
|
18476
|
-
});
|
|
18477
|
-
hostedFieldInstance.on("validityChange", function (event) {
|
|
18478
|
-
const field = event.fields[event.emittedBy];
|
|
18479
|
-
|
|
18480
|
-
// Remove any previously applied error or warning classes
|
|
18481
|
-
field.container.classList.remove("is-valid");
|
|
18482
|
-
field.container.classList.remove("pelcro-input-invalid");
|
|
18483
|
-
if (field.isValid) {
|
|
18484
|
-
field.container.classList.add("is-valid");
|
|
18485
|
-
} else if (field.isPotentiallyValid) ; else {
|
|
18486
|
-
field.container.classList.add("pelcro-input-invalid");
|
|
18487
|
-
}
|
|
18810
|
+
payload: false
|
|
18488
18811
|
});
|
|
18489
|
-
}
|
|
18812
|
+
}
|
|
18490
18813
|
}
|
|
18491
18814
|
}
|
|
18492
18815
|
}
|
|
18493
|
-
useEffect(() => {
|
|
18494
|
-
initializeBraintree();
|
|
18495
|
-
}, [selectedPaymentMethodId, paymentMethodToEdit]);
|
|
18496
18816
|
const braintreeErrorHandler = tokenizeErr => {
|
|
18497
18817
|
var _tokenizeErr$details, _tokenizeErr$details2;
|
|
18498
18818
|
const cardNumber = document.querySelector("#card-number");
|
|
@@ -18555,51 +18875,55 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18555
18875
|
// no need to create a new source using braintree
|
|
18556
18876
|
return handleBraintreePayment(null, state.couponCode);
|
|
18557
18877
|
}
|
|
18558
|
-
if (!
|
|
18559
|
-
|
|
18560
|
-
|
|
18561
|
-
|
|
18562
|
-
|
|
18563
|
-
|
|
18564
|
-
|
|
18565
|
-
|
|
18566
|
-
|
|
18567
|
-
|
|
18568
|
-
|
|
18569
|
-
|
|
18570
|
-
|
|
18571
|
-
|
|
18572
|
-
|
|
18573
|
-
type: SHOW_ALERT,
|
|
18574
|
-
payload: {
|
|
18575
|
-
type: "error",
|
|
18576
|
-
content: braintreeErrorHandler(tokenizeErr)
|
|
18577
|
-
}
|
|
18578
|
-
});
|
|
18878
|
+
if (!braintreeDropinRef.current) {
|
|
18879
|
+
console.error("Braintree Drop-in UI wasn't initialized, please try again");
|
|
18880
|
+
dispatch({
|
|
18881
|
+
type: DISABLE_SUBMIT,
|
|
18882
|
+
payload: false
|
|
18883
|
+
});
|
|
18884
|
+
dispatch({
|
|
18885
|
+
type: LOADING,
|
|
18886
|
+
payload: false
|
|
18887
|
+
});
|
|
18888
|
+
return dispatch({
|
|
18889
|
+
type: SHOW_ALERT,
|
|
18890
|
+
payload: {
|
|
18891
|
+
type: "error",
|
|
18892
|
+
content: "Braintree Drop-in UI wasn't initialized, please try again"
|
|
18579
18893
|
}
|
|
18580
|
-
|
|
18581
|
-
// Directly handle the payment with the tokenized payload
|
|
18582
|
-
handleBraintreePayment(payload, state.couponCode);
|
|
18583
18894
|
});
|
|
18895
|
+
}
|
|
18896
|
+
dispatch({
|
|
18897
|
+
type: LOADING,
|
|
18898
|
+
payload: true
|
|
18899
|
+
});
|
|
18900
|
+
dispatch({
|
|
18901
|
+
type: DISABLE_SUBMIT,
|
|
18902
|
+
payload: true
|
|
18903
|
+
});
|
|
18904
|
+
|
|
18905
|
+
// Use appropriate method based on payment type
|
|
18906
|
+
const paymentMethodPromise = type === "updatePaymentSource" ? requestBraintreeHostedFieldsPaymentMethod(braintreeDropinRef.current) : requestBraintreePaymentMethod(braintreeDropinRef.current);
|
|
18907
|
+
paymentMethodPromise.then(payload => {
|
|
18908
|
+
// Drop-in UI handles 3D Secure automatically, just proceed with payment
|
|
18909
|
+
handleBraintreePayment(payload, state.couponCode);
|
|
18584
18910
|
}).catch(error => {
|
|
18585
|
-
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
|
|
18591
|
-
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18595
|
-
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
});
|
|
18602
|
-
}
|
|
18911
|
+
console.error("Braintree payment error:", error);
|
|
18912
|
+
dispatch({
|
|
18913
|
+
type: DISABLE_SUBMIT,
|
|
18914
|
+
payload: false
|
|
18915
|
+
});
|
|
18916
|
+
dispatch({
|
|
18917
|
+
type: LOADING,
|
|
18918
|
+
payload: false
|
|
18919
|
+
});
|
|
18920
|
+
return dispatch({
|
|
18921
|
+
type: SHOW_ALERT,
|
|
18922
|
+
payload: {
|
|
18923
|
+
type: "error",
|
|
18924
|
+
content: braintreeErrorHandler(error)
|
|
18925
|
+
}
|
|
18926
|
+
});
|
|
18603
18927
|
});
|
|
18604
18928
|
};
|
|
18605
18929
|
const handleBraintreePayment = (braintreePaymentRequest, couponCode) => {
|
|
@@ -18649,7 +18973,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18649
18973
|
content: t("messages.sourceCreated")
|
|
18650
18974
|
}
|
|
18651
18975
|
});
|
|
18652
|
-
refreshUser();
|
|
18653
18976
|
onSuccess(res);
|
|
18654
18977
|
});
|
|
18655
18978
|
}
|
|
@@ -19118,9 +19441,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19118
19441
|
useEffect(() => {
|
|
19119
19442
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
19120
19443
|
if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
|
|
19121
|
-
var _window$Pelcro$site$
|
|
19122
|
-
const payPageId = (_window$Pelcro$site$
|
|
19123
|
-
const reportGroup = (_window$Pelcro$site$
|
|
19444
|
+
var _window$Pelcro$site$r9, _window$Pelcro$site$r10;
|
|
19445
|
+
const payPageId = (_window$Pelcro$site$r9 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r9 === void 0 ? void 0 : _window$Pelcro$site$r9.vantiv_gateway_settings.pay_page_id;
|
|
19446
|
+
const reportGroup = (_window$Pelcro$site$r10 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r10 === void 0 ? void 0 : _window$Pelcro$site$r10.vantiv_gateway_settings.report_group;
|
|
19124
19447
|
vantivInstanceRef.current = new window.EprotectIframeClient({
|
|
19125
19448
|
paypageId: payPageId,
|
|
19126
19449
|
reportGroup: reportGroup,
|
|
@@ -19163,13 +19486,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19163
19486
|
if (cardProcessor === "tap" && !selectedPaymentMethodId && window.Tapjsli) {
|
|
19164
19487
|
initTapScript();
|
|
19165
19488
|
}
|
|
19166
|
-
if (cardProcessor === "cybersource" && !selectedPaymentMethodId
|
|
19167
|
-
window.Pelcro.helpers.loadSDK("https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js", "cybersource-cdn");
|
|
19168
|
-
document.querySelector('script[src="https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js"]').addEventListener("load", () => {
|
|
19169
|
-
initCybersourceScript();
|
|
19170
|
-
});
|
|
19171
|
-
}
|
|
19172
|
-
if (cardProcessor === "cybersource" && !selectedPaymentMethodId && window.FLEX) {
|
|
19489
|
+
if (cardProcessor === "cybersource" && !selectedPaymentMethodId) {
|
|
19173
19490
|
initCybersourceScript();
|
|
19174
19491
|
}
|
|
19175
19492
|
if (cardProcessor === "cybersource") {
|
|
@@ -19190,13 +19507,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19190
19507
|
});
|
|
19191
19508
|
|
|
19192
19509
|
// When Google pay / Apple pay source created
|
|
19193
|
-
paymentRequest.on("source",
|
|
19510
|
+
paymentRequest.on("source", _ref8 => {
|
|
19194
19511
|
var _source$card;
|
|
19195
19512
|
let {
|
|
19196
19513
|
complete,
|
|
19197
19514
|
source,
|
|
19198
19515
|
...data
|
|
19199
|
-
} =
|
|
19516
|
+
} = _ref8;
|
|
19200
19517
|
dispatch({
|
|
19201
19518
|
type: DISABLE_COUPON_BUTTON,
|
|
19202
19519
|
payload: true
|
|
@@ -19211,11 +19528,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19211
19528
|
});
|
|
19212
19529
|
complete("success");
|
|
19213
19530
|
if ((source === null || source === void 0 ? void 0 : (_source$card = source.card) === null || _source$card === void 0 ? void 0 : _source$card.three_d_secure) === "required") {
|
|
19214
|
-
return generate3DSecureSource(source).then(
|
|
19531
|
+
return generate3DSecureSource(source).then(_ref9 => {
|
|
19215
19532
|
let {
|
|
19216
19533
|
source,
|
|
19217
19534
|
error
|
|
19218
|
-
} =
|
|
19535
|
+
} = _ref9;
|
|
19219
19536
|
if (error) {
|
|
19220
19537
|
return handlePaymentError(error);
|
|
19221
19538
|
}
|
|
@@ -19246,9 +19563,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19246
19563
|
* Updates the total amount after adding taxes only if site taxes are enabled
|
|
19247
19564
|
*/
|
|
19248
19565
|
const updateTotalAmountWithTax = () => {
|
|
19249
|
-
var _window$Pelcro$site$
|
|
19566
|
+
var _window$Pelcro$site$r11;
|
|
19250
19567
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
19251
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
19568
|
+
const taxesEnabled = (_window$Pelcro$site$r11 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r11 === void 0 ? void 0 : _window$Pelcro$site$r11.taxes_enabled;
|
|
19252
19569
|
if (taxesEnabled && type === "createPayment") {
|
|
19253
19570
|
dispatch({
|
|
19254
19571
|
type: DISABLE_SUBMIT,
|
|
@@ -19685,7 +20002,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19685
20002
|
gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
|
|
19686
20003
|
gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
|
|
19687
20004
|
gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
|
|
19688
|
-
address_id: product.address_required ? selectedAddressId : null
|
|
20005
|
+
address_id: product.address_required ? selectedAddressId : null,
|
|
20006
|
+
metadata: props === null || props === void 0 ? void 0 : props.subCreateMetadata,
|
|
20007
|
+
cardExpirationMonth: state === null || state === void 0 ? void 0 : state.month,
|
|
20008
|
+
cardExpirationYear: state === null || state === void 0 ? void 0 : state.year
|
|
19689
20009
|
}, (err, res) => {
|
|
19690
20010
|
var _res$data;
|
|
19691
20011
|
if (res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && _res$data.setup_intent) {
|
|
@@ -19860,9 +20180,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19860
20180
|
isExistingSource: Boolean(selectedPaymentMethodId),
|
|
19861
20181
|
items: mappedOrderItems,
|
|
19862
20182
|
addressId: selectedAddressId,
|
|
19863
|
-
couponCode
|
|
20183
|
+
couponCode,
|
|
20184
|
+
cardExpirationMonth: state === null || state === void 0 ? void 0 : state.month,
|
|
20185
|
+
cardExpirationYear: state === null || state === void 0 ? void 0 : state.year
|
|
19864
20186
|
}, (err, orderResponse) => {
|
|
19865
|
-
var _window$
|
|
20187
|
+
var _window$Pelcro3, _window$Pelcro3$user, _window$Pelcro3$user$;
|
|
19866
20188
|
if (err) {
|
|
19867
20189
|
toggleAuthenticationSuccessPendingView(false);
|
|
19868
20190
|
dispatch({
|
|
@@ -19893,7 +20215,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19893
20215
|
});
|
|
19894
20216
|
}
|
|
19895
20217
|
window.Pelcro.user.refresh({
|
|
19896
|
-
auth_token: (_window$
|
|
20218
|
+
auth_token: (_window$Pelcro3 = window.Pelcro) === null || _window$Pelcro3 === void 0 ? void 0 : (_window$Pelcro3$user = _window$Pelcro3.user) === null || _window$Pelcro3$user === void 0 ? void 0 : (_window$Pelcro3$user$ = _window$Pelcro3$user.read()) === null || _window$Pelcro3$user$ === void 0 ? void 0 : _window$Pelcro3$user$.auth_token
|
|
19897
20219
|
}, (err, res) => {
|
|
19898
20220
|
dispatch({
|
|
19899
20221
|
type: DISABLE_SUBMIT,
|
|
@@ -19932,11 +20254,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19932
20254
|
const createPaymentSource = (state, dispatch) => {
|
|
19933
20255
|
return stripe.createSource({
|
|
19934
20256
|
type: "card"
|
|
19935
|
-
}).then(
|
|
20257
|
+
}).then(_ref10 => {
|
|
19936
20258
|
let {
|
|
19937
20259
|
source,
|
|
19938
20260
|
error
|
|
19939
|
-
} =
|
|
20261
|
+
} = _ref10;
|
|
19940
20262
|
if (error) {
|
|
19941
20263
|
return handlePaymentError(error);
|
|
19942
20264
|
}
|
|
@@ -20050,11 +20372,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20050
20372
|
} = paymentMethodToDelete;
|
|
20051
20373
|
return stripe.createSource({
|
|
20052
20374
|
type: "card"
|
|
20053
|
-
}).then(
|
|
20375
|
+
}).then(_ref11 => {
|
|
20054
20376
|
let {
|
|
20055
20377
|
source,
|
|
20056
20378
|
error
|
|
20057
|
-
} =
|
|
20379
|
+
} = _ref11;
|
|
20058
20380
|
if (error) {
|
|
20059
20381
|
return handlePaymentError(error);
|
|
20060
20382
|
}
|
|
@@ -20141,7 +20463,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20141
20463
|
campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
|
|
20142
20464
|
...(selectedAddressId && {
|
|
20143
20465
|
address_id: selectedAddressId
|
|
20144
|
-
})
|
|
20466
|
+
}),
|
|
20467
|
+
cardExpirationMonth: state === null || state === void 0 ? void 0 : state.month,
|
|
20468
|
+
cardExpirationYear: state === null || state === void 0 ? void 0 : state.year
|
|
20145
20469
|
}, (err, res) => {
|
|
20146
20470
|
if (err) {
|
|
20147
20471
|
return handlePaymentError(err);
|
|
@@ -20152,12 +20476,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20152
20476
|
}
|
|
20153
20477
|
stripe.createSource({
|
|
20154
20478
|
type: "card"
|
|
20155
|
-
}).then(
|
|
20156
|
-
var
|
|
20479
|
+
}).then(_ref12 => {
|
|
20480
|
+
var _ref13, _ref14, _state$updatedPrice3;
|
|
20157
20481
|
let {
|
|
20158
20482
|
source,
|
|
20159
20483
|
error
|
|
20160
|
-
} =
|
|
20484
|
+
} = _ref12;
|
|
20161
20485
|
if (error) {
|
|
20162
20486
|
return handlePaymentError(error);
|
|
20163
20487
|
}
|
|
@@ -20176,7 +20500,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20176
20500
|
return total + item.price * item.quantity;
|
|
20177
20501
|
}, 0);
|
|
20178
20502
|
};
|
|
20179
|
-
(
|
|
20503
|
+
(_ref13 = (_ref14 = (_state$updatedPrice3 = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice3 !== void 0 ? _state$updatedPrice3 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref14 !== void 0 ? _ref14 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref13 !== void 0 ? _ref13 : getOrderItemsTotal();
|
|
20180
20504
|
return handlePayment(source);
|
|
20181
20505
|
}).catch(error => {
|
|
20182
20506
|
return handlePaymentError(error);
|
|
@@ -20188,11 +20512,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20188
20512
|
* @return {Promise}
|
|
20189
20513
|
*/
|
|
20190
20514
|
const resolveTaxCalculation = () => {
|
|
20191
|
-
var _window$Pelcro$site$
|
|
20515
|
+
var _window$Pelcro$site$r12;
|
|
20192
20516
|
if (type === "invoicePayment") {
|
|
20193
20517
|
return new Promise(resolve => resolve());
|
|
20194
20518
|
}
|
|
20195
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
20519
|
+
const taxesEnabled = (_window$Pelcro$site$r12 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r12 === void 0 ? void 0 : _window$Pelcro$site$r12.taxes_enabled;
|
|
20196
20520
|
return new Promise((resolve, reject) => {
|
|
20197
20521
|
// resolve early if taxes isn't enabled
|
|
20198
20522
|
if (!taxesEnabled) {
|
|
@@ -20550,6 +20874,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20550
20874
|
return state;
|
|
20551
20875
|
}
|
|
20552
20876
|
}, initialState$l);
|
|
20877
|
+
useEffect(() => {
|
|
20878
|
+
initializeBraintree();
|
|
20879
|
+
}, [selectedPaymentMethodId, paymentMethodToEdit, state.updatedPrice]);
|
|
20553
20880
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
20554
20881
|
style: {
|
|
20555
20882
|
...style
|
|
@@ -20852,32 +21179,21 @@ const CheckoutForm = _ref => {
|
|
|
20852
21179
|
}, "Expiration Year *"), /*#__PURE__*/React__default.createElement("div", {
|
|
20853
21180
|
id: "expiration-year",
|
|
20854
21181
|
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
21182
|
+
})), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("label", {
|
|
21183
|
+
htmlFor: "cvv"
|
|
21184
|
+
}, "CVV *"), /*#__PURE__*/React__default.createElement("div", {
|
|
21185
|
+
id: "cvv",
|
|
21186
|
+
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
20855
21187
|
})))) : /*#__PURE__*/React__default.createElement("div", {
|
|
20856
21188
|
className: "plc-w-full plc-h-40 plc-bg-gray-300 plc-rounded plc-animate-pulse"
|
|
20857
21189
|
}));
|
|
20858
21190
|
}
|
|
20859
|
-
return /*#__PURE__*/React__default.createElement("div", null,
|
|
21191
|
+
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("div", {
|
|
20860
21192
|
className: "plc-max-w-[50em]"
|
|
20861
|
-
}, /*#__PURE__*/React__default.createElement("
|
|
20862
|
-
|
|
20863
|
-
|
|
20864
|
-
|
|
20865
|
-
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
20866
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
20867
|
-
className: "plc-flex plc-items-start plc-space-x-8 plc-my-6"
|
|
20868
|
-
}, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("label", {
|
|
20869
|
-
htmlFor: "expiration-date"
|
|
20870
|
-
}, "Expiration Date *"), /*#__PURE__*/React__default.createElement("div", {
|
|
20871
|
-
id: "expiration-date",
|
|
20872
|
-
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
20873
|
-
})), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("label", {
|
|
20874
|
-
htmlFor: "cvv"
|
|
20875
|
-
}, "CVC *"), /*#__PURE__*/React__default.createElement("div", {
|
|
20876
|
-
id: "cvv",
|
|
20877
|
-
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
20878
|
-
})))) : /*#__PURE__*/React__default.createElement("div", {
|
|
20879
|
-
className: "plc-w-full plc-h-40 plc-bg-gray-300 plc-rounded plc-animate-pulse"
|
|
20880
|
-
}));
|
|
21193
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
21194
|
+
id: "dropin-container",
|
|
21195
|
+
className: "plc-w-full plc-min-h-[300px]"
|
|
21196
|
+
})));
|
|
20881
21197
|
}
|
|
20882
21198
|
if (cardProcessor === "stripe") {
|
|
20883
21199
|
if (type === "updatePaymentSource") {
|
|
@@ -22095,7 +22411,7 @@ function PaymentMethodView(_ref) {
|
|
|
22095
22411
|
label: t("labels.isDefault")
|
|
22096
22412
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
22097
22413
|
className: "plc-grid plc-mt-4 plc-gap-y-2"
|
|
22098
|
-
}, /*#__PURE__*/React__default.createElement(SubmitPaymentMethod, null), showExternalPaymentMethods &&
|
|
22414
|
+
}, /*#__PURE__*/React__default.createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && cardProcessor === "braintree" && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, !supportsVantiv && !supportsCybersource && !supportsTap && /*#__PURE__*/React__default.createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)), showApplePayButton && supportsVantiv && /*#__PURE__*/React__default.createElement(ApplePayButton, null))))));
|
|
22099
22415
|
}
|
|
22100
22416
|
|
|
22101
22417
|
const SubscriptionRenewView = _ref => {
|