@pelcro/react-pelcro-js 3.1.0-beta.4 → 3.1.0-beta.5
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 +203 -28
- package/dist/index.esm.js +203 -28
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -8629,6 +8629,7 @@ var pure_1 = pure.loadStripe;
|
|
|
8629
8629
|
* @param {Object} error Error object
|
|
8630
8630
|
* @return {string}
|
|
8631
8631
|
*/
|
|
8632
|
+
|
|
8632
8633
|
const getErrorMessages = error => {
|
|
8633
8634
|
var _error$error, _error$response, _error$response$data, _error$response3, _error$response3$data, _error$response3$data2, _error$response5, _error$response5$data;
|
|
8634
8635
|
|
|
@@ -8683,6 +8684,20 @@ const debounce = (func, waitTime) => {
|
|
|
8683
8684
|
timeout = setTimeout(later, waitTime);
|
|
8684
8685
|
};
|
|
8685
8686
|
};
|
|
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
|
+
}
|
|
8686
8701
|
|
|
8687
8702
|
/**
|
|
8688
8703
|
* @typedef {Object} OptionsType
|
|
@@ -8763,13 +8778,26 @@ const loadPaymentSDKs = () => {
|
|
|
8763
8778
|
if (!window.Stripe) {
|
|
8764
8779
|
pure_1(window.Pelcro.environment.stripe);
|
|
8765
8780
|
}
|
|
8766
|
-
}); // Load PayPal
|
|
8781
|
+
}); // Load PayPal SDKs
|
|
8767
8782
|
|
|
8768
8783
|
const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
|
|
8769
8784
|
|
|
8770
8785
|
if (supportsPaypal) {
|
|
8771
8786
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/client.min.js", "braintree-sdk");
|
|
8772
8787
|
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
|
+
}
|
|
8773
8801
|
}
|
|
8774
8802
|
};
|
|
8775
8803
|
const loadAuth0SDK = () => {
|
|
@@ -12744,7 +12772,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
|
|
|
12744
12772
|
class Subscription {
|
|
12745
12773
|
/**
|
|
12746
12774
|
* Subscription service constructor
|
|
12747
|
-
* @param {(StripeGateway|
|
|
12775
|
+
* @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
|
|
12748
12776
|
*/
|
|
12749
12777
|
constructor(paymentGateway) {
|
|
12750
12778
|
_defineProperty$3(this, "execute", (options, callback) => {
|
|
@@ -12765,7 +12793,7 @@ class Subscription {
|
|
|
12765
12793
|
_isPaymentGatewayInvalid.set(this, {
|
|
12766
12794
|
writable: true,
|
|
12767
12795
|
value: gateway => {
|
|
12768
|
-
return gateway && !(gateway instanceof StripeGateway
|
|
12796
|
+
return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway);
|
|
12769
12797
|
}
|
|
12770
12798
|
});
|
|
12771
12799
|
|
|
@@ -12818,7 +12846,8 @@ class Subscription {
|
|
|
12818
12846
|
}
|
|
12819
12847
|
const PAYMENT_GATEWAYS_ENUM = {
|
|
12820
12848
|
stripe: "stripe",
|
|
12821
|
-
paypal: "braintree"
|
|
12849
|
+
paypal: "braintree",
|
|
12850
|
+
vantiv: "vantiv"
|
|
12822
12851
|
};
|
|
12823
12852
|
/**
|
|
12824
12853
|
* Subscription Strategies
|
|
@@ -13010,7 +13039,7 @@ var _createGiftedSubscription2 = /*#__PURE__*/new WeakMap();
|
|
|
13010
13039
|
|
|
13011
13040
|
var _payInvoice2 = /*#__PURE__*/new WeakMap();
|
|
13012
13041
|
|
|
13013
|
-
class
|
|
13042
|
+
class PaypalGateway {
|
|
13014
13043
|
constructor() {
|
|
13015
13044
|
_paymentGateway2.set(this, {
|
|
13016
13045
|
writable: true,
|
|
@@ -13111,6 +13140,57 @@ class PaypalGateWay {
|
|
|
13111
13140
|
|
|
13112
13141
|
}
|
|
13113
13142
|
|
|
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
|
+
|
|
13114
13194
|
/**
|
|
13115
13195
|
* @typedef {Object} PaymentStateType
|
|
13116
13196
|
* @property {boolean} disableSubmit
|
|
@@ -13198,6 +13278,78 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13198
13278
|
updateTotalAmountWithTax();
|
|
13199
13279
|
}, []);
|
|
13200
13280
|
|
|
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
|
+
|
|
13201
13353
|
const initPaymentRequest = (state, dispatch) => {
|
|
13202
13354
|
try {
|
|
13203
13355
|
const paymentRequest = stripe.paymentRequest({
|
|
@@ -13268,9 +13420,9 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13268
13420
|
|
|
13269
13421
|
|
|
13270
13422
|
const updateTotalAmountWithTax = () => {
|
|
13271
|
-
var _window$Pelcro$site$
|
|
13423
|
+
var _window$Pelcro$site$r2;
|
|
13272
13424
|
|
|
13273
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
13425
|
+
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;
|
|
13274
13426
|
|
|
13275
13427
|
if (taxesEnabled && type === "createPayment") {
|
|
13276
13428
|
dispatch({
|
|
@@ -13620,7 +13772,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13620
13772
|
|
|
13621
13773
|
|
|
13622
13774
|
const handlePaypalSubscription = (state, paypalNonce) => {
|
|
13623
|
-
const subscription = new Subscription(new
|
|
13775
|
+
const subscription = new Subscription(new PaypalGateway());
|
|
13624
13776
|
const {
|
|
13625
13777
|
couponCode
|
|
13626
13778
|
} = state;
|
|
@@ -13915,13 +14067,13 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13915
14067
|
|
|
13916
14068
|
|
|
13917
14069
|
const resolveTaxCalculation = () => {
|
|
13918
|
-
var _window$Pelcro$site$
|
|
14070
|
+
var _window$Pelcro$site$r3;
|
|
13919
14071
|
|
|
13920
14072
|
if (type === "invoicePayment") {
|
|
13921
14073
|
return new Promise(resolve => resolve());
|
|
13922
14074
|
}
|
|
13923
14075
|
|
|
13924
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
14076
|
+
const taxesEnabled = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.taxes_enabled;
|
|
13925
14077
|
return new Promise((resolve, reject) => {
|
|
13926
14078
|
// resolve early if taxes isn't enabled
|
|
13927
14079
|
if (!taxesEnabled) {
|
|
@@ -14000,6 +14152,8 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14000
14152
|
};
|
|
14001
14153
|
|
|
14002
14154
|
const handlePaymentError = error => {
|
|
14155
|
+
var _getErrorMessages;
|
|
14156
|
+
|
|
14003
14157
|
if (error.type === "validation_error" && // Subscription creation & renewal
|
|
14004
14158
|
type === "createPayment") {
|
|
14005
14159
|
var _state$couponObject;
|
|
@@ -14018,7 +14172,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14018
14172
|
type: SHOW_ALERT,
|
|
14019
14173
|
payload: {
|
|
14020
14174
|
type: "error",
|
|
14021
|
-
content: error === null || error === void 0 ? void 0 : error.message
|
|
14175
|
+
content: (_getErrorMessages = getErrorMessages(error)) !== null && _getErrorMessages !== void 0 ? _getErrorMessages : error === null || error === void 0 ? void 0 : error.message
|
|
14022
14176
|
}
|
|
14023
14177
|
});
|
|
14024
14178
|
dispatch({
|
|
@@ -14122,10 +14276,14 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14122
14276
|
}
|
|
14123
14277
|
|
|
14124
14278
|
if (type === "updatePaymentSource") {
|
|
14125
|
-
updatePaymentSource(state, dispatch);
|
|
14126
|
-
}
|
|
14127
|
-
|
|
14279
|
+
return updatePaymentSource(state, dispatch);
|
|
14280
|
+
}
|
|
14281
|
+
|
|
14282
|
+
if (getSiteCardProcessor() === "vantiv") {
|
|
14283
|
+
return submitVantivPayment();
|
|
14128
14284
|
}
|
|
14285
|
+
|
|
14286
|
+
submitPayment(state);
|
|
14129
14287
|
});
|
|
14130
14288
|
|
|
14131
14289
|
case HANDLE_PAYPAL_SUBSCRIPTION:
|
|
@@ -14314,19 +14472,35 @@ const CheckoutForm = () => {
|
|
|
14314
14472
|
const {
|
|
14315
14473
|
selectedPaymentMethodId
|
|
14316
14474
|
} = usePelcro();
|
|
14317
|
-
|
|
14318
|
-
|
|
14319
|
-
|
|
14320
|
-
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14327
|
-
}
|
|
14328
|
-
|
|
14329
|
-
|
|
14475
|
+
const cardProcessor = getSiteCardProcessor();
|
|
14476
|
+
|
|
14477
|
+
if (selectedPaymentMethodId) {
|
|
14478
|
+
return null;
|
|
14479
|
+
}
|
|
14480
|
+
|
|
14481
|
+
if (cardProcessor === "vantiv") {
|
|
14482
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14483
|
+
id: "eProtectiframe"
|
|
14484
|
+
});
|
|
14485
|
+
}
|
|
14486
|
+
|
|
14487
|
+
if (cardProcessor === "stripe") {
|
|
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;
|
|
14330
14504
|
};
|
|
14331
14505
|
|
|
14332
14506
|
const DiscountedPrice = props => {
|
|
@@ -14976,9 +15150,10 @@ function PaymentMethodView({
|
|
|
14976
15150
|
const {
|
|
14977
15151
|
t
|
|
14978
15152
|
} = useTranslation("checkoutForm");
|
|
15153
|
+
const cardProcessor = getSiteCardProcessor();
|
|
14979
15154
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14980
15155
|
className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
|
|
14981
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
15156
|
+
}, cardProcessor === "stripe" && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14982
15157
|
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"
|
|
14983
15158
|
}, /*#__PURE__*/React__default['default'].createElement(SvgLock, {
|
|
14984
15159
|
className: "plc-w-5 plc-h-5 plc-mr-1"
|
package/dist/index.esm.js
CHANGED
|
@@ -8599,6 +8599,7 @@ var pure_1 = pure.loadStripe;
|
|
|
8599
8599
|
* @param {Object} error Error object
|
|
8600
8600
|
* @return {string}
|
|
8601
8601
|
*/
|
|
8602
|
+
|
|
8602
8603
|
const getErrorMessages = error => {
|
|
8603
8604
|
var _error$error, _error$response, _error$response$data, _error$response3, _error$response3$data, _error$response3$data2, _error$response5, _error$response5$data;
|
|
8604
8605
|
|
|
@@ -8653,6 +8654,20 @@ const debounce = (func, waitTime) => {
|
|
|
8653
8654
|
timeout = setTimeout(later, waitTime);
|
|
8654
8655
|
};
|
|
8655
8656
|
};
|
|
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
|
+
}
|
|
8656
8671
|
|
|
8657
8672
|
/**
|
|
8658
8673
|
* @typedef {Object} OptionsType
|
|
@@ -8733,13 +8748,26 @@ const loadPaymentSDKs = () => {
|
|
|
8733
8748
|
if (!window.Stripe) {
|
|
8734
8749
|
pure_1(window.Pelcro.environment.stripe);
|
|
8735
8750
|
}
|
|
8736
|
-
}); // Load PayPal
|
|
8751
|
+
}); // Load PayPal SDKs
|
|
8737
8752
|
|
|
8738
8753
|
const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
|
|
8739
8754
|
|
|
8740
8755
|
if (supportsPaypal) {
|
|
8741
8756
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/client.min.js", "braintree-sdk");
|
|
8742
8757
|
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
|
+
}
|
|
8743
8771
|
}
|
|
8744
8772
|
};
|
|
8745
8773
|
const loadAuth0SDK = () => {
|
|
@@ -12714,7 +12742,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
|
|
|
12714
12742
|
class Subscription {
|
|
12715
12743
|
/**
|
|
12716
12744
|
* Subscription service constructor
|
|
12717
|
-
* @param {(StripeGateway|
|
|
12745
|
+
* @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
|
|
12718
12746
|
*/
|
|
12719
12747
|
constructor(paymentGateway) {
|
|
12720
12748
|
_defineProperty$3(this, "execute", (options, callback) => {
|
|
@@ -12735,7 +12763,7 @@ class Subscription {
|
|
|
12735
12763
|
_isPaymentGatewayInvalid.set(this, {
|
|
12736
12764
|
writable: true,
|
|
12737
12765
|
value: gateway => {
|
|
12738
|
-
return gateway && !(gateway instanceof StripeGateway
|
|
12766
|
+
return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway);
|
|
12739
12767
|
}
|
|
12740
12768
|
});
|
|
12741
12769
|
|
|
@@ -12788,7 +12816,8 @@ class Subscription {
|
|
|
12788
12816
|
}
|
|
12789
12817
|
const PAYMENT_GATEWAYS_ENUM = {
|
|
12790
12818
|
stripe: "stripe",
|
|
12791
|
-
paypal: "braintree"
|
|
12819
|
+
paypal: "braintree",
|
|
12820
|
+
vantiv: "vantiv"
|
|
12792
12821
|
};
|
|
12793
12822
|
/**
|
|
12794
12823
|
* Subscription Strategies
|
|
@@ -12980,7 +13009,7 @@ var _createGiftedSubscription2 = /*#__PURE__*/new WeakMap();
|
|
|
12980
13009
|
|
|
12981
13010
|
var _payInvoice2 = /*#__PURE__*/new WeakMap();
|
|
12982
13011
|
|
|
12983
|
-
class
|
|
13012
|
+
class PaypalGateway {
|
|
12984
13013
|
constructor() {
|
|
12985
13014
|
_paymentGateway2.set(this, {
|
|
12986
13015
|
writable: true,
|
|
@@ -13081,6 +13110,57 @@ class PaypalGateWay {
|
|
|
13081
13110
|
|
|
13082
13111
|
}
|
|
13083
13112
|
|
|
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
|
+
|
|
13084
13164
|
/**
|
|
13085
13165
|
* @typedef {Object} PaymentStateType
|
|
13086
13166
|
* @property {boolean} disableSubmit
|
|
@@ -13168,6 +13248,78 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13168
13248
|
updateTotalAmountWithTax();
|
|
13169
13249
|
}, []);
|
|
13170
13250
|
|
|
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
|
+
|
|
13171
13323
|
const initPaymentRequest = (state, dispatch) => {
|
|
13172
13324
|
try {
|
|
13173
13325
|
const paymentRequest = stripe.paymentRequest({
|
|
@@ -13238,9 +13390,9 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13238
13390
|
|
|
13239
13391
|
|
|
13240
13392
|
const updateTotalAmountWithTax = () => {
|
|
13241
|
-
var _window$Pelcro$site$
|
|
13393
|
+
var _window$Pelcro$site$r2;
|
|
13242
13394
|
|
|
13243
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
13395
|
+
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;
|
|
13244
13396
|
|
|
13245
13397
|
if (taxesEnabled && type === "createPayment") {
|
|
13246
13398
|
dispatch({
|
|
@@ -13590,7 +13742,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13590
13742
|
|
|
13591
13743
|
|
|
13592
13744
|
const handlePaypalSubscription = (state, paypalNonce) => {
|
|
13593
|
-
const subscription = new Subscription(new
|
|
13745
|
+
const subscription = new Subscription(new PaypalGateway());
|
|
13594
13746
|
const {
|
|
13595
13747
|
couponCode
|
|
13596
13748
|
} = state;
|
|
@@ -13885,13 +14037,13 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13885
14037
|
|
|
13886
14038
|
|
|
13887
14039
|
const resolveTaxCalculation = () => {
|
|
13888
|
-
var _window$Pelcro$site$
|
|
14040
|
+
var _window$Pelcro$site$r3;
|
|
13889
14041
|
|
|
13890
14042
|
if (type === "invoicePayment") {
|
|
13891
14043
|
return new Promise(resolve => resolve());
|
|
13892
14044
|
}
|
|
13893
14045
|
|
|
13894
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
14046
|
+
const taxesEnabled = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.taxes_enabled;
|
|
13895
14047
|
return new Promise((resolve, reject) => {
|
|
13896
14048
|
// resolve early if taxes isn't enabled
|
|
13897
14049
|
if (!taxesEnabled) {
|
|
@@ -13970,6 +14122,8 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13970
14122
|
};
|
|
13971
14123
|
|
|
13972
14124
|
const handlePaymentError = error => {
|
|
14125
|
+
var _getErrorMessages;
|
|
14126
|
+
|
|
13973
14127
|
if (error.type === "validation_error" && // Subscription creation & renewal
|
|
13974
14128
|
type === "createPayment") {
|
|
13975
14129
|
var _state$couponObject;
|
|
@@ -13988,7 +14142,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13988
14142
|
type: SHOW_ALERT,
|
|
13989
14143
|
payload: {
|
|
13990
14144
|
type: "error",
|
|
13991
|
-
content: error === null || error === void 0 ? void 0 : error.message
|
|
14145
|
+
content: (_getErrorMessages = getErrorMessages(error)) !== null && _getErrorMessages !== void 0 ? _getErrorMessages : error === null || error === void 0 ? void 0 : error.message
|
|
13992
14146
|
}
|
|
13993
14147
|
});
|
|
13994
14148
|
dispatch({
|
|
@@ -14092,10 +14246,14 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14092
14246
|
}
|
|
14093
14247
|
|
|
14094
14248
|
if (type === "updatePaymentSource") {
|
|
14095
|
-
updatePaymentSource(state, dispatch);
|
|
14096
|
-
}
|
|
14097
|
-
|
|
14249
|
+
return updatePaymentSource(state, dispatch);
|
|
14250
|
+
}
|
|
14251
|
+
|
|
14252
|
+
if (getSiteCardProcessor() === "vantiv") {
|
|
14253
|
+
return submitVantivPayment();
|
|
14098
14254
|
}
|
|
14255
|
+
|
|
14256
|
+
submitPayment(state);
|
|
14099
14257
|
});
|
|
14100
14258
|
|
|
14101
14259
|
case HANDLE_PAYPAL_SUBSCRIPTION:
|
|
@@ -14284,19 +14442,35 @@ const CheckoutForm = () => {
|
|
|
14284
14442
|
const {
|
|
14285
14443
|
selectedPaymentMethodId
|
|
14286
14444
|
} = usePelcro();
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
}
|
|
14298
|
-
|
|
14299
|
-
|
|
14445
|
+
const cardProcessor = getSiteCardProcessor();
|
|
14446
|
+
|
|
14447
|
+
if (selectedPaymentMethodId) {
|
|
14448
|
+
return null;
|
|
14449
|
+
}
|
|
14450
|
+
|
|
14451
|
+
if (cardProcessor === "vantiv") {
|
|
14452
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
14453
|
+
id: "eProtectiframe"
|
|
14454
|
+
});
|
|
14455
|
+
}
|
|
14456
|
+
|
|
14457
|
+
if (cardProcessor === "stripe") {
|
|
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;
|
|
14300
14474
|
};
|
|
14301
14475
|
|
|
14302
14476
|
const DiscountedPrice = props => {
|
|
@@ -14946,9 +15120,10 @@ function PaymentMethodView({
|
|
|
14946
15120
|
const {
|
|
14947
15121
|
t
|
|
14948
15122
|
} = useTranslation("checkoutForm");
|
|
15123
|
+
const cardProcessor = getSiteCardProcessor();
|
|
14949
15124
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
14950
15125
|
className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
|
|
14951
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
15126
|
+
}, cardProcessor === "stripe" && /*#__PURE__*/React__default.createElement("div", {
|
|
14952
15127
|
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"
|
|
14953
15128
|
}, /*#__PURE__*/React__default.createElement(SvgLock, {
|
|
14954
15129
|
className: "plc-w-5 plc-h-5 plc-mr-1"
|