@pelcro/react-pelcro-js 3.50.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 +401 -174
- package/dist/index.esm.js +401 -174
- 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) => {
|
|
@@ -17806,6 +17908,79 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17806
17908
|
});
|
|
17807
17909
|
updateTotalAmountWithTax();
|
|
17808
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
|
+
};
|
|
17809
17984
|
|
|
17810
17985
|
/* ====== Start Cybersource integration ======== */
|
|
17811
17986
|
const cybersourceErrorHandle = err => {
|
|
@@ -17815,10 +17990,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17815
17990
|
const errorMessages = [];
|
|
17816
17991
|
|
|
17817
17992
|
// enumerable error (ex: validation errors)
|
|
17818
|
-
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 => {
|
|
17819
17994
|
let {
|
|
17820
17995
|
message
|
|
17821
|
-
} =
|
|
17996
|
+
} = _ref4;
|
|
17822
17997
|
errorMessages.push(message);
|
|
17823
17998
|
});
|
|
17824
17999
|
|
|
@@ -18036,10 +18211,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18036
18211
|
// No longer needed - microform instance is stored directly in initCybersourceScript
|
|
18037
18212
|
|
|
18038
18213
|
const appendCybersourceFingerprintScripts = () => {
|
|
18039
|
-
var _window$Pelcro$site$
|
|
18214
|
+
var _window$Pelcro$site$r2, _window$Pelcro$site$r3, _window$Pelcro$site$r4, _window$Pelcro$site$r5;
|
|
18040
18215
|
const uniqueId = crypto.randomUUID();
|
|
18041
|
-
const sessionID = ((_window$Pelcro$site$
|
|
18042
|
-
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;
|
|
18043
18218
|
const fingerPrintScript = document.querySelector(`script[src="https://h.online-metrix.net/fp/tags.js?org_id=${orgID}&session_id=${sessionID}"]`);
|
|
18044
18219
|
const fingerPringIframe = document.querySelector(`iframe[src="https://h.online-metrix.net/fp/tags?org_id=${orgID}&session_id=${sessionID}"]`);
|
|
18045
18220
|
if (!fingerPrintScript && !fingerPringIframe) {
|
|
@@ -18145,7 +18320,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18145
18320
|
|
|
18146
18321
|
/* ====== Start Tap integration ======== */
|
|
18147
18322
|
const submitUsingTap = state => {
|
|
18148
|
-
var
|
|
18323
|
+
var _ref5, _ref6, _ref7, _state$updatedPrice2;
|
|
18149
18324
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
18150
18325
|
if (isUsingExistingPaymentMethod) {
|
|
18151
18326
|
// no need to create a new source using tap
|
|
@@ -18169,7 +18344,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18169
18344
|
return total + item.price * item.quantity;
|
|
18170
18345
|
}, 0);
|
|
18171
18346
|
};
|
|
18172
|
-
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;
|
|
18173
18348
|
tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
|
|
18174
18349
|
if (result.error) {
|
|
18175
18350
|
// Inform the user if there was an error
|
|
@@ -18379,8 +18554,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18379
18554
|
}
|
|
18380
18555
|
}
|
|
18381
18556
|
const initTapScript = () => {
|
|
18382
|
-
var _window$Pelcro$site$
|
|
18383
|
-
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);
|
|
18384
18559
|
let elements = tapKey.elements({});
|
|
18385
18560
|
let style = {
|
|
18386
18561
|
base: {
|
|
@@ -18430,8 +18605,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18430
18605
|
};
|
|
18431
18606
|
/* ====== End Tap integration ======== */
|
|
18432
18607
|
|
|
18433
|
-
/* ====== Start Braintree integration
|
|
18434
|
-
const
|
|
18608
|
+
/* ====== Start Braintree Drop-in UI integration ======== */
|
|
18609
|
+
const braintreeDropinRef = React__default.useRef(null);
|
|
18435
18610
|
function getClientToken() {
|
|
18436
18611
|
return new Promise((resolve, reject) => {
|
|
18437
18612
|
window.Pelcro.payment.generateClientToken({
|
|
@@ -18450,18 +18625,46 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18450
18625
|
async function initializeBraintree() {
|
|
18451
18626
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
18452
18627
|
if (cardProcessor === "braintree" && !selectedPaymentMethodId) {
|
|
18628
|
+
// Clear container before initializing
|
|
18629
|
+
const dropinContainer = document.getElementById("dropin-container");
|
|
18630
|
+
if (dropinContainer) dropinContainer.innerHTML = "";
|
|
18453
18631
|
const braintreeToken = await getClientToken();
|
|
18454
18632
|
const isBraintreeEnabled = Boolean(braintreeToken);
|
|
18455
18633
|
if (!isBraintreeEnabled) {
|
|
18456
18634
|
console.error("Braintree integration is currently not enabled on this site's config");
|
|
18457
18635
|
return;
|
|
18458
18636
|
}
|
|
18637
|
+
console.log("braintreeToken", plan);
|
|
18459
18638
|
if (type !== "updatePaymentSource") {
|
|
18460
|
-
|
|
18461
|
-
|
|
18462
|
-
|
|
18463
|
-
|
|
18464
|
-
|
|
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
|
|
18465
18668
|
styles: {
|
|
18466
18669
|
input: {
|
|
18467
18670
|
"font-size": "14px"
|
|
@@ -18473,48 +18676,85 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18473
18676
|
color: "green"
|
|
18474
18677
|
}
|
|
18475
18678
|
},
|
|
18476
|
-
|
|
18477
|
-
|
|
18478
|
-
|
|
18479
|
-
|
|
18480
|
-
|
|
18481
|
-
|
|
18482
|
-
|
|
18483
|
-
|
|
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
|
+
})()
|
|
18484
18708
|
},
|
|
18485
|
-
|
|
18486
|
-
|
|
18487
|
-
|
|
18709
|
+
// Add button configuration
|
|
18710
|
+
button: {
|
|
18711
|
+
color: "black",
|
|
18712
|
+
type: type === "createPayment" ? "subscribe" : "buy"
|
|
18488
18713
|
}
|
|
18489
18714
|
}
|
|
18490
|
-
};
|
|
18715
|
+
});
|
|
18716
|
+
console.log("Setting skeleton loader to false after successful Braintree initialization");
|
|
18491
18717
|
dispatch({
|
|
18492
18718
|
type: SKELETON_LOADER,
|
|
18493
|
-
payload:
|
|
18719
|
+
payload: false
|
|
18494
18720
|
});
|
|
18495
|
-
|
|
18496
|
-
|
|
18497
|
-
|
|
18498
|
-
|
|
18499
|
-
|
|
18500
|
-
|
|
18501
|
-
|
|
18721
|
+
|
|
18722
|
+
// Clear any error alerts that were shown during initialization
|
|
18723
|
+
dispatch({
|
|
18724
|
+
type: SHOW_ALERT,
|
|
18725
|
+
payload: {
|
|
18726
|
+
type: "error",
|
|
18727
|
+
content: ""
|
|
18502
18728
|
}
|
|
18503
18729
|
});
|
|
18504
|
-
|
|
18505
|
-
|
|
18506
|
-
|
|
18507
|
-
|
|
18508
|
-
|
|
18509
|
-
|
|
18510
|
-
|
|
18511
|
-
|
|
18512
|
-
|
|
18513
|
-
|
|
18514
|
-
|
|
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
|
|
18515
18741
|
});
|
|
18516
|
-
|
|
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
|
+
}
|
|
18517
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
|
|
18518
18758
|
const {
|
|
18519
18759
|
properties
|
|
18520
18760
|
} = paymentMethodToEdit !== null && paymentMethodToEdit !== void 0 ? paymentMethodToEdit : {};
|
|
@@ -18522,9 +18762,14 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18522
18762
|
exp_month: expMonth,
|
|
18523
18763
|
exp_year: expYear
|
|
18524
18764
|
} = properties !== null && properties !== void 0 ? properties : {};
|
|
18525
|
-
|
|
18526
|
-
|
|
18527
|
-
|
|
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
|
+
});
|
|
18528
18773
|
const options = {
|
|
18529
18774
|
client: clientInstance,
|
|
18530
18775
|
styles: {
|
|
@@ -18546,41 +18791,28 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18546
18791
|
expirationYear: {
|
|
18547
18792
|
container: "#expiration-year",
|
|
18548
18793
|
prefill: expYear
|
|
18794
|
+
},
|
|
18795
|
+
cvv: {
|
|
18796
|
+
container: "#cvv"
|
|
18549
18797
|
}
|
|
18550
18798
|
}
|
|
18551
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);
|
|
18552
18808
|
dispatch({
|
|
18553
18809
|
type: SKELETON_LOADER,
|
|
18554
|
-
payload:
|
|
18555
|
-
});
|
|
18556
|
-
return window.braintree.hostedFields.create(options);
|
|
18557
|
-
});
|
|
18558
|
-
braintreeInstanceRef.current.then(hostedFieldInstance => {
|
|
18559
|
-
hostedFieldInstance.on("notEmpty", function (event) {
|
|
18560
|
-
const field = event.fields[event.emittedBy];
|
|
18561
|
-
if (field.isPotentiallyValid) {
|
|
18562
|
-
field.container.classList.remove("pelcro-input-invalid");
|
|
18563
|
-
}
|
|
18564
|
-
});
|
|
18565
|
-
hostedFieldInstance.on("validityChange", function (event) {
|
|
18566
|
-
const field = event.fields[event.emittedBy];
|
|
18567
|
-
|
|
18568
|
-
// Remove any previously applied error or warning classes
|
|
18569
|
-
field.container.classList.remove("is-valid");
|
|
18570
|
-
field.container.classList.remove("pelcro-input-invalid");
|
|
18571
|
-
if (field.isValid) {
|
|
18572
|
-
field.container.classList.add("is-valid");
|
|
18573
|
-
} else if (field.isPotentiallyValid) ; else {
|
|
18574
|
-
field.container.classList.add("pelcro-input-invalid");
|
|
18575
|
-
}
|
|
18810
|
+
payload: false
|
|
18576
18811
|
});
|
|
18577
|
-
}
|
|
18812
|
+
}
|
|
18578
18813
|
}
|
|
18579
18814
|
}
|
|
18580
18815
|
}
|
|
18581
|
-
useEffect(() => {
|
|
18582
|
-
initializeBraintree();
|
|
18583
|
-
}, [selectedPaymentMethodId, paymentMethodToEdit]);
|
|
18584
18816
|
const braintreeErrorHandler = tokenizeErr => {
|
|
18585
18817
|
var _tokenizeErr$details, _tokenizeErr$details2;
|
|
18586
18818
|
const cardNumber = document.querySelector("#card-number");
|
|
@@ -18643,51 +18875,55 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18643
18875
|
// no need to create a new source using braintree
|
|
18644
18876
|
return handleBraintreePayment(null, state.couponCode);
|
|
18645
18877
|
}
|
|
18646
|
-
if (!
|
|
18647
|
-
|
|
18648
|
-
|
|
18649
|
-
|
|
18650
|
-
|
|
18651
|
-
|
|
18652
|
-
|
|
18653
|
-
|
|
18654
|
-
|
|
18655
|
-
|
|
18656
|
-
|
|
18657
|
-
|
|
18658
|
-
|
|
18659
|
-
|
|
18660
|
-
|
|
18661
|
-
type: SHOW_ALERT,
|
|
18662
|
-
payload: {
|
|
18663
|
-
type: "error",
|
|
18664
|
-
content: braintreeErrorHandler(tokenizeErr)
|
|
18665
|
-
}
|
|
18666
|
-
});
|
|
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"
|
|
18667
18893
|
}
|
|
18668
|
-
|
|
18669
|
-
// Directly handle the payment with the tokenized payload
|
|
18670
|
-
handleBraintreePayment(payload, state.couponCode);
|
|
18671
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);
|
|
18672
18910
|
}).catch(error => {
|
|
18673
|
-
|
|
18674
|
-
|
|
18675
|
-
|
|
18676
|
-
|
|
18677
|
-
|
|
18678
|
-
|
|
18679
|
-
|
|
18680
|
-
|
|
18681
|
-
|
|
18682
|
-
|
|
18683
|
-
|
|
18684
|
-
|
|
18685
|
-
|
|
18686
|
-
|
|
18687
|
-
|
|
18688
|
-
|
|
18689
|
-
});
|
|
18690
|
-
}
|
|
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
|
+
});
|
|
18691
18927
|
});
|
|
18692
18928
|
};
|
|
18693
18929
|
const handleBraintreePayment = (braintreePaymentRequest, couponCode) => {
|
|
@@ -18737,7 +18973,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18737
18973
|
content: t("messages.sourceCreated")
|
|
18738
18974
|
}
|
|
18739
18975
|
});
|
|
18740
|
-
refreshUser();
|
|
18741
18976
|
onSuccess(res);
|
|
18742
18977
|
});
|
|
18743
18978
|
}
|
|
@@ -19206,9 +19441,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19206
19441
|
useEffect(() => {
|
|
19207
19442
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
19208
19443
|
if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
|
|
19209
|
-
var _window$Pelcro$site$
|
|
19210
|
-
const payPageId = (_window$Pelcro$site$
|
|
19211
|
-
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;
|
|
19212
19447
|
vantivInstanceRef.current = new window.EprotectIframeClient({
|
|
19213
19448
|
paypageId: payPageId,
|
|
19214
19449
|
reportGroup: reportGroup,
|
|
@@ -19272,13 +19507,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19272
19507
|
});
|
|
19273
19508
|
|
|
19274
19509
|
// When Google pay / Apple pay source created
|
|
19275
|
-
paymentRequest.on("source",
|
|
19510
|
+
paymentRequest.on("source", _ref8 => {
|
|
19276
19511
|
var _source$card;
|
|
19277
19512
|
let {
|
|
19278
19513
|
complete,
|
|
19279
19514
|
source,
|
|
19280
19515
|
...data
|
|
19281
|
-
} =
|
|
19516
|
+
} = _ref8;
|
|
19282
19517
|
dispatch({
|
|
19283
19518
|
type: DISABLE_COUPON_BUTTON,
|
|
19284
19519
|
payload: true
|
|
@@ -19293,11 +19528,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19293
19528
|
});
|
|
19294
19529
|
complete("success");
|
|
19295
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") {
|
|
19296
|
-
return generate3DSecureSource(source).then(
|
|
19531
|
+
return generate3DSecureSource(source).then(_ref9 => {
|
|
19297
19532
|
let {
|
|
19298
19533
|
source,
|
|
19299
19534
|
error
|
|
19300
|
-
} =
|
|
19535
|
+
} = _ref9;
|
|
19301
19536
|
if (error) {
|
|
19302
19537
|
return handlePaymentError(error);
|
|
19303
19538
|
}
|
|
@@ -19328,9 +19563,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19328
19563
|
* Updates the total amount after adding taxes only if site taxes are enabled
|
|
19329
19564
|
*/
|
|
19330
19565
|
const updateTotalAmountWithTax = () => {
|
|
19331
|
-
var _window$Pelcro$site$
|
|
19566
|
+
var _window$Pelcro$site$r11;
|
|
19332
19567
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
19333
|
-
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;
|
|
19334
19569
|
if (taxesEnabled && type === "createPayment") {
|
|
19335
19570
|
dispatch({
|
|
19336
19571
|
type: DISABLE_SUBMIT,
|
|
@@ -19949,7 +20184,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19949
20184
|
cardExpirationMonth: state === null || state === void 0 ? void 0 : state.month,
|
|
19950
20185
|
cardExpirationYear: state === null || state === void 0 ? void 0 : state.year
|
|
19951
20186
|
}, (err, orderResponse) => {
|
|
19952
|
-
var _window$
|
|
20187
|
+
var _window$Pelcro3, _window$Pelcro3$user, _window$Pelcro3$user$;
|
|
19953
20188
|
if (err) {
|
|
19954
20189
|
toggleAuthenticationSuccessPendingView(false);
|
|
19955
20190
|
dispatch({
|
|
@@ -19980,7 +20215,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19980
20215
|
});
|
|
19981
20216
|
}
|
|
19982
20217
|
window.Pelcro.user.refresh({
|
|
19983
|
-
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
|
|
19984
20219
|
}, (err, res) => {
|
|
19985
20220
|
dispatch({
|
|
19986
20221
|
type: DISABLE_SUBMIT,
|
|
@@ -20019,11 +20254,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20019
20254
|
const createPaymentSource = (state, dispatch) => {
|
|
20020
20255
|
return stripe.createSource({
|
|
20021
20256
|
type: "card"
|
|
20022
|
-
}).then(
|
|
20257
|
+
}).then(_ref10 => {
|
|
20023
20258
|
let {
|
|
20024
20259
|
source,
|
|
20025
20260
|
error
|
|
20026
|
-
} =
|
|
20261
|
+
} = _ref10;
|
|
20027
20262
|
if (error) {
|
|
20028
20263
|
return handlePaymentError(error);
|
|
20029
20264
|
}
|
|
@@ -20137,11 +20372,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20137
20372
|
} = paymentMethodToDelete;
|
|
20138
20373
|
return stripe.createSource({
|
|
20139
20374
|
type: "card"
|
|
20140
|
-
}).then(
|
|
20375
|
+
}).then(_ref11 => {
|
|
20141
20376
|
let {
|
|
20142
20377
|
source,
|
|
20143
20378
|
error
|
|
20144
|
-
} =
|
|
20379
|
+
} = _ref11;
|
|
20145
20380
|
if (error) {
|
|
20146
20381
|
return handlePaymentError(error);
|
|
20147
20382
|
}
|
|
@@ -20241,12 +20476,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20241
20476
|
}
|
|
20242
20477
|
stripe.createSource({
|
|
20243
20478
|
type: "card"
|
|
20244
|
-
}).then(
|
|
20245
|
-
var
|
|
20479
|
+
}).then(_ref12 => {
|
|
20480
|
+
var _ref13, _ref14, _state$updatedPrice3;
|
|
20246
20481
|
let {
|
|
20247
20482
|
source,
|
|
20248
20483
|
error
|
|
20249
|
-
} =
|
|
20484
|
+
} = _ref12;
|
|
20250
20485
|
if (error) {
|
|
20251
20486
|
return handlePaymentError(error);
|
|
20252
20487
|
}
|
|
@@ -20265,7 +20500,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20265
20500
|
return total + item.price * item.quantity;
|
|
20266
20501
|
}, 0);
|
|
20267
20502
|
};
|
|
20268
|
-
(
|
|
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();
|
|
20269
20504
|
return handlePayment(source);
|
|
20270
20505
|
}).catch(error => {
|
|
20271
20506
|
return handlePaymentError(error);
|
|
@@ -20277,11 +20512,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20277
20512
|
* @return {Promise}
|
|
20278
20513
|
*/
|
|
20279
20514
|
const resolveTaxCalculation = () => {
|
|
20280
|
-
var _window$Pelcro$site$
|
|
20515
|
+
var _window$Pelcro$site$r12;
|
|
20281
20516
|
if (type === "invoicePayment") {
|
|
20282
20517
|
return new Promise(resolve => resolve());
|
|
20283
20518
|
}
|
|
20284
|
-
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;
|
|
20285
20520
|
return new Promise((resolve, reject) => {
|
|
20286
20521
|
// resolve early if taxes isn't enabled
|
|
20287
20522
|
if (!taxesEnabled) {
|
|
@@ -20639,6 +20874,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20639
20874
|
return state;
|
|
20640
20875
|
}
|
|
20641
20876
|
}, initialState$l);
|
|
20877
|
+
useEffect(() => {
|
|
20878
|
+
initializeBraintree();
|
|
20879
|
+
}, [selectedPaymentMethodId, paymentMethodToEdit, state.updatedPrice]);
|
|
20642
20880
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
20643
20881
|
style: {
|
|
20644
20882
|
...style
|
|
@@ -20941,32 +21179,21 @@ const CheckoutForm = _ref => {
|
|
|
20941
21179
|
}, "Expiration Year *"), /*#__PURE__*/React__default.createElement("div", {
|
|
20942
21180
|
id: "expiration-year",
|
|
20943
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"
|
|
20944
21187
|
})))) : /*#__PURE__*/React__default.createElement("div", {
|
|
20945
21188
|
className: "plc-w-full plc-h-40 plc-bg-gray-300 plc-rounded plc-animate-pulse"
|
|
20946
21189
|
}));
|
|
20947
21190
|
}
|
|
20948
|
-
return /*#__PURE__*/React__default.createElement("div", null,
|
|
21191
|
+
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("div", {
|
|
20949
21192
|
className: "plc-max-w-[50em]"
|
|
20950
|
-
}, /*#__PURE__*/React__default.createElement("
|
|
20951
|
-
|
|
20952
|
-
|
|
20953
|
-
|
|
20954
|
-
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
20955
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
20956
|
-
className: "plc-flex plc-items-start plc-space-x-8 plc-my-6"
|
|
20957
|
-
}, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("label", {
|
|
20958
|
-
htmlFor: "expiration-date"
|
|
20959
|
-
}, "Expiration Date *"), /*#__PURE__*/React__default.createElement("div", {
|
|
20960
|
-
id: "expiration-date",
|
|
20961
|
-
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
20962
|
-
})), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("label", {
|
|
20963
|
-
htmlFor: "cvv"
|
|
20964
|
-
}, "CVC *"), /*#__PURE__*/React__default.createElement("div", {
|
|
20965
|
-
id: "cvv",
|
|
20966
|
-
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
20967
|
-
})))) : /*#__PURE__*/React__default.createElement("div", {
|
|
20968
|
-
className: "plc-w-full plc-h-40 plc-bg-gray-300 plc-rounded plc-animate-pulse"
|
|
20969
|
-
}));
|
|
21193
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
21194
|
+
id: "dropin-container",
|
|
21195
|
+
className: "plc-w-full plc-min-h-[300px]"
|
|
21196
|
+
})));
|
|
20970
21197
|
}
|
|
20971
21198
|
if (cardProcessor === "stripe") {
|
|
20972
21199
|
if (type === "updatePaymentSource") {
|
|
@@ -22184,7 +22411,7 @@ function PaymentMethodView(_ref) {
|
|
|
22184
22411
|
label: t("labels.isDefault")
|
|
22185
22412
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
22186
22413
|
className: "plc-grid plc-mt-4 plc-gap-y-2"
|
|
22187
|
-
}, /*#__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))))));
|
|
22188
22415
|
}
|
|
22189
22416
|
|
|
22190
22417
|
const SubscriptionRenewView = _ref => {
|