@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.cjs.js
CHANGED
|
@@ -11682,6 +11682,101 @@ function getFourDigitYear(lastTwoDigits) {
|
|
|
11682
11682
|
return fourDigitYear;
|
|
11683
11683
|
}
|
|
11684
11684
|
|
|
11685
|
+
/**
|
|
11686
|
+
* Loads Braintree Drop-in UI script
|
|
11687
|
+
* @returns {Promise} Promise that resolves when script is loaded
|
|
11688
|
+
*/
|
|
11689
|
+
function loadBraintreeScript() {
|
|
11690
|
+
return new Promise((resolve, reject) => {
|
|
11691
|
+
// Check if script is already loaded
|
|
11692
|
+
if (window.braintree) {
|
|
11693
|
+
console.log("Braintree script already loaded");
|
|
11694
|
+
resolve(window.braintree);
|
|
11695
|
+
return;
|
|
11696
|
+
}
|
|
11697
|
+
console.log("Loading Braintree script...");
|
|
11698
|
+
const script = document.createElement("script");
|
|
11699
|
+
script.src = "https://js.braintreegateway.com/web/dropin/1.45.1/js/dropin.js";
|
|
11700
|
+
script.onload = () => {
|
|
11701
|
+
console.log("Braintree script loaded successfully");
|
|
11702
|
+
resolve(window.braintree);
|
|
11703
|
+
};
|
|
11704
|
+
script.onerror = error => {
|
|
11705
|
+
console.error("Failed to load Braintree script:", error);
|
|
11706
|
+
reject(new Error("Failed to load Braintree script"));
|
|
11707
|
+
};
|
|
11708
|
+
document.head.appendChild(script);
|
|
11709
|
+
});
|
|
11710
|
+
}
|
|
11711
|
+
|
|
11712
|
+
/**
|
|
11713
|
+
* Creates Braintree Drop-in UI instance
|
|
11714
|
+
* @param {string} authorization - Braintree authorization token
|
|
11715
|
+
* @param {string} selector - CSS selector for the container
|
|
11716
|
+
* @param {Object} options - Additional options for dropin creation
|
|
11717
|
+
* @returns {Promise} Promise that resolves with the dropin instance
|
|
11718
|
+
*/
|
|
11719
|
+
function createBraintreeDropin(authorization, selector) {
|
|
11720
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
11721
|
+
console.log("Creating Braintree Drop-in with:", {
|
|
11722
|
+
authorization: authorization ? "present" : "missing",
|
|
11723
|
+
selector,
|
|
11724
|
+
options
|
|
11725
|
+
});
|
|
11726
|
+
return loadBraintreeScript().then(() => {
|
|
11727
|
+
console.log("Braintree script loaded, creating dropin...");
|
|
11728
|
+
return new Promise((resolve, reject) => {
|
|
11729
|
+
window.braintree.dropin.create({
|
|
11730
|
+
authorization,
|
|
11731
|
+
selector,
|
|
11732
|
+
...options
|
|
11733
|
+
}, (err, instance) => {
|
|
11734
|
+
if (err) {
|
|
11735
|
+
console.error("Braintree dropin creation failed:", err);
|
|
11736
|
+
reject(err);
|
|
11737
|
+
} else {
|
|
11738
|
+
console.log("Braintree dropin created successfully:", instance);
|
|
11739
|
+
resolve(instance);
|
|
11740
|
+
}
|
|
11741
|
+
});
|
|
11742
|
+
});
|
|
11743
|
+
});
|
|
11744
|
+
}
|
|
11745
|
+
|
|
11746
|
+
/**
|
|
11747
|
+
* Requests payment method from Braintree Drop-in UI
|
|
11748
|
+
* @param {Object} instance - Braintree dropin instance
|
|
11749
|
+
* @returns {Promise} Promise that resolves with payment method payload
|
|
11750
|
+
*/
|
|
11751
|
+
function requestBraintreePaymentMethod(instance) {
|
|
11752
|
+
return new Promise((resolve, reject) => {
|
|
11753
|
+
instance.requestPaymentMethod((err, payload) => {
|
|
11754
|
+
if (err) {
|
|
11755
|
+
reject(err);
|
|
11756
|
+
} else {
|
|
11757
|
+
resolve(payload);
|
|
11758
|
+
}
|
|
11759
|
+
});
|
|
11760
|
+
});
|
|
11761
|
+
}
|
|
11762
|
+
|
|
11763
|
+
/**
|
|
11764
|
+
* Requests payment method from Braintree Hosted Fields
|
|
11765
|
+
* @param {Object} hostedFieldsInstance - Braintree hosted fields instance
|
|
11766
|
+
* @returns {Promise} Promise that resolves with payment method payload
|
|
11767
|
+
*/
|
|
11768
|
+
function requestBraintreeHostedFieldsPaymentMethod(hostedFieldsInstance) {
|
|
11769
|
+
return new Promise((resolve, reject) => {
|
|
11770
|
+
hostedFieldsInstance.tokenize((err, payload) => {
|
|
11771
|
+
if (err) {
|
|
11772
|
+
reject(err);
|
|
11773
|
+
} else {
|
|
11774
|
+
resolve(payload);
|
|
11775
|
+
}
|
|
11776
|
+
});
|
|
11777
|
+
});
|
|
11778
|
+
}
|
|
11779
|
+
|
|
11685
11780
|
/**
|
|
11686
11781
|
* @typedef {Object} OptionsType
|
|
11687
11782
|
* @property {boolean} loadPaymentSDKs
|
|
@@ -11792,6 +11887,7 @@ const loadPaymentSDKs = () => {
|
|
|
11792
11887
|
// "braintree-3D-secure-sdk"
|
|
11793
11888
|
// );
|
|
11794
11889
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.99.0/js/hosted-fields.min.js", "braintree-hosted-fields-sdk");
|
|
11890
|
+
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/dropin/1.45.1/js/dropin.js", "braintree-dropin-sdk");
|
|
11795
11891
|
}
|
|
11796
11892
|
|
|
11797
11893
|
// Load Vantiv SDKs
|
|
@@ -11836,16 +11932,16 @@ const initSecuritySdk = () => {
|
|
|
11836
11932
|
});
|
|
11837
11933
|
};
|
|
11838
11934
|
const initGATracking = () => {
|
|
11839
|
-
var _window, _window$Pelcro, _window$Pelcro$uiSett;
|
|
11935
|
+
var _window, _window$Pelcro, _window$Pelcro$uiSett, _window2, _window2$Pelcro, _window2$Pelcro$uiSet;
|
|
11840
11936
|
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;
|
|
11937
|
+
// Respect disablePageViewEvents flag from uiSettings
|
|
11938
|
+
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;
|
|
11841
11939
|
if (window.Pelcro.site.read().google_analytics_id) {
|
|
11842
11940
|
if (enableReactGA4) {
|
|
11843
|
-
// Initialize ReactGA4 with your tracking ID
|
|
11844
|
-
ReactGA4.initialize(window.Pelcro.site.read().google_analytics_id);
|
|
11845
|
-
// Enable e-commerce tracking
|
|
11941
|
+
// Initialize ReactGA4 with your tracking ID and options, only once
|
|
11846
11942
|
ReactGA4.initialize(window.Pelcro.site.read().google_analytics_id, {
|
|
11847
11943
|
gaOptions: {
|
|
11848
|
-
send_page_view: true,
|
|
11944
|
+
send_page_view: disablePageViewEvents ? false : true,
|
|
11849
11945
|
ecommerce: {
|
|
11850
11946
|
enabled: true
|
|
11851
11947
|
}
|
|
@@ -11859,8 +11955,8 @@ const initGATracking = () => {
|
|
|
11859
11955
|
}
|
|
11860
11956
|
};
|
|
11861
11957
|
const dispatchModalDisplayEvents = modalName => {
|
|
11862
|
-
var
|
|
11863
|
-
const enableReactGA4 = (
|
|
11958
|
+
var _window3, _window3$Pelcro, _window3$Pelcro$uiSet, _modalName$replace, _modalName$replace2;
|
|
11959
|
+
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;
|
|
11864
11960
|
const formattedAction = modalName === null || modalName === void 0 ? void 0 : (_modalName$replace = modalName.replace("pelcro-", "")) === null || _modalName$replace === void 0 ? void 0 : _modalName$replace.replaceAll("-", " ");
|
|
11865
11961
|
if (enableReactGA4) {
|
|
11866
11962
|
ReactGA4.event(`${formattedAction} viewed`, {
|
|
@@ -16454,10 +16550,6 @@ var es_13 = es.StripeProvider;
|
|
|
16454
16550
|
|
|
16455
16551
|
function _classPrivateFieldInitSpec$1(obj, privateMap, value) { _checkPrivateRedeclaration$1(obj, privateMap); privateMap.set(obj, value); }
|
|
16456
16552
|
function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
16457
|
-
/**
|
|
16458
|
-
* @TODO: All payment related business logic should end up moving
|
|
16459
|
-
* to this service, and out of react components.
|
|
16460
|
-
*/
|
|
16461
16553
|
|
|
16462
16554
|
/**
|
|
16463
16555
|
* Enum for payment types
|
|
@@ -16593,6 +16685,16 @@ class StripeGateway {
|
|
|
16593
16685
|
console.error("Unsupported payment method: Stripe Gateway");
|
|
16594
16686
|
}
|
|
16595
16687
|
});
|
|
16688
|
+
_defineProperty$3(this, "createDropin", function (authorization, selector) {
|
|
16689
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
16690
|
+
return createBraintreeDropin(authorization, selector, options);
|
|
16691
|
+
});
|
|
16692
|
+
_defineProperty$3(this, "requestPaymentMethod", instance => {
|
|
16693
|
+
return requestBraintreePaymentMethod(instance);
|
|
16694
|
+
});
|
|
16695
|
+
_defineProperty$3(this, "loadScript", () => {
|
|
16696
|
+
return loadBraintreeScript();
|
|
16697
|
+
});
|
|
16596
16698
|
_classPrivateFieldInitSpec$1(this, _createSubscription, {
|
|
16597
16699
|
writable: true,
|
|
16598
16700
|
value: (options, callback) => {
|
|
@@ -17836,6 +17938,79 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17836
17938
|
});
|
|
17837
17939
|
updateTotalAmountWithTax();
|
|
17838
17940
|
}, []);
|
|
17941
|
+
// Helper function to calculate total amount for payment methods
|
|
17942
|
+
const calculateTotalAmount = (state, plan, invoice, order) => {
|
|
17943
|
+
var _ref2, _ref3, _state$updatedPrice;
|
|
17944
|
+
const getOrderItemsTotal = () => {
|
|
17945
|
+
if (!order) {
|
|
17946
|
+
return null;
|
|
17947
|
+
}
|
|
17948
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
17949
|
+
if (isQuickPurchase) {
|
|
17950
|
+
return order.price * order.quantity;
|
|
17951
|
+
}
|
|
17952
|
+
if (order.length === 0) {
|
|
17953
|
+
return null;
|
|
17954
|
+
}
|
|
17955
|
+
return order.reduce((total, item) => {
|
|
17956
|
+
return total + item.price * item.quantity;
|
|
17957
|
+
}, 0);
|
|
17958
|
+
};
|
|
17959
|
+
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();
|
|
17960
|
+
};
|
|
17961
|
+
|
|
17962
|
+
// Helper function to get currency from the appropriate source
|
|
17963
|
+
const getCurrencyFromPaymentType = (plan, order, invoice) => {
|
|
17964
|
+
if (plan) {
|
|
17965
|
+
return plan.currency;
|
|
17966
|
+
} else if (order) {
|
|
17967
|
+
var _order$;
|
|
17968
|
+
// Handle both single order and array of orders
|
|
17969
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
17970
|
+
return isQuickPurchase ? order.currency : (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency;
|
|
17971
|
+
} else if (invoice) {
|
|
17972
|
+
return invoice.currency;
|
|
17973
|
+
}
|
|
17974
|
+
return "USD"; // Default fallback
|
|
17975
|
+
};
|
|
17976
|
+
|
|
17977
|
+
// Helper function to get payment label
|
|
17978
|
+
const getPaymentLabel = (plan, order, invoice) => {
|
|
17979
|
+
var _window$Pelcro$site$r;
|
|
17980
|
+
if (plan) {
|
|
17981
|
+
return plan.nickname || plan.description || "Subscription";
|
|
17982
|
+
} else if (order) {
|
|
17983
|
+
// Handle both single order and array of orders
|
|
17984
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
17985
|
+
if (isQuickPurchase) {
|
|
17986
|
+
return order.name || "Order";
|
|
17987
|
+
} else {
|
|
17988
|
+
return order.length === 1 ? order[0].name : "Order";
|
|
17989
|
+
}
|
|
17990
|
+
} else if (invoice) {
|
|
17991
|
+
return `Invoice #${invoice.id}`;
|
|
17992
|
+
}
|
|
17993
|
+
return ((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.name) || "Payment";
|
|
17994
|
+
};
|
|
17995
|
+
|
|
17996
|
+
// Helper function to format amount for payment methods (Apple Pay, Google Pay)
|
|
17997
|
+
const formatPaymentAmount = function (totalAmount, currency) {
|
|
17998
|
+
var _window$Pelcro2, _window$Pelcro2$utils, _window$Pelcro2$utils2, _currency$toUpperCase;
|
|
17999
|
+
let paymentMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
18000
|
+
if (!totalAmount) return "0.00";
|
|
18001
|
+
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));
|
|
18002
|
+
|
|
18003
|
+
// Payment methods expect amount in major currency unit (dollars, not cents)
|
|
18004
|
+
let finalAmount;
|
|
18005
|
+
if (isZeroDecimal) {
|
|
18006
|
+
finalAmount = Math.round(totalAmount).toString();
|
|
18007
|
+
} else {
|
|
18008
|
+
// Convert from cents to dollars and format with 2 decimal places
|
|
18009
|
+
finalAmount = (totalAmount / 100).toFixed(2);
|
|
18010
|
+
}
|
|
18011
|
+
console.log(`${paymentMethod} amount:`, finalAmount, "currency:", currency, "type:", type);
|
|
18012
|
+
return String(finalAmount);
|
|
18013
|
+
};
|
|
17839
18014
|
|
|
17840
18015
|
/* ====== Start Cybersource integration ======== */
|
|
17841
18016
|
const cybersourceErrorHandle = err => {
|
|
@@ -17845,10 +18020,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17845
18020
|
const errorMessages = [];
|
|
17846
18021
|
|
|
17847
18022
|
// enumerable error (ex: validation errors)
|
|
17848
|
-
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(
|
|
18023
|
+
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 => {
|
|
17849
18024
|
let {
|
|
17850
18025
|
message
|
|
17851
|
-
} =
|
|
18026
|
+
} = _ref4;
|
|
17852
18027
|
errorMessages.push(message);
|
|
17853
18028
|
});
|
|
17854
18029
|
|
|
@@ -18066,10 +18241,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18066
18241
|
// No longer needed - microform instance is stored directly in initCybersourceScript
|
|
18067
18242
|
|
|
18068
18243
|
const appendCybersourceFingerprintScripts = () => {
|
|
18069
|
-
var _window$Pelcro$site$
|
|
18244
|
+
var _window$Pelcro$site$r2, _window$Pelcro$site$r3, _window$Pelcro$site$r4, _window$Pelcro$site$r5;
|
|
18070
18245
|
const uniqueId = crypto.randomUUID();
|
|
18071
|
-
const sessionID = ((_window$Pelcro$site$
|
|
18072
|
-
const orgID = (_window$Pelcro$site$
|
|
18246
|
+
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;
|
|
18247
|
+
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;
|
|
18073
18248
|
const fingerPrintScript = document.querySelector(`script[src="https://h.online-metrix.net/fp/tags.js?org_id=${orgID}&session_id=${sessionID}"]`);
|
|
18074
18249
|
const fingerPringIframe = document.querySelector(`iframe[src="https://h.online-metrix.net/fp/tags?org_id=${orgID}&session_id=${sessionID}"]`);
|
|
18075
18250
|
if (!fingerPrintScript && !fingerPringIframe) {
|
|
@@ -18175,7 +18350,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18175
18350
|
|
|
18176
18351
|
/* ====== Start Tap integration ======== */
|
|
18177
18352
|
const submitUsingTap = state => {
|
|
18178
|
-
var
|
|
18353
|
+
var _ref5, _ref6, _ref7, _state$updatedPrice2;
|
|
18179
18354
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
18180
18355
|
if (isUsingExistingPaymentMethod) {
|
|
18181
18356
|
// no need to create a new source using tap
|
|
@@ -18199,7 +18374,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18199
18374
|
return total + item.price * item.quantity;
|
|
18200
18375
|
}, 0);
|
|
18201
18376
|
};
|
|
18202
|
-
const totalAmount = (
|
|
18377
|
+
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;
|
|
18203
18378
|
tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
|
|
18204
18379
|
if (result.error) {
|
|
18205
18380
|
// Inform the user if there was an error
|
|
@@ -18409,8 +18584,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18409
18584
|
}
|
|
18410
18585
|
}
|
|
18411
18586
|
const initTapScript = () => {
|
|
18412
|
-
var _window$Pelcro$site$
|
|
18413
|
-
const tapKey = window.Tapjsli((_window$Pelcro$site$
|
|
18587
|
+
var _window$Pelcro$site$r6;
|
|
18588
|
+
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);
|
|
18414
18589
|
let elements = tapKey.elements({});
|
|
18415
18590
|
let style = {
|
|
18416
18591
|
base: {
|
|
@@ -18460,8 +18635,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18460
18635
|
};
|
|
18461
18636
|
/* ====== End Tap integration ======== */
|
|
18462
18637
|
|
|
18463
|
-
/* ====== Start Braintree integration
|
|
18464
|
-
const
|
|
18638
|
+
/* ====== Start Braintree Drop-in UI integration ======== */
|
|
18639
|
+
const braintreeDropinRef = React__default['default'].useRef(null);
|
|
18465
18640
|
function getClientToken() {
|
|
18466
18641
|
return new Promise((resolve, reject) => {
|
|
18467
18642
|
window.Pelcro.payment.generateClientToken({
|
|
@@ -18480,18 +18655,46 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18480
18655
|
async function initializeBraintree() {
|
|
18481
18656
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
18482
18657
|
if (cardProcessor === "braintree" && !selectedPaymentMethodId) {
|
|
18658
|
+
// Clear container before initializing
|
|
18659
|
+
const dropinContainer = document.getElementById("dropin-container");
|
|
18660
|
+
if (dropinContainer) dropinContainer.innerHTML = "";
|
|
18483
18661
|
const braintreeToken = await getClientToken();
|
|
18484
18662
|
const isBraintreeEnabled = Boolean(braintreeToken);
|
|
18485
18663
|
if (!isBraintreeEnabled) {
|
|
18486
18664
|
console.error("Braintree integration is currently not enabled on this site's config");
|
|
18487
18665
|
return;
|
|
18488
18666
|
}
|
|
18667
|
+
console.log("braintreeToken", plan);
|
|
18489
18668
|
if (type !== "updatePaymentSource") {
|
|
18490
|
-
|
|
18491
|
-
|
|
18492
|
-
|
|
18493
|
-
|
|
18494
|
-
|
|
18669
|
+
console.log("Setting skeleton loader to true at start of Braintree initialization");
|
|
18670
|
+
dispatch({
|
|
18671
|
+
type: SKELETON_LOADER,
|
|
18672
|
+
payload: true
|
|
18673
|
+
});
|
|
18674
|
+
try {
|
|
18675
|
+
var _window$Pelcro$site$r7, _window$Pelcro$site$r8;
|
|
18676
|
+
// Ensure the DOM element exists before creating Drop-in UI
|
|
18677
|
+
const dropinContainer = document.querySelector("#dropin-container");
|
|
18678
|
+
if (!dropinContainer) {
|
|
18679
|
+
console.error("Drop-in container not found. Waiting for DOM to be ready...");
|
|
18680
|
+
dispatch({
|
|
18681
|
+
type: SKELETON_LOADER,
|
|
18682
|
+
payload: false
|
|
18683
|
+
});
|
|
18684
|
+
return;
|
|
18685
|
+
}
|
|
18686
|
+
|
|
18687
|
+
// Small delay to ensure DOM is fully rendered
|
|
18688
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
18689
|
+
|
|
18690
|
+
// Calculate Google Pay amount using the same logic as Apple Pay
|
|
18691
|
+
const totalAmount = calculateTotalAmount(state, plan, invoice, order);
|
|
18692
|
+
const currency = getCurrencyFromPaymentType(plan, order, invoice);
|
|
18693
|
+
const googlePayAmount = formatPaymentAmount(totalAmount, currency, "Google Pay");
|
|
18694
|
+
|
|
18695
|
+
// Create Braintree Drop-in UI instance
|
|
18696
|
+
braintreeDropinRef.current = await createBraintreeDropin(braintreeToken, "#dropin-container", {
|
|
18697
|
+
// Customize the Drop-in UI appearance
|
|
18495
18698
|
styles: {
|
|
18496
18699
|
input: {
|
|
18497
18700
|
"font-size": "14px"
|
|
@@ -18503,48 +18706,85 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18503
18706
|
color: "green"
|
|
18504
18707
|
}
|
|
18505
18708
|
},
|
|
18506
|
-
|
|
18507
|
-
|
|
18508
|
-
|
|
18509
|
-
|
|
18510
|
-
|
|
18511
|
-
|
|
18512
|
-
|
|
18513
|
-
|
|
18709
|
+
// Disable PayPal to avoid conflicts with existing PayPal SDK
|
|
18710
|
+
// paypal: {
|
|
18711
|
+
// flow: "vault"
|
|
18712
|
+
// },
|
|
18713
|
+
// Enable Apple Pay if available
|
|
18714
|
+
applePay: {
|
|
18715
|
+
displayName: ((_window$Pelcro$site$r7 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r7 === void 0 ? void 0 : _window$Pelcro$site$r7.name) || "Pelcro",
|
|
18716
|
+
paymentRequest: {
|
|
18717
|
+
total: {
|
|
18718
|
+
label: getPaymentLabel(plan, order, invoice),
|
|
18719
|
+
amount: (() => {
|
|
18720
|
+
const totalAmount = calculateTotalAmount(state, plan, invoice, order);
|
|
18721
|
+
const currency = getCurrencyFromPaymentType(plan, order, invoice);
|
|
18722
|
+
return formatPaymentAmount(totalAmount, currency, "Apple Pay");
|
|
18723
|
+
})()
|
|
18724
|
+
}
|
|
18725
|
+
}
|
|
18726
|
+
},
|
|
18727
|
+
// Enable Google Pay for both orders and subscriptions
|
|
18728
|
+
googlePay: {
|
|
18729
|
+
googlePayVersion: 2,
|
|
18730
|
+
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,
|
|
18731
|
+
transactionInfo: {
|
|
18732
|
+
totalPriceStatus: "FINAL",
|
|
18733
|
+
totalPrice: googlePayAmount,
|
|
18734
|
+
currencyCode: (() => {
|
|
18735
|
+
const currency = getCurrencyFromPaymentType(plan, order, invoice);
|
|
18736
|
+
return (currency === null || currency === void 0 ? void 0 : currency.toUpperCase()) || "USD";
|
|
18737
|
+
})()
|
|
18514
18738
|
},
|
|
18515
|
-
|
|
18516
|
-
|
|
18517
|
-
|
|
18739
|
+
// Add button configuration
|
|
18740
|
+
button: {
|
|
18741
|
+
color: "black",
|
|
18742
|
+
type: type === "createPayment" ? "subscribe" : "buy"
|
|
18518
18743
|
}
|
|
18519
18744
|
}
|
|
18520
|
-
};
|
|
18745
|
+
});
|
|
18746
|
+
console.log("Setting skeleton loader to false after successful Braintree initialization");
|
|
18521
18747
|
dispatch({
|
|
18522
18748
|
type: SKELETON_LOADER,
|
|
18523
|
-
payload:
|
|
18749
|
+
payload: false
|
|
18524
18750
|
});
|
|
18525
|
-
|
|
18526
|
-
|
|
18527
|
-
|
|
18528
|
-
|
|
18529
|
-
|
|
18530
|
-
|
|
18531
|
-
|
|
18751
|
+
|
|
18752
|
+
// Clear any error alerts that were shown during initialization
|
|
18753
|
+
dispatch({
|
|
18754
|
+
type: SHOW_ALERT,
|
|
18755
|
+
payload: {
|
|
18756
|
+
type: "error",
|
|
18757
|
+
content: ""
|
|
18532
18758
|
}
|
|
18533
18759
|
});
|
|
18534
|
-
|
|
18535
|
-
|
|
18536
|
-
|
|
18537
|
-
|
|
18538
|
-
|
|
18539
|
-
|
|
18540
|
-
|
|
18541
|
-
|
|
18542
|
-
|
|
18543
|
-
|
|
18544
|
-
|
|
18760
|
+
} catch (error) {
|
|
18761
|
+
var _error$message, _error$message2, _error$message3, _error$message4;
|
|
18762
|
+
console.error("Failed to initialize Braintree Drop-in UI:", error);
|
|
18763
|
+
|
|
18764
|
+
// Check if it's a Google Pay specific error
|
|
18765
|
+
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")) {
|
|
18766
|
+
console.warn("Google Pay configuration issue detected. " + `Transaction type: ${type}. ` + "This might be due to merchant settings or unsupported payment flow.");
|
|
18767
|
+
}
|
|
18768
|
+
dispatch({
|
|
18769
|
+
type: SKELETON_LOADER,
|
|
18770
|
+
payload: false
|
|
18545
18771
|
});
|
|
18546
|
-
|
|
18772
|
+
|
|
18773
|
+
// Don't show error to user for Google Pay configuration issues
|
|
18774
|
+
// as it's expected for subscriptions
|
|
18775
|
+
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"))) {
|
|
18776
|
+
dispatch({
|
|
18777
|
+
type: SHOW_ALERT,
|
|
18778
|
+
payload: {
|
|
18779
|
+
type: "error",
|
|
18780
|
+
content: "Failed to initialize payment form. Please refresh and try again."
|
|
18781
|
+
}
|
|
18782
|
+
});
|
|
18783
|
+
}
|
|
18784
|
+
}
|
|
18547
18785
|
} else if (type == "updatePaymentSource" && paymentMethodToEdit) {
|
|
18786
|
+
// For updating payment methods, we still use hosted fields
|
|
18787
|
+
// as Drop-in UI doesn't support partial updates
|
|
18548
18788
|
const {
|
|
18549
18789
|
properties
|
|
18550
18790
|
} = paymentMethodToEdit !== null && paymentMethodToEdit !== void 0 ? paymentMethodToEdit : {};
|
|
@@ -18552,9 +18792,14 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18552
18792
|
exp_month: expMonth,
|
|
18553
18793
|
exp_year: expYear
|
|
18554
18794
|
} = properties !== null && properties !== void 0 ? properties : {};
|
|
18555
|
-
|
|
18556
|
-
|
|
18557
|
-
|
|
18795
|
+
dispatch({
|
|
18796
|
+
type: SKELETON_LOADER,
|
|
18797
|
+
payload: true
|
|
18798
|
+
});
|
|
18799
|
+
try {
|
|
18800
|
+
const clientInstance = await new window.braintree.client.create({
|
|
18801
|
+
authorization: braintreeToken
|
|
18802
|
+
});
|
|
18558
18803
|
const options = {
|
|
18559
18804
|
client: clientInstance,
|
|
18560
18805
|
styles: {
|
|
@@ -18576,41 +18821,28 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18576
18821
|
expirationYear: {
|
|
18577
18822
|
container: "#expiration-year",
|
|
18578
18823
|
prefill: expYear
|
|
18824
|
+
},
|
|
18825
|
+
cvv: {
|
|
18826
|
+
container: "#cvv"
|
|
18579
18827
|
}
|
|
18580
18828
|
}
|
|
18581
18829
|
};
|
|
18830
|
+
braintreeDropinRef.current = await window.braintree.hostedFields.create(options);
|
|
18831
|
+
|
|
18832
|
+
// dispatch({
|
|
18833
|
+
// type: SKELETON_LOADER,
|
|
18834
|
+
// payload: false
|
|
18835
|
+
// });
|
|
18836
|
+
} catch (error) {
|
|
18837
|
+
console.error("Failed to initialize Braintree hosted fields:", error);
|
|
18582
18838
|
dispatch({
|
|
18583
18839
|
type: SKELETON_LOADER,
|
|
18584
|
-
payload:
|
|
18585
|
-
});
|
|
18586
|
-
return window.braintree.hostedFields.create(options);
|
|
18587
|
-
});
|
|
18588
|
-
braintreeInstanceRef.current.then(hostedFieldInstance => {
|
|
18589
|
-
hostedFieldInstance.on("notEmpty", function (event) {
|
|
18590
|
-
const field = event.fields[event.emittedBy];
|
|
18591
|
-
if (field.isPotentiallyValid) {
|
|
18592
|
-
field.container.classList.remove("pelcro-input-invalid");
|
|
18593
|
-
}
|
|
18594
|
-
});
|
|
18595
|
-
hostedFieldInstance.on("validityChange", function (event) {
|
|
18596
|
-
const field = event.fields[event.emittedBy];
|
|
18597
|
-
|
|
18598
|
-
// Remove any previously applied error or warning classes
|
|
18599
|
-
field.container.classList.remove("is-valid");
|
|
18600
|
-
field.container.classList.remove("pelcro-input-invalid");
|
|
18601
|
-
if (field.isValid) {
|
|
18602
|
-
field.container.classList.add("is-valid");
|
|
18603
|
-
} else if (field.isPotentiallyValid) ; else {
|
|
18604
|
-
field.container.classList.add("pelcro-input-invalid");
|
|
18605
|
-
}
|
|
18840
|
+
payload: false
|
|
18606
18841
|
});
|
|
18607
|
-
}
|
|
18842
|
+
}
|
|
18608
18843
|
}
|
|
18609
18844
|
}
|
|
18610
18845
|
}
|
|
18611
|
-
React.useEffect(() => {
|
|
18612
|
-
initializeBraintree();
|
|
18613
|
-
}, [selectedPaymentMethodId, paymentMethodToEdit]);
|
|
18614
18846
|
const braintreeErrorHandler = tokenizeErr => {
|
|
18615
18847
|
var _tokenizeErr$details, _tokenizeErr$details2;
|
|
18616
18848
|
const cardNumber = document.querySelector("#card-number");
|
|
@@ -18673,51 +18905,55 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18673
18905
|
// no need to create a new source using braintree
|
|
18674
18906
|
return handleBraintreePayment(null, state.couponCode);
|
|
18675
18907
|
}
|
|
18676
|
-
if (!
|
|
18677
|
-
|
|
18678
|
-
|
|
18679
|
-
|
|
18680
|
-
|
|
18681
|
-
|
|
18682
|
-
|
|
18683
|
-
|
|
18684
|
-
|
|
18685
|
-
|
|
18686
|
-
|
|
18687
|
-
|
|
18688
|
-
|
|
18689
|
-
|
|
18690
|
-
|
|
18691
|
-
type: SHOW_ALERT,
|
|
18692
|
-
payload: {
|
|
18693
|
-
type: "error",
|
|
18694
|
-
content: braintreeErrorHandler(tokenizeErr)
|
|
18695
|
-
}
|
|
18696
|
-
});
|
|
18908
|
+
if (!braintreeDropinRef.current) {
|
|
18909
|
+
console.error("Braintree Drop-in UI wasn't initialized, please try again");
|
|
18910
|
+
dispatch({
|
|
18911
|
+
type: DISABLE_SUBMIT,
|
|
18912
|
+
payload: false
|
|
18913
|
+
});
|
|
18914
|
+
dispatch({
|
|
18915
|
+
type: LOADING,
|
|
18916
|
+
payload: false
|
|
18917
|
+
});
|
|
18918
|
+
return dispatch({
|
|
18919
|
+
type: SHOW_ALERT,
|
|
18920
|
+
payload: {
|
|
18921
|
+
type: "error",
|
|
18922
|
+
content: "Braintree Drop-in UI wasn't initialized, please try again"
|
|
18697
18923
|
}
|
|
18698
|
-
|
|
18699
|
-
// Directly handle the payment with the tokenized payload
|
|
18700
|
-
handleBraintreePayment(payload, state.couponCode);
|
|
18701
18924
|
});
|
|
18925
|
+
}
|
|
18926
|
+
dispatch({
|
|
18927
|
+
type: LOADING,
|
|
18928
|
+
payload: true
|
|
18929
|
+
});
|
|
18930
|
+
dispatch({
|
|
18931
|
+
type: DISABLE_SUBMIT,
|
|
18932
|
+
payload: true
|
|
18933
|
+
});
|
|
18934
|
+
|
|
18935
|
+
// Use appropriate method based on payment type
|
|
18936
|
+
const paymentMethodPromise = type === "updatePaymentSource" ? requestBraintreeHostedFieldsPaymentMethod(braintreeDropinRef.current) : requestBraintreePaymentMethod(braintreeDropinRef.current);
|
|
18937
|
+
paymentMethodPromise.then(payload => {
|
|
18938
|
+
// Drop-in UI handles 3D Secure automatically, just proceed with payment
|
|
18939
|
+
handleBraintreePayment(payload, state.couponCode);
|
|
18702
18940
|
}).catch(error => {
|
|
18703
|
-
|
|
18704
|
-
|
|
18705
|
-
|
|
18706
|
-
|
|
18707
|
-
|
|
18708
|
-
|
|
18709
|
-
|
|
18710
|
-
|
|
18711
|
-
|
|
18712
|
-
|
|
18713
|
-
|
|
18714
|
-
|
|
18715
|
-
|
|
18716
|
-
|
|
18717
|
-
|
|
18718
|
-
|
|
18719
|
-
});
|
|
18720
|
-
}
|
|
18941
|
+
console.error("Braintree payment error:", error);
|
|
18942
|
+
dispatch({
|
|
18943
|
+
type: DISABLE_SUBMIT,
|
|
18944
|
+
payload: false
|
|
18945
|
+
});
|
|
18946
|
+
dispatch({
|
|
18947
|
+
type: LOADING,
|
|
18948
|
+
payload: false
|
|
18949
|
+
});
|
|
18950
|
+
return dispatch({
|
|
18951
|
+
type: SHOW_ALERT,
|
|
18952
|
+
payload: {
|
|
18953
|
+
type: "error",
|
|
18954
|
+
content: braintreeErrorHandler(error)
|
|
18955
|
+
}
|
|
18956
|
+
});
|
|
18721
18957
|
});
|
|
18722
18958
|
};
|
|
18723
18959
|
const handleBraintreePayment = (braintreePaymentRequest, couponCode) => {
|
|
@@ -18767,7 +19003,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18767
19003
|
content: t("messages.sourceCreated")
|
|
18768
19004
|
}
|
|
18769
19005
|
});
|
|
18770
|
-
refreshUser();
|
|
18771
19006
|
onSuccess(res);
|
|
18772
19007
|
});
|
|
18773
19008
|
}
|
|
@@ -19236,9 +19471,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19236
19471
|
React.useEffect(() => {
|
|
19237
19472
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
19238
19473
|
if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
|
|
19239
|
-
var _window$Pelcro$site$
|
|
19240
|
-
const payPageId = (_window$Pelcro$site$
|
|
19241
|
-
const reportGroup = (_window$Pelcro$site$
|
|
19474
|
+
var _window$Pelcro$site$r9, _window$Pelcro$site$r10;
|
|
19475
|
+
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;
|
|
19476
|
+
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;
|
|
19242
19477
|
vantivInstanceRef.current = new window.EprotectIframeClient({
|
|
19243
19478
|
paypageId: payPageId,
|
|
19244
19479
|
reportGroup: reportGroup,
|
|
@@ -19302,13 +19537,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19302
19537
|
});
|
|
19303
19538
|
|
|
19304
19539
|
// When Google pay / Apple pay source created
|
|
19305
|
-
paymentRequest.on("source",
|
|
19540
|
+
paymentRequest.on("source", _ref8 => {
|
|
19306
19541
|
var _source$card;
|
|
19307
19542
|
let {
|
|
19308
19543
|
complete,
|
|
19309
19544
|
source,
|
|
19310
19545
|
...data
|
|
19311
|
-
} =
|
|
19546
|
+
} = _ref8;
|
|
19312
19547
|
dispatch({
|
|
19313
19548
|
type: DISABLE_COUPON_BUTTON,
|
|
19314
19549
|
payload: true
|
|
@@ -19323,11 +19558,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19323
19558
|
});
|
|
19324
19559
|
complete("success");
|
|
19325
19560
|
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") {
|
|
19326
|
-
return generate3DSecureSource(source).then(
|
|
19561
|
+
return generate3DSecureSource(source).then(_ref9 => {
|
|
19327
19562
|
let {
|
|
19328
19563
|
source,
|
|
19329
19564
|
error
|
|
19330
|
-
} =
|
|
19565
|
+
} = _ref9;
|
|
19331
19566
|
if (error) {
|
|
19332
19567
|
return handlePaymentError(error);
|
|
19333
19568
|
}
|
|
@@ -19358,9 +19593,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19358
19593
|
* Updates the total amount after adding taxes only if site taxes are enabled
|
|
19359
19594
|
*/
|
|
19360
19595
|
const updateTotalAmountWithTax = () => {
|
|
19361
|
-
var _window$Pelcro$site$
|
|
19596
|
+
var _window$Pelcro$site$r11;
|
|
19362
19597
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
|
|
19363
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
19598
|
+
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;
|
|
19364
19599
|
if (taxesEnabled && type === "createPayment") {
|
|
19365
19600
|
dispatch({
|
|
19366
19601
|
type: DISABLE_SUBMIT,
|
|
@@ -19979,7 +20214,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19979
20214
|
cardExpirationMonth: state === null || state === void 0 ? void 0 : state.month,
|
|
19980
20215
|
cardExpirationYear: state === null || state === void 0 ? void 0 : state.year
|
|
19981
20216
|
}, (err, orderResponse) => {
|
|
19982
|
-
var _window$
|
|
20217
|
+
var _window$Pelcro3, _window$Pelcro3$user, _window$Pelcro3$user$;
|
|
19983
20218
|
if (err) {
|
|
19984
20219
|
toggleAuthenticationSuccessPendingView(false);
|
|
19985
20220
|
dispatch({
|
|
@@ -20010,7 +20245,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20010
20245
|
});
|
|
20011
20246
|
}
|
|
20012
20247
|
window.Pelcro.user.refresh({
|
|
20013
|
-
auth_token: (_window$
|
|
20248
|
+
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
|
|
20014
20249
|
}, (err, res) => {
|
|
20015
20250
|
dispatch({
|
|
20016
20251
|
type: DISABLE_SUBMIT,
|
|
@@ -20049,11 +20284,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20049
20284
|
const createPaymentSource = (state, dispatch) => {
|
|
20050
20285
|
return stripe.createSource({
|
|
20051
20286
|
type: "card"
|
|
20052
|
-
}).then(
|
|
20287
|
+
}).then(_ref10 => {
|
|
20053
20288
|
let {
|
|
20054
20289
|
source,
|
|
20055
20290
|
error
|
|
20056
|
-
} =
|
|
20291
|
+
} = _ref10;
|
|
20057
20292
|
if (error) {
|
|
20058
20293
|
return handlePaymentError(error);
|
|
20059
20294
|
}
|
|
@@ -20167,11 +20402,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20167
20402
|
} = paymentMethodToDelete;
|
|
20168
20403
|
return stripe.createSource({
|
|
20169
20404
|
type: "card"
|
|
20170
|
-
}).then(
|
|
20405
|
+
}).then(_ref11 => {
|
|
20171
20406
|
let {
|
|
20172
20407
|
source,
|
|
20173
20408
|
error
|
|
20174
|
-
} =
|
|
20409
|
+
} = _ref11;
|
|
20175
20410
|
if (error) {
|
|
20176
20411
|
return handlePaymentError(error);
|
|
20177
20412
|
}
|
|
@@ -20271,12 +20506,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20271
20506
|
}
|
|
20272
20507
|
stripe.createSource({
|
|
20273
20508
|
type: "card"
|
|
20274
|
-
}).then(
|
|
20275
|
-
var
|
|
20509
|
+
}).then(_ref12 => {
|
|
20510
|
+
var _ref13, _ref14, _state$updatedPrice3;
|
|
20276
20511
|
let {
|
|
20277
20512
|
source,
|
|
20278
20513
|
error
|
|
20279
|
-
} =
|
|
20514
|
+
} = _ref12;
|
|
20280
20515
|
if (error) {
|
|
20281
20516
|
return handlePaymentError(error);
|
|
20282
20517
|
}
|
|
@@ -20295,7 +20530,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20295
20530
|
return total + item.price * item.quantity;
|
|
20296
20531
|
}, 0);
|
|
20297
20532
|
};
|
|
20298
|
-
(
|
|
20533
|
+
(_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();
|
|
20299
20534
|
return handlePayment(source);
|
|
20300
20535
|
}).catch(error => {
|
|
20301
20536
|
return handlePaymentError(error);
|
|
@@ -20307,11 +20542,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20307
20542
|
* @return {Promise}
|
|
20308
20543
|
*/
|
|
20309
20544
|
const resolveTaxCalculation = () => {
|
|
20310
|
-
var _window$Pelcro$site$
|
|
20545
|
+
var _window$Pelcro$site$r12;
|
|
20311
20546
|
if (type === "invoicePayment") {
|
|
20312
20547
|
return new Promise(resolve => resolve());
|
|
20313
20548
|
}
|
|
20314
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
20549
|
+
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;
|
|
20315
20550
|
return new Promise((resolve, reject) => {
|
|
20316
20551
|
// resolve early if taxes isn't enabled
|
|
20317
20552
|
if (!taxesEnabled) {
|
|
@@ -20669,6 +20904,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
20669
20904
|
return state;
|
|
20670
20905
|
}
|
|
20671
20906
|
}, initialState$l);
|
|
20907
|
+
React.useEffect(() => {
|
|
20908
|
+
initializeBraintree();
|
|
20909
|
+
}, [selectedPaymentMethodId, paymentMethodToEdit, state.updatedPrice]);
|
|
20672
20910
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
20673
20911
|
style: {
|
|
20674
20912
|
...style
|
|
@@ -20971,32 +21209,21 @@ const CheckoutForm = _ref => {
|
|
|
20971
21209
|
}, "Expiration Year *"), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
20972
21210
|
id: "expiration-year",
|
|
20973
21211
|
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
21212
|
+
})), /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("label", {
|
|
21213
|
+
htmlFor: "cvv"
|
|
21214
|
+
}, "CVV *"), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
21215
|
+
id: "cvv",
|
|
21216
|
+
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
20974
21217
|
})))) : /*#__PURE__*/React__default['default'].createElement("div", {
|
|
20975
21218
|
className: "plc-w-full plc-h-40 plc-bg-gray-300 plc-rounded plc-animate-pulse"
|
|
20976
21219
|
}));
|
|
20977
21220
|
}
|
|
20978
|
-
return /*#__PURE__*/React__default['default'].createElement("div", null,
|
|
21221
|
+
return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
20979
21222
|
className: "plc-max-w-[50em]"
|
|
20980
|
-
}, /*#__PURE__*/React__default['default'].createElement("
|
|
20981
|
-
|
|
20982
|
-
|
|
20983
|
-
|
|
20984
|
-
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
20985
|
-
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
20986
|
-
className: "plc-flex plc-items-start plc-space-x-8 plc-my-6"
|
|
20987
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("label", {
|
|
20988
|
-
htmlFor: "expiration-date"
|
|
20989
|
-
}, "Expiration Date *"), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
20990
|
-
id: "expiration-date",
|
|
20991
|
-
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
20992
|
-
})), /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("label", {
|
|
20993
|
-
htmlFor: "cvv"
|
|
20994
|
-
}, "CVC *"), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
20995
|
-
id: "cvv",
|
|
20996
|
-
className: "pelcro-input-field plc-h-12 plc-bg-white"
|
|
20997
|
-
})))) : /*#__PURE__*/React__default['default'].createElement("div", {
|
|
20998
|
-
className: "plc-w-full plc-h-40 plc-bg-gray-300 plc-rounded plc-animate-pulse"
|
|
20999
|
-
}));
|
|
21223
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
21224
|
+
id: "dropin-container",
|
|
21225
|
+
className: "plc-w-full plc-min-h-[300px]"
|
|
21226
|
+
})));
|
|
21000
21227
|
}
|
|
21001
21228
|
if (cardProcessor === "stripe") {
|
|
21002
21229
|
if (type === "updatePaymentSource") {
|
|
@@ -22214,7 +22441,7 @@ function PaymentMethodView(_ref) {
|
|
|
22214
22441
|
label: t("labels.isDefault")
|
|
22215
22442
|
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
22216
22443
|
className: "plc-grid plc-mt-4 plc-gap-y-2"
|
|
22217
|
-
}, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods &&
|
|
22444
|
+
}, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && cardProcessor === "braintree" && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, !supportsVantiv && !supportsCybersource && !supportsTap && /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)), showApplePayButton && supportsVantiv && /*#__PURE__*/React__default['default'].createElement(ApplePayButton, null))))));
|
|
22218
22445
|
}
|
|
22219
22446
|
|
|
22220
22447
|
const SubscriptionRenewView = _ref => {
|