@pelcro/react-pelcro-js 3.1.0-beta.5 → 3.1.0-beta.6
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 +28 -203
- package/dist/index.esm.js +28 -203
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -8629,7 +8629,6 @@ var pure_1 = pure.loadStripe;
|
|
|
8629
8629
|
* @param {Object} error Error object
|
|
8630
8630
|
* @return {string}
|
|
8631
8631
|
*/
|
|
8632
|
-
|
|
8633
8632
|
const getErrorMessages = error => {
|
|
8634
8633
|
var _error$error, _error$response, _error$response$data, _error$response3, _error$response3$data, _error$response3$data2, _error$response5, _error$response5$data;
|
|
8635
8634
|
|
|
@@ -8684,20 +8683,6 @@ const debounce = (func, waitTime) => {
|
|
|
8684
8683
|
timeout = setTimeout(later, waitTime);
|
|
8685
8684
|
};
|
|
8686
8685
|
};
|
|
8687
|
-
function getSiteCardProcessor() {
|
|
8688
|
-
var _window$Pelcro$site$r;
|
|
8689
|
-
|
|
8690
|
-
const {
|
|
8691
|
-
view
|
|
8692
|
-
} = usePelcro.getStore();
|
|
8693
|
-
const temp_ONLY_USE_VANTIV_WITH_SUBSCRIPTION_CREATE = view === "subscription-create";
|
|
8694
|
-
|
|
8695
|
-
if (temp_ONLY_USE_VANTIV_WITH_SUBSCRIPTION_CREATE && (_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_pay_page_id) {
|
|
8696
|
-
return "vantiv";
|
|
8697
|
-
}
|
|
8698
|
-
|
|
8699
|
-
return "stripe";
|
|
8700
|
-
}
|
|
8701
8686
|
|
|
8702
8687
|
/**
|
|
8703
8688
|
* @typedef {Object} OptionsType
|
|
@@ -8778,26 +8763,13 @@ const loadPaymentSDKs = () => {
|
|
|
8778
8763
|
if (!window.Stripe) {
|
|
8779
8764
|
pure_1(window.Pelcro.environment.stripe);
|
|
8780
8765
|
}
|
|
8781
|
-
}); // Load PayPal
|
|
8766
|
+
}); // Load PayPal SDK's
|
|
8782
8767
|
|
|
8783
8768
|
const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
|
|
8784
8769
|
|
|
8785
8770
|
if (supportsPaypal) {
|
|
8786
8771
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/client.min.js", "braintree-sdk");
|
|
8787
8772
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
|
|
8788
|
-
} // Load Vantiv SDKs
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_pay_page_id);
|
|
8792
|
-
|
|
8793
|
-
if (supportsVantiv) {
|
|
8794
|
-
if (!window.jQuery) {
|
|
8795
|
-
window.Pelcro.helpers.loadSDK("https://code.jquery.com/jquery-3.6.0.slim.min.js", "vantiv-jquery-sdk");
|
|
8796
|
-
}
|
|
8797
|
-
|
|
8798
|
-
if (!window.EprotectIframeClient) {
|
|
8799
|
-
window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js", "vantiv-eprotect-sdk");
|
|
8800
|
-
}
|
|
8801
8773
|
}
|
|
8802
8774
|
};
|
|
8803
8775
|
const loadAuth0SDK = () => {
|
|
@@ -12772,7 +12744,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
|
|
|
12772
12744
|
class Subscription {
|
|
12773
12745
|
/**
|
|
12774
12746
|
* Subscription service constructor
|
|
12775
|
-
* @param {(StripeGateway|
|
|
12747
|
+
* @param {(StripeGateway|PaypalGateWay)} paymentGateway
|
|
12776
12748
|
*/
|
|
12777
12749
|
constructor(paymentGateway) {
|
|
12778
12750
|
_defineProperty$3(this, "execute", (options, callback) => {
|
|
@@ -12793,7 +12765,7 @@ class Subscription {
|
|
|
12793
12765
|
_isPaymentGatewayInvalid.set(this, {
|
|
12794
12766
|
writable: true,
|
|
12795
12767
|
value: gateway => {
|
|
12796
|
-
return gateway && !(gateway instanceof StripeGateway
|
|
12768
|
+
return gateway && !(gateway instanceof StripeGateway) && gateway && !(gateway instanceof PaypalGateWay);
|
|
12797
12769
|
}
|
|
12798
12770
|
});
|
|
12799
12771
|
|
|
@@ -12846,8 +12818,7 @@ class Subscription {
|
|
|
12846
12818
|
}
|
|
12847
12819
|
const PAYMENT_GATEWAYS_ENUM = {
|
|
12848
12820
|
stripe: "stripe",
|
|
12849
|
-
paypal: "braintree"
|
|
12850
|
-
vantiv: "vantiv"
|
|
12821
|
+
paypal: "braintree"
|
|
12851
12822
|
};
|
|
12852
12823
|
/**
|
|
12853
12824
|
* Subscription Strategies
|
|
@@ -13039,7 +13010,7 @@ var _createGiftedSubscription2 = /*#__PURE__*/new WeakMap();
|
|
|
13039
13010
|
|
|
13040
13011
|
var _payInvoice2 = /*#__PURE__*/new WeakMap();
|
|
13041
13012
|
|
|
13042
|
-
class
|
|
13013
|
+
class PaypalGateWay {
|
|
13043
13014
|
constructor() {
|
|
13044
13015
|
_paymentGateway2.set(this, {
|
|
13045
13016
|
writable: true,
|
|
@@ -13140,57 +13111,6 @@ class PaypalGateway {
|
|
|
13140
13111
|
|
|
13141
13112
|
}
|
|
13142
13113
|
|
|
13143
|
-
var _paymentGateway3 = /*#__PURE__*/new WeakMap();
|
|
13144
|
-
|
|
13145
|
-
var _createSubscription3 = /*#__PURE__*/new WeakMap();
|
|
13146
|
-
|
|
13147
|
-
class VantivGateway {
|
|
13148
|
-
constructor() {
|
|
13149
|
-
_paymentGateway3.set(this, {
|
|
13150
|
-
writable: true,
|
|
13151
|
-
value: PAYMENT_GATEWAYS_ENUM["vantiv"]
|
|
13152
|
-
});
|
|
13153
|
-
|
|
13154
|
-
_defineProperty$3(this, "execute", (options, callback) => {
|
|
13155
|
-
const types = SUBSCRIPTION_TYPES;
|
|
13156
|
-
|
|
13157
|
-
switch (options.type) {
|
|
13158
|
-
case types.CREATE_SUBSCRIPTION:
|
|
13159
|
-
return _classPrivateFieldGet(this, _createSubscription3).call(this, options, callback);
|
|
13160
|
-
|
|
13161
|
-
default:
|
|
13162
|
-
console.error("Unsupported subscriptiion method: vantiv Gateway");
|
|
13163
|
-
}
|
|
13164
|
-
});
|
|
13165
|
-
|
|
13166
|
-
_createSubscription3.set(this, {
|
|
13167
|
-
writable: true,
|
|
13168
|
-
value: (options, callback) => {
|
|
13169
|
-
const {
|
|
13170
|
-
token,
|
|
13171
|
-
plan,
|
|
13172
|
-
couponCode,
|
|
13173
|
-
product,
|
|
13174
|
-
quantity = 1,
|
|
13175
|
-
addressId
|
|
13176
|
-
} = options;
|
|
13177
|
-
window.Pelcro.subscription.create({
|
|
13178
|
-
quantity,
|
|
13179
|
-
gateway_token: token,
|
|
13180
|
-
payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
|
|
13181
|
-
auth_token: window.Pelcro.user.read().auth_token,
|
|
13182
|
-
plan_id: plan.id,
|
|
13183
|
-
coupon_code: couponCode,
|
|
13184
|
-
address_id: product.address_required ? addressId : null
|
|
13185
|
-
}, (err, res) => {
|
|
13186
|
-
callback(err, res);
|
|
13187
|
-
});
|
|
13188
|
-
}
|
|
13189
|
-
});
|
|
13190
|
-
}
|
|
13191
|
-
|
|
13192
|
-
}
|
|
13193
|
-
|
|
13194
13114
|
/**
|
|
13195
13115
|
* @typedef {Object} PaymentStateType
|
|
13196
13116
|
* @property {boolean} disableSubmit
|
|
@@ -13278,78 +13198,6 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13278
13198
|
updateTotalAmountWithTax();
|
|
13279
13199
|
}, []);
|
|
13280
13200
|
|
|
13281
|
-
function submitVantivPayment() {
|
|
13282
|
-
if (!vantivInstanceRef.current) {
|
|
13283
|
-
return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
|
|
13284
|
-
}
|
|
13285
|
-
|
|
13286
|
-
const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
|
|
13287
|
-
|
|
13288
|
-
vantivInstanceRef.current.getPaypageRegistrationId({
|
|
13289
|
-
id: orderId,
|
|
13290
|
-
orderId: orderId
|
|
13291
|
-
});
|
|
13292
|
-
}
|
|
13293
|
-
|
|
13294
|
-
function handleVantivPayment(paymentRequest) {
|
|
13295
|
-
const SUCCESS_STATUS = "870";
|
|
13296
|
-
|
|
13297
|
-
if (paymentRequest.response !== SUCCESS_STATUS) {
|
|
13298
|
-
return handlePaymentError({
|
|
13299
|
-
error: new Error(paymentRequest.message)
|
|
13300
|
-
});
|
|
13301
|
-
}
|
|
13302
|
-
|
|
13303
|
-
const subscription = new Subscription(new VantivGateway());
|
|
13304
|
-
const {
|
|
13305
|
-
couponCode
|
|
13306
|
-
} = state;
|
|
13307
|
-
return subscription.execute({
|
|
13308
|
-
type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
|
|
13309
|
-
token: paymentRequest,
|
|
13310
|
-
quantity: plan.quantity,
|
|
13311
|
-
plan,
|
|
13312
|
-
couponCode,
|
|
13313
|
-
product,
|
|
13314
|
-
addressId: selectedAddressId
|
|
13315
|
-
}, (err, res) => {
|
|
13316
|
-
if (err) {
|
|
13317
|
-
return handlePaymentError(err);
|
|
13318
|
-
}
|
|
13319
|
-
|
|
13320
|
-
onSuccess(res);
|
|
13321
|
-
});
|
|
13322
|
-
}
|
|
13323
|
-
|
|
13324
|
-
const vantivInstanceRef = React__default['default'].useRef(null);
|
|
13325
|
-
React.useEffect(() => {
|
|
13326
|
-
const cardProcessor = getSiteCardProcessor();
|
|
13327
|
-
|
|
13328
|
-
if (cardProcessor === "vantiv") {
|
|
13329
|
-
var _window$Pelcro$site$r;
|
|
13330
|
-
|
|
13331
|
-
const payPageId = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_pay_page_id;
|
|
13332
|
-
vantivInstanceRef.current = new window.EprotectIframeClient({
|
|
13333
|
-
paypageId: payPageId,
|
|
13334
|
-
reportGroup: payPageId,
|
|
13335
|
-
style: "pelcro",
|
|
13336
|
-
height: "245",
|
|
13337
|
-
timeout: 50000,
|
|
13338
|
-
div: "eProtectiframe",
|
|
13339
|
-
callback: handleVantivPayment,
|
|
13340
|
-
showCvv: true,
|
|
13341
|
-
numYears: 8,
|
|
13342
|
-
placeholderText: {
|
|
13343
|
-
cvv: "CVV",
|
|
13344
|
-
accountNumber: "1234 1234 1234 1234"
|
|
13345
|
-
},
|
|
13346
|
-
enhancedUxFeatures: {
|
|
13347
|
-
inlineFieldValidations: true
|
|
13348
|
-
}
|
|
13349
|
-
});
|
|
13350
|
-
}
|
|
13351
|
-
}, []);
|
|
13352
|
-
|
|
13353
13201
|
const initPaymentRequest = (state, dispatch) => {
|
|
13354
13202
|
try {
|
|
13355
13203
|
const paymentRequest = stripe.paymentRequest({
|
|
@@ -13420,9 +13268,9 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13420
13268
|
|
|
13421
13269
|
|
|
13422
13270
|
const updateTotalAmountWithTax = () => {
|
|
13423
|
-
var _window$Pelcro$site$
|
|
13271
|
+
var _window$Pelcro$site$r;
|
|
13424
13272
|
|
|
13425
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
13273
|
+
const taxesEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.taxes_enabled;
|
|
13426
13274
|
|
|
13427
13275
|
if (taxesEnabled && type === "createPayment") {
|
|
13428
13276
|
dispatch({
|
|
@@ -13772,7 +13620,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13772
13620
|
|
|
13773
13621
|
|
|
13774
13622
|
const handlePaypalSubscription = (state, paypalNonce) => {
|
|
13775
|
-
const subscription = new Subscription(new
|
|
13623
|
+
const subscription = new Subscription(new PaypalGateWay());
|
|
13776
13624
|
const {
|
|
13777
13625
|
couponCode
|
|
13778
13626
|
} = state;
|
|
@@ -14067,13 +13915,13 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14067
13915
|
|
|
14068
13916
|
|
|
14069
13917
|
const resolveTaxCalculation = () => {
|
|
14070
|
-
var _window$Pelcro$site$
|
|
13918
|
+
var _window$Pelcro$site$r2;
|
|
14071
13919
|
|
|
14072
13920
|
if (type === "invoicePayment") {
|
|
14073
13921
|
return new Promise(resolve => resolve());
|
|
14074
13922
|
}
|
|
14075
13923
|
|
|
14076
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
13924
|
+
const taxesEnabled = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.taxes_enabled;
|
|
14077
13925
|
return new Promise((resolve, reject) => {
|
|
14078
13926
|
// resolve early if taxes isn't enabled
|
|
14079
13927
|
if (!taxesEnabled) {
|
|
@@ -14152,8 +14000,6 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14152
14000
|
};
|
|
14153
14001
|
|
|
14154
14002
|
const handlePaymentError = error => {
|
|
14155
|
-
var _getErrorMessages;
|
|
14156
|
-
|
|
14157
14003
|
if (error.type === "validation_error" && // Subscription creation & renewal
|
|
14158
14004
|
type === "createPayment") {
|
|
14159
14005
|
var _state$couponObject;
|
|
@@ -14172,7 +14018,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14172
14018
|
type: SHOW_ALERT,
|
|
14173
14019
|
payload: {
|
|
14174
14020
|
type: "error",
|
|
14175
|
-
content:
|
|
14021
|
+
content: error === null || error === void 0 ? void 0 : error.message
|
|
14176
14022
|
}
|
|
14177
14023
|
});
|
|
14178
14024
|
dispatch({
|
|
@@ -14276,14 +14122,10 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14276
14122
|
}
|
|
14277
14123
|
|
|
14278
14124
|
if (type === "updatePaymentSource") {
|
|
14279
|
-
|
|
14280
|
-
}
|
|
14281
|
-
|
|
14282
|
-
if (getSiteCardProcessor() === "vantiv") {
|
|
14283
|
-
return submitVantivPayment();
|
|
14125
|
+
updatePaymentSource(state, dispatch);
|
|
14126
|
+
} else {
|
|
14127
|
+
submitPayment(state);
|
|
14284
14128
|
}
|
|
14285
|
-
|
|
14286
|
-
submitPayment(state);
|
|
14287
14129
|
});
|
|
14288
14130
|
|
|
14289
14131
|
case HANDLE_PAYPAL_SUBSCRIPTION:
|
|
@@ -14472,35 +14314,19 @@ const CheckoutForm = () => {
|
|
|
14472
14314
|
const {
|
|
14473
14315
|
selectedPaymentMethodId
|
|
14474
14316
|
} = usePelcro();
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
|
|
14478
|
-
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
|
|
14483
|
-
|
|
14484
|
-
|
|
14485
|
-
}
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(PelcroCardNumber, {
|
|
14489
|
-
autoFocus: true
|
|
14490
|
-
}), /*#__PURE__*/React__default['default'].createElement("img", {
|
|
14491
|
-
alt: "credit_cards",
|
|
14492
|
-
className: "plc-w-auto plc-h-4 plc-mt-2",
|
|
14493
|
-
src: "https://js.pelcro.com/ui/plugin/main/images/credit_cards.png"
|
|
14494
|
-
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14495
|
-
className: "plc-flex plc-items-end plc-justify-between plc-my-2"
|
|
14496
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14497
|
-
className: "plc-w-6/12 plc-pr-4"
|
|
14498
|
-
}, /*#__PURE__*/React__default['default'].createElement(PelcroCardExpiry, null)), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14499
|
-
className: "plc-w-6/12 plc-pl-4"
|
|
14500
|
-
}, /*#__PURE__*/React__default['default'].createElement(PelcroCardCVC, null))));
|
|
14501
|
-
}
|
|
14502
|
-
|
|
14503
|
-
return null;
|
|
14317
|
+
return !selectedPaymentMethodId && /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(PelcroCardNumber, {
|
|
14318
|
+
autoFocus: true
|
|
14319
|
+
}), /*#__PURE__*/React__default['default'].createElement("img", {
|
|
14320
|
+
alt: "credit_cards",
|
|
14321
|
+
className: "plc-h-4 plc-w-auto plc-mt-2",
|
|
14322
|
+
src: "https://js.pelcro.com/ui/plugin/main/images/credit_cards.png"
|
|
14323
|
+
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14324
|
+
className: "plc-flex plc-justify-between plc-my-2 plc-items-end"
|
|
14325
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14326
|
+
className: "plc-w-6/12 plc-pr-4"
|
|
14327
|
+
}, /*#__PURE__*/React__default['default'].createElement(PelcroCardExpiry, null)), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14328
|
+
className: "plc-w-6/12 plc-pl-4"
|
|
14329
|
+
}, /*#__PURE__*/React__default['default'].createElement(PelcroCardCVC, null))));
|
|
14504
14330
|
};
|
|
14505
14331
|
|
|
14506
14332
|
const DiscountedPrice = props => {
|
|
@@ -15150,10 +14976,9 @@ function PaymentMethodView({
|
|
|
15150
14976
|
const {
|
|
15151
14977
|
t
|
|
15152
14978
|
} = useTranslation("checkoutForm");
|
|
15153
|
-
const cardProcessor = getSiteCardProcessor();
|
|
15154
14979
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
15155
14980
|
className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
|
|
15156
|
-
},
|
|
14981
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
15157
14982
|
className: "plc-flex plc-items-center plc-w-full plc-px-4 plc-py-2 plc-text-center plc-text-green-600 plc-border plc-border-green-400 plc-rounded plc-bg-green-50"
|
|
15158
14983
|
}, /*#__PURE__*/React__default['default'].createElement(SvgLock, {
|
|
15159
14984
|
className: "plc-w-5 plc-h-5 plc-mr-1"
|
package/dist/index.esm.js
CHANGED
|
@@ -8599,7 +8599,6 @@ var pure_1 = pure.loadStripe;
|
|
|
8599
8599
|
* @param {Object} error Error object
|
|
8600
8600
|
* @return {string}
|
|
8601
8601
|
*/
|
|
8602
|
-
|
|
8603
8602
|
const getErrorMessages = error => {
|
|
8604
8603
|
var _error$error, _error$response, _error$response$data, _error$response3, _error$response3$data, _error$response3$data2, _error$response5, _error$response5$data;
|
|
8605
8604
|
|
|
@@ -8654,20 +8653,6 @@ const debounce = (func, waitTime) => {
|
|
|
8654
8653
|
timeout = setTimeout(later, waitTime);
|
|
8655
8654
|
};
|
|
8656
8655
|
};
|
|
8657
|
-
function getSiteCardProcessor() {
|
|
8658
|
-
var _window$Pelcro$site$r;
|
|
8659
|
-
|
|
8660
|
-
const {
|
|
8661
|
-
view
|
|
8662
|
-
} = usePelcro.getStore();
|
|
8663
|
-
const temp_ONLY_USE_VANTIV_WITH_SUBSCRIPTION_CREATE = view === "subscription-create";
|
|
8664
|
-
|
|
8665
|
-
if (temp_ONLY_USE_VANTIV_WITH_SUBSCRIPTION_CREATE && (_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_pay_page_id) {
|
|
8666
|
-
return "vantiv";
|
|
8667
|
-
}
|
|
8668
|
-
|
|
8669
|
-
return "stripe";
|
|
8670
|
-
}
|
|
8671
8656
|
|
|
8672
8657
|
/**
|
|
8673
8658
|
* @typedef {Object} OptionsType
|
|
@@ -8748,26 +8733,13 @@ const loadPaymentSDKs = () => {
|
|
|
8748
8733
|
if (!window.Stripe) {
|
|
8749
8734
|
pure_1(window.Pelcro.environment.stripe);
|
|
8750
8735
|
}
|
|
8751
|
-
}); // Load PayPal
|
|
8736
|
+
}); // Load PayPal SDK's
|
|
8752
8737
|
|
|
8753
8738
|
const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
|
|
8754
8739
|
|
|
8755
8740
|
if (supportsPaypal) {
|
|
8756
8741
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/client.min.js", "braintree-sdk");
|
|
8757
8742
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
|
|
8758
|
-
} // Load Vantiv SDKs
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_pay_page_id);
|
|
8762
|
-
|
|
8763
|
-
if (supportsVantiv) {
|
|
8764
|
-
if (!window.jQuery) {
|
|
8765
|
-
window.Pelcro.helpers.loadSDK("https://code.jquery.com/jquery-3.6.0.slim.min.js", "vantiv-jquery-sdk");
|
|
8766
|
-
}
|
|
8767
|
-
|
|
8768
|
-
if (!window.EprotectIframeClient) {
|
|
8769
|
-
window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js", "vantiv-eprotect-sdk");
|
|
8770
|
-
}
|
|
8771
8743
|
}
|
|
8772
8744
|
};
|
|
8773
8745
|
const loadAuth0SDK = () => {
|
|
@@ -12742,7 +12714,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
|
|
|
12742
12714
|
class Subscription {
|
|
12743
12715
|
/**
|
|
12744
12716
|
* Subscription service constructor
|
|
12745
|
-
* @param {(StripeGateway|
|
|
12717
|
+
* @param {(StripeGateway|PaypalGateWay)} paymentGateway
|
|
12746
12718
|
*/
|
|
12747
12719
|
constructor(paymentGateway) {
|
|
12748
12720
|
_defineProperty$3(this, "execute", (options, callback) => {
|
|
@@ -12763,7 +12735,7 @@ class Subscription {
|
|
|
12763
12735
|
_isPaymentGatewayInvalid.set(this, {
|
|
12764
12736
|
writable: true,
|
|
12765
12737
|
value: gateway => {
|
|
12766
|
-
return gateway && !(gateway instanceof StripeGateway
|
|
12738
|
+
return gateway && !(gateway instanceof StripeGateway) && gateway && !(gateway instanceof PaypalGateWay);
|
|
12767
12739
|
}
|
|
12768
12740
|
});
|
|
12769
12741
|
|
|
@@ -12816,8 +12788,7 @@ class Subscription {
|
|
|
12816
12788
|
}
|
|
12817
12789
|
const PAYMENT_GATEWAYS_ENUM = {
|
|
12818
12790
|
stripe: "stripe",
|
|
12819
|
-
paypal: "braintree"
|
|
12820
|
-
vantiv: "vantiv"
|
|
12791
|
+
paypal: "braintree"
|
|
12821
12792
|
};
|
|
12822
12793
|
/**
|
|
12823
12794
|
* Subscription Strategies
|
|
@@ -13009,7 +12980,7 @@ var _createGiftedSubscription2 = /*#__PURE__*/new WeakMap();
|
|
|
13009
12980
|
|
|
13010
12981
|
var _payInvoice2 = /*#__PURE__*/new WeakMap();
|
|
13011
12982
|
|
|
13012
|
-
class
|
|
12983
|
+
class PaypalGateWay {
|
|
13013
12984
|
constructor() {
|
|
13014
12985
|
_paymentGateway2.set(this, {
|
|
13015
12986
|
writable: true,
|
|
@@ -13110,57 +13081,6 @@ class PaypalGateway {
|
|
|
13110
13081
|
|
|
13111
13082
|
}
|
|
13112
13083
|
|
|
13113
|
-
var _paymentGateway3 = /*#__PURE__*/new WeakMap();
|
|
13114
|
-
|
|
13115
|
-
var _createSubscription3 = /*#__PURE__*/new WeakMap();
|
|
13116
|
-
|
|
13117
|
-
class VantivGateway {
|
|
13118
|
-
constructor() {
|
|
13119
|
-
_paymentGateway3.set(this, {
|
|
13120
|
-
writable: true,
|
|
13121
|
-
value: PAYMENT_GATEWAYS_ENUM["vantiv"]
|
|
13122
|
-
});
|
|
13123
|
-
|
|
13124
|
-
_defineProperty$3(this, "execute", (options, callback) => {
|
|
13125
|
-
const types = SUBSCRIPTION_TYPES;
|
|
13126
|
-
|
|
13127
|
-
switch (options.type) {
|
|
13128
|
-
case types.CREATE_SUBSCRIPTION:
|
|
13129
|
-
return _classPrivateFieldGet(this, _createSubscription3).call(this, options, callback);
|
|
13130
|
-
|
|
13131
|
-
default:
|
|
13132
|
-
console.error("Unsupported subscriptiion method: vantiv Gateway");
|
|
13133
|
-
}
|
|
13134
|
-
});
|
|
13135
|
-
|
|
13136
|
-
_createSubscription3.set(this, {
|
|
13137
|
-
writable: true,
|
|
13138
|
-
value: (options, callback) => {
|
|
13139
|
-
const {
|
|
13140
|
-
token,
|
|
13141
|
-
plan,
|
|
13142
|
-
couponCode,
|
|
13143
|
-
product,
|
|
13144
|
-
quantity = 1,
|
|
13145
|
-
addressId
|
|
13146
|
-
} = options;
|
|
13147
|
-
window.Pelcro.subscription.create({
|
|
13148
|
-
quantity,
|
|
13149
|
-
gateway_token: token,
|
|
13150
|
-
payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
|
|
13151
|
-
auth_token: window.Pelcro.user.read().auth_token,
|
|
13152
|
-
plan_id: plan.id,
|
|
13153
|
-
coupon_code: couponCode,
|
|
13154
|
-
address_id: product.address_required ? addressId : null
|
|
13155
|
-
}, (err, res) => {
|
|
13156
|
-
callback(err, res);
|
|
13157
|
-
});
|
|
13158
|
-
}
|
|
13159
|
-
});
|
|
13160
|
-
}
|
|
13161
|
-
|
|
13162
|
-
}
|
|
13163
|
-
|
|
13164
13084
|
/**
|
|
13165
13085
|
* @typedef {Object} PaymentStateType
|
|
13166
13086
|
* @property {boolean} disableSubmit
|
|
@@ -13248,78 +13168,6 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13248
13168
|
updateTotalAmountWithTax();
|
|
13249
13169
|
}, []);
|
|
13250
13170
|
|
|
13251
|
-
function submitVantivPayment() {
|
|
13252
|
-
if (!vantivInstanceRef.current) {
|
|
13253
|
-
return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
|
|
13254
|
-
}
|
|
13255
|
-
|
|
13256
|
-
const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
|
|
13257
|
-
|
|
13258
|
-
vantivInstanceRef.current.getPaypageRegistrationId({
|
|
13259
|
-
id: orderId,
|
|
13260
|
-
orderId: orderId
|
|
13261
|
-
});
|
|
13262
|
-
}
|
|
13263
|
-
|
|
13264
|
-
function handleVantivPayment(paymentRequest) {
|
|
13265
|
-
const SUCCESS_STATUS = "870";
|
|
13266
|
-
|
|
13267
|
-
if (paymentRequest.response !== SUCCESS_STATUS) {
|
|
13268
|
-
return handlePaymentError({
|
|
13269
|
-
error: new Error(paymentRequest.message)
|
|
13270
|
-
});
|
|
13271
|
-
}
|
|
13272
|
-
|
|
13273
|
-
const subscription = new Subscription(new VantivGateway());
|
|
13274
|
-
const {
|
|
13275
|
-
couponCode
|
|
13276
|
-
} = state;
|
|
13277
|
-
return subscription.execute({
|
|
13278
|
-
type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
|
|
13279
|
-
token: paymentRequest,
|
|
13280
|
-
quantity: plan.quantity,
|
|
13281
|
-
plan,
|
|
13282
|
-
couponCode,
|
|
13283
|
-
product,
|
|
13284
|
-
addressId: selectedAddressId
|
|
13285
|
-
}, (err, res) => {
|
|
13286
|
-
if (err) {
|
|
13287
|
-
return handlePaymentError(err);
|
|
13288
|
-
}
|
|
13289
|
-
|
|
13290
|
-
onSuccess(res);
|
|
13291
|
-
});
|
|
13292
|
-
}
|
|
13293
|
-
|
|
13294
|
-
const vantivInstanceRef = React__default.useRef(null);
|
|
13295
|
-
useEffect(() => {
|
|
13296
|
-
const cardProcessor = getSiteCardProcessor();
|
|
13297
|
-
|
|
13298
|
-
if (cardProcessor === "vantiv") {
|
|
13299
|
-
var _window$Pelcro$site$r;
|
|
13300
|
-
|
|
13301
|
-
const payPageId = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_pay_page_id;
|
|
13302
|
-
vantivInstanceRef.current = new window.EprotectIframeClient({
|
|
13303
|
-
paypageId: payPageId,
|
|
13304
|
-
reportGroup: payPageId,
|
|
13305
|
-
style: "pelcro",
|
|
13306
|
-
height: "245",
|
|
13307
|
-
timeout: 50000,
|
|
13308
|
-
div: "eProtectiframe",
|
|
13309
|
-
callback: handleVantivPayment,
|
|
13310
|
-
showCvv: true,
|
|
13311
|
-
numYears: 8,
|
|
13312
|
-
placeholderText: {
|
|
13313
|
-
cvv: "CVV",
|
|
13314
|
-
accountNumber: "1234 1234 1234 1234"
|
|
13315
|
-
},
|
|
13316
|
-
enhancedUxFeatures: {
|
|
13317
|
-
inlineFieldValidations: true
|
|
13318
|
-
}
|
|
13319
|
-
});
|
|
13320
|
-
}
|
|
13321
|
-
}, []);
|
|
13322
|
-
|
|
13323
13171
|
const initPaymentRequest = (state, dispatch) => {
|
|
13324
13172
|
try {
|
|
13325
13173
|
const paymentRequest = stripe.paymentRequest({
|
|
@@ -13390,9 +13238,9 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13390
13238
|
|
|
13391
13239
|
|
|
13392
13240
|
const updateTotalAmountWithTax = () => {
|
|
13393
|
-
var _window$Pelcro$site$
|
|
13241
|
+
var _window$Pelcro$site$r;
|
|
13394
13242
|
|
|
13395
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
13243
|
+
const taxesEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.taxes_enabled;
|
|
13396
13244
|
|
|
13397
13245
|
if (taxesEnabled && type === "createPayment") {
|
|
13398
13246
|
dispatch({
|
|
@@ -13742,7 +13590,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13742
13590
|
|
|
13743
13591
|
|
|
13744
13592
|
const handlePaypalSubscription = (state, paypalNonce) => {
|
|
13745
|
-
const subscription = new Subscription(new
|
|
13593
|
+
const subscription = new Subscription(new PaypalGateWay());
|
|
13746
13594
|
const {
|
|
13747
13595
|
couponCode
|
|
13748
13596
|
} = state;
|
|
@@ -14037,13 +13885,13 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14037
13885
|
|
|
14038
13886
|
|
|
14039
13887
|
const resolveTaxCalculation = () => {
|
|
14040
|
-
var _window$Pelcro$site$
|
|
13888
|
+
var _window$Pelcro$site$r2;
|
|
14041
13889
|
|
|
14042
13890
|
if (type === "invoicePayment") {
|
|
14043
13891
|
return new Promise(resolve => resolve());
|
|
14044
13892
|
}
|
|
14045
13893
|
|
|
14046
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
13894
|
+
const taxesEnabled = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.taxes_enabled;
|
|
14047
13895
|
return new Promise((resolve, reject) => {
|
|
14048
13896
|
// resolve early if taxes isn't enabled
|
|
14049
13897
|
if (!taxesEnabled) {
|
|
@@ -14122,8 +13970,6 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14122
13970
|
};
|
|
14123
13971
|
|
|
14124
13972
|
const handlePaymentError = error => {
|
|
14125
|
-
var _getErrorMessages;
|
|
14126
|
-
|
|
14127
13973
|
if (error.type === "validation_error" && // Subscription creation & renewal
|
|
14128
13974
|
type === "createPayment") {
|
|
14129
13975
|
var _state$couponObject;
|
|
@@ -14142,7 +13988,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14142
13988
|
type: SHOW_ALERT,
|
|
14143
13989
|
payload: {
|
|
14144
13990
|
type: "error",
|
|
14145
|
-
content:
|
|
13991
|
+
content: error === null || error === void 0 ? void 0 : error.message
|
|
14146
13992
|
}
|
|
14147
13993
|
});
|
|
14148
13994
|
dispatch({
|
|
@@ -14246,14 +14092,10 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14246
14092
|
}
|
|
14247
14093
|
|
|
14248
14094
|
if (type === "updatePaymentSource") {
|
|
14249
|
-
|
|
14250
|
-
}
|
|
14251
|
-
|
|
14252
|
-
if (getSiteCardProcessor() === "vantiv") {
|
|
14253
|
-
return submitVantivPayment();
|
|
14095
|
+
updatePaymentSource(state, dispatch);
|
|
14096
|
+
} else {
|
|
14097
|
+
submitPayment(state);
|
|
14254
14098
|
}
|
|
14255
|
-
|
|
14256
|
-
submitPayment(state);
|
|
14257
14099
|
});
|
|
14258
14100
|
|
|
14259
14101
|
case HANDLE_PAYPAL_SUBSCRIPTION:
|
|
@@ -14442,35 +14284,19 @@ const CheckoutForm = () => {
|
|
|
14442
14284
|
const {
|
|
14443
14285
|
selectedPaymentMethodId
|
|
14444
14286
|
} = usePelcro();
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14451
|
-
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
}
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(PelcroCardNumber, {
|
|
14459
|
-
autoFocus: true
|
|
14460
|
-
}), /*#__PURE__*/React__default.createElement("img", {
|
|
14461
|
-
alt: "credit_cards",
|
|
14462
|
-
className: "plc-w-auto plc-h-4 plc-mt-2",
|
|
14463
|
-
src: "https://js.pelcro.com/ui/plugin/main/images/credit_cards.png"
|
|
14464
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
14465
|
-
className: "plc-flex plc-items-end plc-justify-between plc-my-2"
|
|
14466
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
14467
|
-
className: "plc-w-6/12 plc-pr-4"
|
|
14468
|
-
}, /*#__PURE__*/React__default.createElement(PelcroCardExpiry, null)), /*#__PURE__*/React__default.createElement("div", {
|
|
14469
|
-
className: "plc-w-6/12 plc-pl-4"
|
|
14470
|
-
}, /*#__PURE__*/React__default.createElement(PelcroCardCVC, null))));
|
|
14471
|
-
}
|
|
14472
|
-
|
|
14473
|
-
return null;
|
|
14287
|
+
return !selectedPaymentMethodId && /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(PelcroCardNumber, {
|
|
14288
|
+
autoFocus: true
|
|
14289
|
+
}), /*#__PURE__*/React__default.createElement("img", {
|
|
14290
|
+
alt: "credit_cards",
|
|
14291
|
+
className: "plc-h-4 plc-w-auto plc-mt-2",
|
|
14292
|
+
src: "https://js.pelcro.com/ui/plugin/main/images/credit_cards.png"
|
|
14293
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
14294
|
+
className: "plc-flex plc-justify-between plc-my-2 plc-items-end"
|
|
14295
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
14296
|
+
className: "plc-w-6/12 plc-pr-4"
|
|
14297
|
+
}, /*#__PURE__*/React__default.createElement(PelcroCardExpiry, null)), /*#__PURE__*/React__default.createElement("div", {
|
|
14298
|
+
className: "plc-w-6/12 plc-pl-4"
|
|
14299
|
+
}, /*#__PURE__*/React__default.createElement(PelcroCardCVC, null))));
|
|
14474
14300
|
};
|
|
14475
14301
|
|
|
14476
14302
|
const DiscountedPrice = props => {
|
|
@@ -15120,10 +14946,9 @@ function PaymentMethodView({
|
|
|
15120
14946
|
const {
|
|
15121
14947
|
t
|
|
15122
14948
|
} = useTranslation("checkoutForm");
|
|
15123
|
-
const cardProcessor = getSiteCardProcessor();
|
|
15124
14949
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
15125
14950
|
className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
|
|
15126
|
-
},
|
|
14951
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
15127
14952
|
className: "plc-flex plc-items-center plc-w-full plc-px-4 plc-py-2 plc-text-center plc-text-green-600 plc-border plc-border-green-400 plc-rounded plc-bg-green-50"
|
|
15128
14953
|
}, /*#__PURE__*/React__default.createElement(SvgLock, {
|
|
15129
14954
|
className: "plc-w-5 plc-h-5 plc-mr-1"
|