@pelcro/react-pelcro-js 3.1.0 → 3.2.0-beta.1
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 +199 -29
- package/dist/index.esm.js +199 -29
- 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,15 @@ 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
|
+
if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_pay_page_id) {
|
|
8691
|
+
return "vantiv";
|
|
8692
|
+
}
|
|
8693
|
+
|
|
8694
|
+
return "stripe";
|
|
8695
|
+
}
|
|
8686
8696
|
|
|
8687
8697
|
/**
|
|
8688
8698
|
* @typedef {Object} OptionsType
|
|
@@ -8763,13 +8773,26 @@ const loadPaymentSDKs = () => {
|
|
|
8763
8773
|
if (!window.Stripe) {
|
|
8764
8774
|
pure_1(window.Pelcro.environment.stripe);
|
|
8765
8775
|
}
|
|
8766
|
-
}); // Load PayPal
|
|
8776
|
+
}); // Load PayPal SDKs
|
|
8767
8777
|
|
|
8768
8778
|
const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
|
|
8769
8779
|
|
|
8770
8780
|
if (supportsPaypal) {
|
|
8771
8781
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/client.min.js", "braintree-sdk");
|
|
8772
8782
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
|
|
8783
|
+
} // Load Vantiv SDKs
|
|
8784
|
+
|
|
8785
|
+
|
|
8786
|
+
const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_pay_page_id);
|
|
8787
|
+
|
|
8788
|
+
if (supportsVantiv) {
|
|
8789
|
+
if (!window.jQuery) {
|
|
8790
|
+
window.Pelcro.helpers.loadSDK("https://code.jquery.com/jquery-3.6.0.slim.min.js", "vantiv-jquery-sdk");
|
|
8791
|
+
}
|
|
8792
|
+
|
|
8793
|
+
if (!window.EprotectIframeClient) {
|
|
8794
|
+
window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js", "vantiv-eprotect-sdk");
|
|
8795
|
+
}
|
|
8773
8796
|
}
|
|
8774
8797
|
};
|
|
8775
8798
|
const loadAuth0SDK = () => {
|
|
@@ -12708,7 +12731,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
|
|
|
12708
12731
|
class Subscription {
|
|
12709
12732
|
/**
|
|
12710
12733
|
* Subscription service constructor
|
|
12711
|
-
* @param {(StripeGateway|
|
|
12734
|
+
* @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
|
|
12712
12735
|
*/
|
|
12713
12736
|
constructor(paymentGateway) {
|
|
12714
12737
|
_defineProperty$3(this, "execute", (options, callback) => {
|
|
@@ -12729,7 +12752,7 @@ class Subscription {
|
|
|
12729
12752
|
_isPaymentGatewayInvalid.set(this, {
|
|
12730
12753
|
writable: true,
|
|
12731
12754
|
value: gateway => {
|
|
12732
|
-
return gateway && !(gateway instanceof StripeGateway
|
|
12755
|
+
return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway);
|
|
12733
12756
|
}
|
|
12734
12757
|
});
|
|
12735
12758
|
|
|
@@ -12782,7 +12805,8 @@ class Subscription {
|
|
|
12782
12805
|
}
|
|
12783
12806
|
const PAYMENT_GATEWAYS_ENUM = {
|
|
12784
12807
|
stripe: "stripe",
|
|
12785
|
-
paypal: "braintree"
|
|
12808
|
+
paypal: "braintree",
|
|
12809
|
+
vantiv: "vantiv"
|
|
12786
12810
|
};
|
|
12787
12811
|
/**
|
|
12788
12812
|
* Subscription Strategies
|
|
@@ -12974,7 +12998,7 @@ var _createGiftedSubscription2 = /*#__PURE__*/new WeakMap();
|
|
|
12974
12998
|
|
|
12975
12999
|
var _payInvoice2 = /*#__PURE__*/new WeakMap();
|
|
12976
13000
|
|
|
12977
|
-
class
|
|
13001
|
+
class PaypalGateway {
|
|
12978
13002
|
constructor() {
|
|
12979
13003
|
_paymentGateway2.set(this, {
|
|
12980
13004
|
writable: true,
|
|
@@ -13075,6 +13099,57 @@ class PaypalGateWay {
|
|
|
13075
13099
|
|
|
13076
13100
|
}
|
|
13077
13101
|
|
|
13102
|
+
var _paymentGateway3 = /*#__PURE__*/new WeakMap();
|
|
13103
|
+
|
|
13104
|
+
var _createSubscription3 = /*#__PURE__*/new WeakMap();
|
|
13105
|
+
|
|
13106
|
+
class VantivGateway {
|
|
13107
|
+
constructor() {
|
|
13108
|
+
_paymentGateway3.set(this, {
|
|
13109
|
+
writable: true,
|
|
13110
|
+
value: PAYMENT_GATEWAYS_ENUM["vantiv"]
|
|
13111
|
+
});
|
|
13112
|
+
|
|
13113
|
+
_defineProperty$3(this, "execute", (options, callback) => {
|
|
13114
|
+
const types = SUBSCRIPTION_TYPES;
|
|
13115
|
+
|
|
13116
|
+
switch (options.type) {
|
|
13117
|
+
case types.CREATE_SUBSCRIPTION:
|
|
13118
|
+
return _classPrivateFieldGet(this, _createSubscription3).call(this, options, callback);
|
|
13119
|
+
|
|
13120
|
+
default:
|
|
13121
|
+
console.error("Unsupported subscriptiion method: vantiv Gateway");
|
|
13122
|
+
}
|
|
13123
|
+
});
|
|
13124
|
+
|
|
13125
|
+
_createSubscription3.set(this, {
|
|
13126
|
+
writable: true,
|
|
13127
|
+
value: (options, callback) => {
|
|
13128
|
+
const {
|
|
13129
|
+
token,
|
|
13130
|
+
plan,
|
|
13131
|
+
couponCode,
|
|
13132
|
+
product,
|
|
13133
|
+
quantity = 1,
|
|
13134
|
+
addressId
|
|
13135
|
+
} = options;
|
|
13136
|
+
window.Pelcro.subscription.create({
|
|
13137
|
+
quantity,
|
|
13138
|
+
gateway_token: token,
|
|
13139
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
|
|
13140
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
13141
|
+
plan_id: plan.id,
|
|
13142
|
+
coupon_code: couponCode,
|
|
13143
|
+
address_id: product.address_required ? addressId : null
|
|
13144
|
+
}, (err, res) => {
|
|
13145
|
+
callback(err, res);
|
|
13146
|
+
});
|
|
13147
|
+
}
|
|
13148
|
+
});
|
|
13149
|
+
}
|
|
13150
|
+
|
|
13151
|
+
}
|
|
13152
|
+
|
|
13078
13153
|
/**
|
|
13079
13154
|
* @typedef {Object} PaymentStateType
|
|
13080
13155
|
* @property {boolean} disableSubmit
|
|
@@ -13162,6 +13237,78 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13162
13237
|
updateTotalAmountWithTax();
|
|
13163
13238
|
}, []);
|
|
13164
13239
|
|
|
13240
|
+
function submitVantivPayment() {
|
|
13241
|
+
if (!vantivInstanceRef.current) {
|
|
13242
|
+
return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
|
|
13243
|
+
}
|
|
13244
|
+
|
|
13245
|
+
const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
|
|
13246
|
+
|
|
13247
|
+
vantivInstanceRef.current.getPaypageRegistrationId({
|
|
13248
|
+
id: orderId,
|
|
13249
|
+
orderId: orderId
|
|
13250
|
+
});
|
|
13251
|
+
}
|
|
13252
|
+
|
|
13253
|
+
function handleVantivPayment(paymentRequest) {
|
|
13254
|
+
const SUCCESS_STATUS = "870";
|
|
13255
|
+
|
|
13256
|
+
if (paymentRequest.response !== SUCCESS_STATUS) {
|
|
13257
|
+
return handlePaymentError({
|
|
13258
|
+
error: new Error(paymentRequest.message)
|
|
13259
|
+
});
|
|
13260
|
+
}
|
|
13261
|
+
|
|
13262
|
+
const subscription = new Subscription(new VantivGateway());
|
|
13263
|
+
const {
|
|
13264
|
+
couponCode
|
|
13265
|
+
} = state;
|
|
13266
|
+
return subscription.execute({
|
|
13267
|
+
type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
|
|
13268
|
+
token: paymentRequest,
|
|
13269
|
+
quantity: plan.quantity,
|
|
13270
|
+
plan,
|
|
13271
|
+
couponCode,
|
|
13272
|
+
product,
|
|
13273
|
+
addressId: selectedAddressId
|
|
13274
|
+
}, (err, res) => {
|
|
13275
|
+
if (err) {
|
|
13276
|
+
return handlePaymentError(err);
|
|
13277
|
+
}
|
|
13278
|
+
|
|
13279
|
+
onSuccess(res);
|
|
13280
|
+
});
|
|
13281
|
+
}
|
|
13282
|
+
|
|
13283
|
+
const vantivInstanceRef = React__default['default'].useRef(null);
|
|
13284
|
+
React.useEffect(() => {
|
|
13285
|
+
const cardProcessor = getSiteCardProcessor();
|
|
13286
|
+
|
|
13287
|
+
if (cardProcessor === "vantiv") {
|
|
13288
|
+
var _window$Pelcro$site$r;
|
|
13289
|
+
|
|
13290
|
+
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;
|
|
13291
|
+
vantivInstanceRef.current = new window.EprotectIframeClient({
|
|
13292
|
+
paypageId: payPageId,
|
|
13293
|
+
reportGroup: payPageId,
|
|
13294
|
+
style: "pelcro",
|
|
13295
|
+
height: "245",
|
|
13296
|
+
timeout: 50000,
|
|
13297
|
+
div: "eProtectiframe",
|
|
13298
|
+
callback: handleVantivPayment,
|
|
13299
|
+
showCvv: true,
|
|
13300
|
+
numYears: 8,
|
|
13301
|
+
placeholderText: {
|
|
13302
|
+
cvv: "CVV",
|
|
13303
|
+
accountNumber: "1234 1234 1234 1234"
|
|
13304
|
+
},
|
|
13305
|
+
enhancedUxFeatures: {
|
|
13306
|
+
inlineFieldValidations: true
|
|
13307
|
+
}
|
|
13308
|
+
});
|
|
13309
|
+
}
|
|
13310
|
+
}, []);
|
|
13311
|
+
|
|
13165
13312
|
const initPaymentRequest = (state, dispatch) => {
|
|
13166
13313
|
try {
|
|
13167
13314
|
const paymentRequest = stripe.paymentRequest({
|
|
@@ -13232,9 +13379,9 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13232
13379
|
|
|
13233
13380
|
|
|
13234
13381
|
const updateTotalAmountWithTax = () => {
|
|
13235
|
-
var _window$Pelcro$site$
|
|
13382
|
+
var _window$Pelcro$site$r2;
|
|
13236
13383
|
|
|
13237
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
13384
|
+
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;
|
|
13238
13385
|
|
|
13239
13386
|
if (taxesEnabled && type === "createPayment") {
|
|
13240
13387
|
dispatch({
|
|
@@ -13584,7 +13731,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13584
13731
|
|
|
13585
13732
|
|
|
13586
13733
|
const handlePaypalSubscription = (state, paypalNonce) => {
|
|
13587
|
-
const subscription = new Subscription(new
|
|
13734
|
+
const subscription = new Subscription(new PaypalGateway());
|
|
13588
13735
|
const {
|
|
13589
13736
|
couponCode
|
|
13590
13737
|
} = state;
|
|
@@ -13879,13 +14026,13 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13879
14026
|
|
|
13880
14027
|
|
|
13881
14028
|
const resolveTaxCalculation = () => {
|
|
13882
|
-
var _window$Pelcro$site$
|
|
14029
|
+
var _window$Pelcro$site$r3;
|
|
13883
14030
|
|
|
13884
14031
|
if (type === "invoicePayment") {
|
|
13885
14032
|
return new Promise(resolve => resolve());
|
|
13886
14033
|
}
|
|
13887
14034
|
|
|
13888
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
14035
|
+
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;
|
|
13889
14036
|
return new Promise((resolve, reject) => {
|
|
13890
14037
|
// resolve early if taxes isn't enabled
|
|
13891
14038
|
if (!taxesEnabled) {
|
|
@@ -13964,6 +14111,8 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13964
14111
|
};
|
|
13965
14112
|
|
|
13966
14113
|
const handlePaymentError = error => {
|
|
14114
|
+
var _getErrorMessages;
|
|
14115
|
+
|
|
13967
14116
|
if (error.type === "validation_error" && // Subscription creation & renewal
|
|
13968
14117
|
type === "createPayment") {
|
|
13969
14118
|
var _state$couponObject;
|
|
@@ -13982,7 +14131,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13982
14131
|
type: SHOW_ALERT,
|
|
13983
14132
|
payload: {
|
|
13984
14133
|
type: "error",
|
|
13985
|
-
content: error === null || error === void 0 ? void 0 : error.message
|
|
14134
|
+
content: (_getErrorMessages = getErrorMessages(error)) !== null && _getErrorMessages !== void 0 ? _getErrorMessages : error === null || error === void 0 ? void 0 : error.message
|
|
13986
14135
|
}
|
|
13987
14136
|
});
|
|
13988
14137
|
dispatch({
|
|
@@ -14086,16 +14235,20 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14086
14235
|
}
|
|
14087
14236
|
|
|
14088
14237
|
if (type === "updatePaymentSource") {
|
|
14089
|
-
updatePaymentSource(state, dispatch);
|
|
14090
|
-
} else {
|
|
14091
|
-
submitPayment(state);
|
|
14238
|
+
return updatePaymentSource(state, dispatch);
|
|
14092
14239
|
}
|
|
14240
|
+
|
|
14241
|
+
if (getSiteCardProcessor() === "vantiv") {
|
|
14242
|
+
return submitVantivPayment();
|
|
14243
|
+
}
|
|
14244
|
+
|
|
14245
|
+
submitPayment(state);
|
|
14093
14246
|
});
|
|
14094
14247
|
|
|
14095
14248
|
case HANDLE_PAYPAL_SUBSCRIPTION:
|
|
14096
14249
|
return lib_5(state, (state, dispatch) => {
|
|
14097
14250
|
if (type === "invoicePayment") {
|
|
14098
|
-
payInvoice(new
|
|
14251
|
+
payInvoice(new PaypalGateway(), action.payload, dispatch);
|
|
14099
14252
|
} else {
|
|
14100
14253
|
handlePaypalSubscription(state, action.payload);
|
|
14101
14254
|
}
|
|
@@ -14278,19 +14431,35 @@ const CheckoutForm = () => {
|
|
|
14278
14431
|
const {
|
|
14279
14432
|
selectedPaymentMethodId
|
|
14280
14433
|
} = usePelcro();
|
|
14281
|
-
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
|
|
14286
|
-
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
}
|
|
14292
|
-
|
|
14293
|
-
|
|
14434
|
+
const cardProcessor = getSiteCardProcessor();
|
|
14435
|
+
|
|
14436
|
+
if (selectedPaymentMethodId) {
|
|
14437
|
+
return null;
|
|
14438
|
+
}
|
|
14439
|
+
|
|
14440
|
+
if (cardProcessor === "vantiv") {
|
|
14441
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14442
|
+
id: "eProtectiframe"
|
|
14443
|
+
});
|
|
14444
|
+
}
|
|
14445
|
+
|
|
14446
|
+
if (cardProcessor === "stripe") {
|
|
14447
|
+
return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(PelcroCardNumber, {
|
|
14448
|
+
autoFocus: true
|
|
14449
|
+
}), /*#__PURE__*/React__default['default'].createElement("img", {
|
|
14450
|
+
alt: "credit_cards",
|
|
14451
|
+
className: "plc-w-auto plc-h-4 plc-mt-2",
|
|
14452
|
+
src: "https://js.pelcro.com/ui/plugin/main/images/credit_cards.png"
|
|
14453
|
+
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14454
|
+
className: "plc-flex plc-items-end plc-justify-between plc-my-2"
|
|
14455
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14456
|
+
className: "plc-w-6/12 plc-pr-4"
|
|
14457
|
+
}, /*#__PURE__*/React__default['default'].createElement(PelcroCardExpiry, null)), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14458
|
+
className: "plc-w-6/12 plc-pl-4"
|
|
14459
|
+
}, /*#__PURE__*/React__default['default'].createElement(PelcroCardCVC, null))));
|
|
14460
|
+
}
|
|
14461
|
+
|
|
14462
|
+
return null;
|
|
14294
14463
|
};
|
|
14295
14464
|
|
|
14296
14465
|
const DiscountedPrice = props => {
|
|
@@ -14940,9 +15109,10 @@ function PaymentMethodView({
|
|
|
14940
15109
|
const {
|
|
14941
15110
|
t
|
|
14942
15111
|
} = useTranslation("checkoutForm");
|
|
15112
|
+
const cardProcessor = getSiteCardProcessor();
|
|
14943
15113
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14944
15114
|
className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
|
|
14945
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
15115
|
+
}, cardProcessor === "stripe" && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
14946
15116
|
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"
|
|
14947
15117
|
}, /*#__PURE__*/React__default['default'].createElement(SvgLock, {
|
|
14948
15118
|
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,15 @@ 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
|
+
if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_pay_page_id) {
|
|
8661
|
+
return "vantiv";
|
|
8662
|
+
}
|
|
8663
|
+
|
|
8664
|
+
return "stripe";
|
|
8665
|
+
}
|
|
8656
8666
|
|
|
8657
8667
|
/**
|
|
8658
8668
|
* @typedef {Object} OptionsType
|
|
@@ -8733,13 +8743,26 @@ const loadPaymentSDKs = () => {
|
|
|
8733
8743
|
if (!window.Stripe) {
|
|
8734
8744
|
pure_1(window.Pelcro.environment.stripe);
|
|
8735
8745
|
}
|
|
8736
|
-
}); // Load PayPal
|
|
8746
|
+
}); // Load PayPal SDKs
|
|
8737
8747
|
|
|
8738
8748
|
const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
|
|
8739
8749
|
|
|
8740
8750
|
if (supportsPaypal) {
|
|
8741
8751
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/client.min.js", "braintree-sdk");
|
|
8742
8752
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
|
|
8753
|
+
} // Load Vantiv SDKs
|
|
8754
|
+
|
|
8755
|
+
|
|
8756
|
+
const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_pay_page_id);
|
|
8757
|
+
|
|
8758
|
+
if (supportsVantiv) {
|
|
8759
|
+
if (!window.jQuery) {
|
|
8760
|
+
window.Pelcro.helpers.loadSDK("https://code.jquery.com/jquery-3.6.0.slim.min.js", "vantiv-jquery-sdk");
|
|
8761
|
+
}
|
|
8762
|
+
|
|
8763
|
+
if (!window.EprotectIframeClient) {
|
|
8764
|
+
window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js", "vantiv-eprotect-sdk");
|
|
8765
|
+
}
|
|
8743
8766
|
}
|
|
8744
8767
|
};
|
|
8745
8768
|
const loadAuth0SDK = () => {
|
|
@@ -12678,7 +12701,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
|
|
|
12678
12701
|
class Subscription {
|
|
12679
12702
|
/**
|
|
12680
12703
|
* Subscription service constructor
|
|
12681
|
-
* @param {(StripeGateway|
|
|
12704
|
+
* @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
|
|
12682
12705
|
*/
|
|
12683
12706
|
constructor(paymentGateway) {
|
|
12684
12707
|
_defineProperty$3(this, "execute", (options, callback) => {
|
|
@@ -12699,7 +12722,7 @@ class Subscription {
|
|
|
12699
12722
|
_isPaymentGatewayInvalid.set(this, {
|
|
12700
12723
|
writable: true,
|
|
12701
12724
|
value: gateway => {
|
|
12702
|
-
return gateway && !(gateway instanceof StripeGateway
|
|
12725
|
+
return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway);
|
|
12703
12726
|
}
|
|
12704
12727
|
});
|
|
12705
12728
|
|
|
@@ -12752,7 +12775,8 @@ class Subscription {
|
|
|
12752
12775
|
}
|
|
12753
12776
|
const PAYMENT_GATEWAYS_ENUM = {
|
|
12754
12777
|
stripe: "stripe",
|
|
12755
|
-
paypal: "braintree"
|
|
12778
|
+
paypal: "braintree",
|
|
12779
|
+
vantiv: "vantiv"
|
|
12756
12780
|
};
|
|
12757
12781
|
/**
|
|
12758
12782
|
* Subscription Strategies
|
|
@@ -12944,7 +12968,7 @@ var _createGiftedSubscription2 = /*#__PURE__*/new WeakMap();
|
|
|
12944
12968
|
|
|
12945
12969
|
var _payInvoice2 = /*#__PURE__*/new WeakMap();
|
|
12946
12970
|
|
|
12947
|
-
class
|
|
12971
|
+
class PaypalGateway {
|
|
12948
12972
|
constructor() {
|
|
12949
12973
|
_paymentGateway2.set(this, {
|
|
12950
12974
|
writable: true,
|
|
@@ -13045,6 +13069,57 @@ class PaypalGateWay {
|
|
|
13045
13069
|
|
|
13046
13070
|
}
|
|
13047
13071
|
|
|
13072
|
+
var _paymentGateway3 = /*#__PURE__*/new WeakMap();
|
|
13073
|
+
|
|
13074
|
+
var _createSubscription3 = /*#__PURE__*/new WeakMap();
|
|
13075
|
+
|
|
13076
|
+
class VantivGateway {
|
|
13077
|
+
constructor() {
|
|
13078
|
+
_paymentGateway3.set(this, {
|
|
13079
|
+
writable: true,
|
|
13080
|
+
value: PAYMENT_GATEWAYS_ENUM["vantiv"]
|
|
13081
|
+
});
|
|
13082
|
+
|
|
13083
|
+
_defineProperty$3(this, "execute", (options, callback) => {
|
|
13084
|
+
const types = SUBSCRIPTION_TYPES;
|
|
13085
|
+
|
|
13086
|
+
switch (options.type) {
|
|
13087
|
+
case types.CREATE_SUBSCRIPTION:
|
|
13088
|
+
return _classPrivateFieldGet(this, _createSubscription3).call(this, options, callback);
|
|
13089
|
+
|
|
13090
|
+
default:
|
|
13091
|
+
console.error("Unsupported subscriptiion method: vantiv Gateway");
|
|
13092
|
+
}
|
|
13093
|
+
});
|
|
13094
|
+
|
|
13095
|
+
_createSubscription3.set(this, {
|
|
13096
|
+
writable: true,
|
|
13097
|
+
value: (options, callback) => {
|
|
13098
|
+
const {
|
|
13099
|
+
token,
|
|
13100
|
+
plan,
|
|
13101
|
+
couponCode,
|
|
13102
|
+
product,
|
|
13103
|
+
quantity = 1,
|
|
13104
|
+
addressId
|
|
13105
|
+
} = options;
|
|
13106
|
+
window.Pelcro.subscription.create({
|
|
13107
|
+
quantity,
|
|
13108
|
+
gateway_token: token,
|
|
13109
|
+
payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
|
|
13110
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
13111
|
+
plan_id: plan.id,
|
|
13112
|
+
coupon_code: couponCode,
|
|
13113
|
+
address_id: product.address_required ? addressId : null
|
|
13114
|
+
}, (err, res) => {
|
|
13115
|
+
callback(err, res);
|
|
13116
|
+
});
|
|
13117
|
+
}
|
|
13118
|
+
});
|
|
13119
|
+
}
|
|
13120
|
+
|
|
13121
|
+
}
|
|
13122
|
+
|
|
13048
13123
|
/**
|
|
13049
13124
|
* @typedef {Object} PaymentStateType
|
|
13050
13125
|
* @property {boolean} disableSubmit
|
|
@@ -13132,6 +13207,78 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13132
13207
|
updateTotalAmountWithTax();
|
|
13133
13208
|
}, []);
|
|
13134
13209
|
|
|
13210
|
+
function submitVantivPayment() {
|
|
13211
|
+
if (!vantivInstanceRef.current) {
|
|
13212
|
+
return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
|
|
13213
|
+
}
|
|
13214
|
+
|
|
13215
|
+
const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
|
|
13216
|
+
|
|
13217
|
+
vantivInstanceRef.current.getPaypageRegistrationId({
|
|
13218
|
+
id: orderId,
|
|
13219
|
+
orderId: orderId
|
|
13220
|
+
});
|
|
13221
|
+
}
|
|
13222
|
+
|
|
13223
|
+
function handleVantivPayment(paymentRequest) {
|
|
13224
|
+
const SUCCESS_STATUS = "870";
|
|
13225
|
+
|
|
13226
|
+
if (paymentRequest.response !== SUCCESS_STATUS) {
|
|
13227
|
+
return handlePaymentError({
|
|
13228
|
+
error: new Error(paymentRequest.message)
|
|
13229
|
+
});
|
|
13230
|
+
}
|
|
13231
|
+
|
|
13232
|
+
const subscription = new Subscription(new VantivGateway());
|
|
13233
|
+
const {
|
|
13234
|
+
couponCode
|
|
13235
|
+
} = state;
|
|
13236
|
+
return subscription.execute({
|
|
13237
|
+
type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
|
|
13238
|
+
token: paymentRequest,
|
|
13239
|
+
quantity: plan.quantity,
|
|
13240
|
+
plan,
|
|
13241
|
+
couponCode,
|
|
13242
|
+
product,
|
|
13243
|
+
addressId: selectedAddressId
|
|
13244
|
+
}, (err, res) => {
|
|
13245
|
+
if (err) {
|
|
13246
|
+
return handlePaymentError(err);
|
|
13247
|
+
}
|
|
13248
|
+
|
|
13249
|
+
onSuccess(res);
|
|
13250
|
+
});
|
|
13251
|
+
}
|
|
13252
|
+
|
|
13253
|
+
const vantivInstanceRef = React__default.useRef(null);
|
|
13254
|
+
useEffect(() => {
|
|
13255
|
+
const cardProcessor = getSiteCardProcessor();
|
|
13256
|
+
|
|
13257
|
+
if (cardProcessor === "vantiv") {
|
|
13258
|
+
var _window$Pelcro$site$r;
|
|
13259
|
+
|
|
13260
|
+
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;
|
|
13261
|
+
vantivInstanceRef.current = new window.EprotectIframeClient({
|
|
13262
|
+
paypageId: payPageId,
|
|
13263
|
+
reportGroup: payPageId,
|
|
13264
|
+
style: "pelcro",
|
|
13265
|
+
height: "245",
|
|
13266
|
+
timeout: 50000,
|
|
13267
|
+
div: "eProtectiframe",
|
|
13268
|
+
callback: handleVantivPayment,
|
|
13269
|
+
showCvv: true,
|
|
13270
|
+
numYears: 8,
|
|
13271
|
+
placeholderText: {
|
|
13272
|
+
cvv: "CVV",
|
|
13273
|
+
accountNumber: "1234 1234 1234 1234"
|
|
13274
|
+
},
|
|
13275
|
+
enhancedUxFeatures: {
|
|
13276
|
+
inlineFieldValidations: true
|
|
13277
|
+
}
|
|
13278
|
+
});
|
|
13279
|
+
}
|
|
13280
|
+
}, []);
|
|
13281
|
+
|
|
13135
13282
|
const initPaymentRequest = (state, dispatch) => {
|
|
13136
13283
|
try {
|
|
13137
13284
|
const paymentRequest = stripe.paymentRequest({
|
|
@@ -13202,9 +13349,9 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13202
13349
|
|
|
13203
13350
|
|
|
13204
13351
|
const updateTotalAmountWithTax = () => {
|
|
13205
|
-
var _window$Pelcro$site$
|
|
13352
|
+
var _window$Pelcro$site$r2;
|
|
13206
13353
|
|
|
13207
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
13354
|
+
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;
|
|
13208
13355
|
|
|
13209
13356
|
if (taxesEnabled && type === "createPayment") {
|
|
13210
13357
|
dispatch({
|
|
@@ -13554,7 +13701,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13554
13701
|
|
|
13555
13702
|
|
|
13556
13703
|
const handlePaypalSubscription = (state, paypalNonce) => {
|
|
13557
|
-
const subscription = new Subscription(new
|
|
13704
|
+
const subscription = new Subscription(new PaypalGateway());
|
|
13558
13705
|
const {
|
|
13559
13706
|
couponCode
|
|
13560
13707
|
} = state;
|
|
@@ -13849,13 +13996,13 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13849
13996
|
|
|
13850
13997
|
|
|
13851
13998
|
const resolveTaxCalculation = () => {
|
|
13852
|
-
var _window$Pelcro$site$
|
|
13999
|
+
var _window$Pelcro$site$r3;
|
|
13853
14000
|
|
|
13854
14001
|
if (type === "invoicePayment") {
|
|
13855
14002
|
return new Promise(resolve => resolve());
|
|
13856
14003
|
}
|
|
13857
14004
|
|
|
13858
|
-
const taxesEnabled = (_window$Pelcro$site$
|
|
14005
|
+
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;
|
|
13859
14006
|
return new Promise((resolve, reject) => {
|
|
13860
14007
|
// resolve early if taxes isn't enabled
|
|
13861
14008
|
if (!taxesEnabled) {
|
|
@@ -13934,6 +14081,8 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13934
14081
|
};
|
|
13935
14082
|
|
|
13936
14083
|
const handlePaymentError = error => {
|
|
14084
|
+
var _getErrorMessages;
|
|
14085
|
+
|
|
13937
14086
|
if (error.type === "validation_error" && // Subscription creation & renewal
|
|
13938
14087
|
type === "createPayment") {
|
|
13939
14088
|
var _state$couponObject;
|
|
@@ -13952,7 +14101,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
13952
14101
|
type: SHOW_ALERT,
|
|
13953
14102
|
payload: {
|
|
13954
14103
|
type: "error",
|
|
13955
|
-
content: error === null || error === void 0 ? void 0 : error.message
|
|
14104
|
+
content: (_getErrorMessages = getErrorMessages(error)) !== null && _getErrorMessages !== void 0 ? _getErrorMessages : error === null || error === void 0 ? void 0 : error.message
|
|
13956
14105
|
}
|
|
13957
14106
|
});
|
|
13958
14107
|
dispatch({
|
|
@@ -14056,16 +14205,20 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
14056
14205
|
}
|
|
14057
14206
|
|
|
14058
14207
|
if (type === "updatePaymentSource") {
|
|
14059
|
-
updatePaymentSource(state, dispatch);
|
|
14060
|
-
} else {
|
|
14061
|
-
submitPayment(state);
|
|
14208
|
+
return updatePaymentSource(state, dispatch);
|
|
14062
14209
|
}
|
|
14210
|
+
|
|
14211
|
+
if (getSiteCardProcessor() === "vantiv") {
|
|
14212
|
+
return submitVantivPayment();
|
|
14213
|
+
}
|
|
14214
|
+
|
|
14215
|
+
submitPayment(state);
|
|
14063
14216
|
});
|
|
14064
14217
|
|
|
14065
14218
|
case HANDLE_PAYPAL_SUBSCRIPTION:
|
|
14066
14219
|
return lib_5(state, (state, dispatch) => {
|
|
14067
14220
|
if (type === "invoicePayment") {
|
|
14068
|
-
payInvoice(new
|
|
14221
|
+
payInvoice(new PaypalGateway(), action.payload, dispatch);
|
|
14069
14222
|
} else {
|
|
14070
14223
|
handlePaypalSubscription(state, action.payload);
|
|
14071
14224
|
}
|
|
@@ -14248,19 +14401,35 @@ const CheckoutForm = () => {
|
|
|
14248
14401
|
const {
|
|
14249
14402
|
selectedPaymentMethodId
|
|
14250
14403
|
} = usePelcro();
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14256
|
-
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
|
|
14260
|
-
|
|
14261
|
-
}
|
|
14262
|
-
|
|
14263
|
-
|
|
14404
|
+
const cardProcessor = getSiteCardProcessor();
|
|
14405
|
+
|
|
14406
|
+
if (selectedPaymentMethodId) {
|
|
14407
|
+
return null;
|
|
14408
|
+
}
|
|
14409
|
+
|
|
14410
|
+
if (cardProcessor === "vantiv") {
|
|
14411
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
14412
|
+
id: "eProtectiframe"
|
|
14413
|
+
});
|
|
14414
|
+
}
|
|
14415
|
+
|
|
14416
|
+
if (cardProcessor === "stripe") {
|
|
14417
|
+
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(PelcroCardNumber, {
|
|
14418
|
+
autoFocus: true
|
|
14419
|
+
}), /*#__PURE__*/React__default.createElement("img", {
|
|
14420
|
+
alt: "credit_cards",
|
|
14421
|
+
className: "plc-w-auto plc-h-4 plc-mt-2",
|
|
14422
|
+
src: "https://js.pelcro.com/ui/plugin/main/images/credit_cards.png"
|
|
14423
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
14424
|
+
className: "plc-flex plc-items-end plc-justify-between plc-my-2"
|
|
14425
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
14426
|
+
className: "plc-w-6/12 plc-pr-4"
|
|
14427
|
+
}, /*#__PURE__*/React__default.createElement(PelcroCardExpiry, null)), /*#__PURE__*/React__default.createElement("div", {
|
|
14428
|
+
className: "plc-w-6/12 plc-pl-4"
|
|
14429
|
+
}, /*#__PURE__*/React__default.createElement(PelcroCardCVC, null))));
|
|
14430
|
+
}
|
|
14431
|
+
|
|
14432
|
+
return null;
|
|
14264
14433
|
};
|
|
14265
14434
|
|
|
14266
14435
|
const DiscountedPrice = props => {
|
|
@@ -14910,9 +15079,10 @@ function PaymentMethodView({
|
|
|
14910
15079
|
const {
|
|
14911
15080
|
t
|
|
14912
15081
|
} = useTranslation("checkoutForm");
|
|
15082
|
+
const cardProcessor = getSiteCardProcessor();
|
|
14913
15083
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
14914
15084
|
className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
|
|
14915
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
15085
|
+
}, cardProcessor === "stripe" && /*#__PURE__*/React__default.createElement("div", {
|
|
14916
15086
|
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"
|
|
14917
15087
|
}, /*#__PURE__*/React__default.createElement(SvgLock, {
|
|
14918
15088
|
className: "plc-w-5 plc-h-5 plc-mr-1"
|