@pelcro/react-pelcro-js 3.22.0-beta.19 → 3.22.0-beta.20

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 CHANGED
@@ -11160,13 +11160,16 @@ const debounce = (func, waitTime) => {
11160
11160
  };
11161
11161
  };
11162
11162
  function getSiteCardProcessor() {
11163
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
11163
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3;
11164
11164
  if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
11165
11165
  return "vantiv";
11166
11166
  }
11167
11167
  if ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r2 !== void 0 && _window$Pelcro$site$r2.tap_gateway_settings) {
11168
11168
  return "tap";
11169
11169
  }
11170
+ if ((_window$Pelcro$site$r3 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r3 !== void 0 && _window$Pelcro$site$r3.cybersource_gateway_settings) {
11171
+ return "cybersource";
11172
+ }
11170
11173
  return "stripe";
11171
11174
  }
11172
11175
 
@@ -12091,6 +12094,8 @@ const SET_FIRST_NAME_ERROR = "SET_FIRST_NAME_ERROR";
12091
12094
  const SET_LAST_NAME_ERROR = "SET_LAST_NAME_ERROR";
12092
12095
  const SET_PHONE_ERROR = "SET_PHONE_ERROR";
12093
12096
  const SET_TEXT_FIELD = "SET_TEXT_FIELD";
12097
+ const SET_MONTH = "SET_MONTH";
12098
+ const SET_YEAR = "SET_YEAR";
12094
12099
  const SET_TOKEN = "SET_TOKEN";
12095
12100
  const SET_GIFT_CODE = "SET_GIFT_CODE";
12096
12101
  const RESET_LOGIN_FORM = "RESET_LOGIN_FORM";
@@ -16291,7 +16296,7 @@ var _isPaymentGatewayInvalid = /*#__PURE__*/new WeakMap();
16291
16296
  var _generateUserError = /*#__PURE__*/new WeakMap();
16292
16297
  class Payment {
16293
16298
  /**
16294
- * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway)} paymentGateway
16299
+ * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway|CybersourceGateway)} paymentGateway
16295
16300
  */
16296
16301
  constructor(paymentGateway) {
16297
16302
  _defineProperty$3(this, "execute", (options, callback) => {
@@ -16310,7 +16315,7 @@ class Payment {
16310
16315
  _classPrivateFieldInitSpec$1(this, _isPaymentGatewayInvalid, {
16311
16316
  writable: true,
16312
16317
  value: gateway => {
16313
- return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway);
16318
+ return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway || gateway instanceof CybersourceGateway);
16314
16319
  }
16315
16320
  });
16316
16321
  _classPrivateFieldInitSpec$1(this, _generateUserError, {
@@ -16364,7 +16369,8 @@ const PAYMENT_GATEWAYS_ENUM = {
16364
16369
  stripe: "stripe",
16365
16370
  paypal: "braintree",
16366
16371
  vantiv: "vantiv",
16367
- tap: "tap"
16372
+ tap: "tap",
16373
+ cybersource: "cybersource"
16368
16374
  };
16369
16375
 
16370
16376
  /**
@@ -17086,6 +17092,222 @@ class TapGateway {
17086
17092
  }
17087
17093
  }
17088
17094
 
17095
+ /**
17096
+ * Cybersource gateway strategy
17097
+ */
17098
+ var _paymentGateway5 = /*#__PURE__*/new WeakMap();
17099
+ var _createSubscription5 = /*#__PURE__*/new WeakMap();
17100
+ var _renewSubscription4 = /*#__PURE__*/new WeakMap();
17101
+ var _createGiftedSubscription5 = /*#__PURE__*/new WeakMap();
17102
+ var _renewGiftedSubscription4 = /*#__PURE__*/new WeakMap();
17103
+ var _purchaseEcommerceOrder4 = /*#__PURE__*/new WeakMap();
17104
+ var _payInvoice5 = /*#__PURE__*/new WeakMap();
17105
+ class CybersourceGateway {
17106
+ constructor() {
17107
+ _classPrivateFieldInitSpec$1(this, _paymentGateway5, {
17108
+ writable: true,
17109
+ value: PAYMENT_GATEWAYS_ENUM["cybersource"]
17110
+ });
17111
+ _defineProperty$3(this, "execute", (options, callback) => {
17112
+ const types = PAYMENT_TYPES;
17113
+ switch (options.type) {
17114
+ case types.CREATE_SUBSCRIPTION:
17115
+ return _classPrivateFieldGet(this, _createSubscription5).call(this, options, callback);
17116
+ case types.RENEW_SUBSCRIPTION:
17117
+ return _classPrivateFieldGet(this, _renewSubscription4).call(this, options, callback);
17118
+ case types.CREATE_GIFTED_SUBSCRIPTION:
17119
+ return _classPrivateFieldGet(this, _createGiftedSubscription5).call(this, options, callback);
17120
+ case types.RENEW_GIFTED_SUBSCRIPTION:
17121
+ return _classPrivateFieldGet(this, _renewGiftedSubscription4).call(this, options, callback);
17122
+ case types.PURCHASE_ECOMMERCE_ORDER:
17123
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder4).call(this, options, callback);
17124
+ case types.PAY_INVOICE:
17125
+ return _classPrivateFieldGet(this, _payInvoice5).call(this, options, callback);
17126
+ default:
17127
+ console.error("Unsupported payment method: cybersource Gateway");
17128
+ }
17129
+ });
17130
+ _classPrivateFieldInitSpec$1(this, _createSubscription5, {
17131
+ writable: true,
17132
+ value: (options, callback) => {
17133
+ const {
17134
+ token,
17135
+ plan,
17136
+ couponCode,
17137
+ product,
17138
+ quantity = 1,
17139
+ addressId,
17140
+ isExistingSource
17141
+ } = options;
17142
+ const params = isExistingSource ? {
17143
+ source_id: token
17144
+ } : {
17145
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
17146
+ gateway_token: token
17147
+ };
17148
+ window.Pelcro.subscription.create({
17149
+ quantity,
17150
+ auth_token: window.Pelcro.user.read().auth_token,
17151
+ plan_id: plan.id,
17152
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17153
+ coupon_code: couponCode,
17154
+ address_id: product.address_required ? addressId : null,
17155
+ ...params
17156
+ }, (err, res) => {
17157
+ callback(err, res);
17158
+ });
17159
+ }
17160
+ });
17161
+ _classPrivateFieldInitSpec$1(this, _renewSubscription4, {
17162
+ writable: true,
17163
+ value: (options, callback) => {
17164
+ const {
17165
+ subscriptionIdToRenew,
17166
+ token,
17167
+ plan,
17168
+ couponCode,
17169
+ product,
17170
+ addressId,
17171
+ isExistingSource
17172
+ } = options;
17173
+ const params = isExistingSource ? {
17174
+ source_id: token
17175
+ } : {
17176
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
17177
+ gateway_token: token
17178
+ };
17179
+ window.Pelcro.subscription.renew({
17180
+ auth_token: window.Pelcro.user.read().auth_token,
17181
+ plan_id: plan.id,
17182
+ coupon_code: couponCode,
17183
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17184
+ subscription_id: subscriptionIdToRenew,
17185
+ address_id: product.address_required ? addressId : null,
17186
+ ...params
17187
+ }, (err, res) => {
17188
+ callback(err, res);
17189
+ });
17190
+ }
17191
+ });
17192
+ _classPrivateFieldInitSpec$1(this, _createGiftedSubscription5, {
17193
+ writable: true,
17194
+ value: (options, callback) => {
17195
+ const {
17196
+ token,
17197
+ plan,
17198
+ couponCode,
17199
+ product,
17200
+ giftRecipient,
17201
+ quantity = 1,
17202
+ addressId,
17203
+ isExistingSource
17204
+ } = options;
17205
+ const params = isExistingSource ? {
17206
+ source_id: token
17207
+ } : {
17208
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
17209
+ gateway_token: token
17210
+ };
17211
+ window.Pelcro.subscription.create({
17212
+ quantity,
17213
+ auth_token: window.Pelcro.user.read().auth_token,
17214
+ plan_id: plan.id,
17215
+ coupon_code: couponCode,
17216
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17217
+ gift_recipient_email: giftRecipient.email,
17218
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
17219
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
17220
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
17221
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
17222
+ address_id: product.address_required ? addressId : null,
17223
+ ...params
17224
+ }, (err, res) => {
17225
+ callback(err, res);
17226
+ });
17227
+ }
17228
+ });
17229
+ _classPrivateFieldInitSpec$1(this, _renewGiftedSubscription4, {
17230
+ writable: true,
17231
+ value: (options, callback) => {
17232
+ const {
17233
+ subscriptionIdToRenew,
17234
+ token,
17235
+ product,
17236
+ plan,
17237
+ couponCode,
17238
+ addressId,
17239
+ isExistingSource
17240
+ } = options;
17241
+ const params = isExistingSource ? {
17242
+ source_id: token
17243
+ } : {
17244
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
17245
+ gateway_token: token
17246
+ };
17247
+ window.Pelcro.subscription.renewGift({
17248
+ auth_token: window.Pelcro.user.read().auth_token,
17249
+ plan_id: plan.id,
17250
+ coupon_code: couponCode,
17251
+ subscription_id: subscriptionIdToRenew,
17252
+ address_id: product.address_required ? addressId : null,
17253
+ ...params
17254
+ }, (err, res) => {
17255
+ callback(err, res);
17256
+ });
17257
+ }
17258
+ });
17259
+ _classPrivateFieldInitSpec$1(this, _purchaseEcommerceOrder4, {
17260
+ writable: true,
17261
+ value: (options, callback) => {
17262
+ const {
17263
+ token,
17264
+ items,
17265
+ couponCode,
17266
+ addressId,
17267
+ isExistingSource
17268
+ } = options;
17269
+ const params = isExistingSource ? {
17270
+ source_id: token
17271
+ } : {
17272
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
17273
+ gateway_token: token
17274
+ };
17275
+ window.Pelcro.ecommerce.order.create({
17276
+ items,
17277
+ coupon_code: couponCode,
17278
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17279
+ ...params,
17280
+ ...(addressId && {
17281
+ address_id: addressId
17282
+ })
17283
+ }, (err, res) => {
17284
+ callback(err, res);
17285
+ });
17286
+ }
17287
+ });
17288
+ _classPrivateFieldInitSpec$1(this, _payInvoice5, {
17289
+ writable: true,
17290
+ value: (options, callback) => {
17291
+ const {
17292
+ token,
17293
+ invoiceId
17294
+ } = options;
17295
+ const params = options.isExistingSource ? {
17296
+ source_id: token,
17297
+ invoice_id: invoiceId
17298
+ } : {
17299
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
17300
+ gateway_token: token,
17301
+ invoice_id: invoiceId
17302
+ };
17303
+ window.Pelcro.invoice.pay(params, (err, res) => {
17304
+ callback(err, res);
17305
+ });
17306
+ }
17307
+ });
17308
+ }
17309
+ }
17310
+
17089
17311
  /**
17090
17312
  * @typedef {Object} PaymentStateType
17091
17313
  * @property {boolean} disableSubmit
@@ -17127,6 +17349,8 @@ const initialState$k = {
17127
17349
  lastNameError: null,
17128
17350
  phoneError: null,
17129
17351
  emailError: null,
17352
+ month: "",
17353
+ year: "",
17130
17354
  alert: {
17131
17355
  type: "error",
17132
17356
  content: ""
@@ -17195,9 +17419,251 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17195
17419
  updateTotalAmountWithTax();
17196
17420
  }, []);
17197
17421
 
17422
+ /*====== Start Cybersource integration ========*/
17423
+ const cybersourceErrorHandle = err => {
17424
+ var _err$details, _err$details$response;
17425
+ const errorMessages = [];
17426
+
17427
+ // enumerable error (ex: validation errors)
17428
+ Object.values(err === null || err === void 0 ? void 0 : (_err$details = err.details) === null || _err$details === void 0 ? void 0 : (_err$details$response = _err$details.responseStatus) === null || _err$details$response === void 0 ? void 0 : _err$details$response.details).forEach(_ref2 => {
17429
+ let {
17430
+ message
17431
+ } = _ref2;
17432
+ errorMessages.push(message);
17433
+ });
17434
+
17435
+ // convert to multiline string
17436
+ return errorMessages.join("\n");
17437
+ };
17438
+ const submitUsingCybersource = (state, dispatch) => {
17439
+ var _cybersourceInstanceR;
17440
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
17441
+ if (isUsingExistingPaymentMethod) {
17442
+ // no need to create a new source using cybersrce
17443
+ return handleCybersourcePayment(null, state);
17444
+ }
17445
+ if (!cybersourceInstanceRef.current) {
17446
+ return console.error("Cybersource sdk script wasn't loaded, you need to load Cybersource sdk before rendering the Cybersource payment flow");
17447
+ }
17448
+ let options = {
17449
+ cardExpirationMonth: state.month,
17450
+ cardExpirationYear: state.year
17451
+ };
17452
+ (_cybersourceInstanceR = cybersourceInstanceRef.current) === null || _cybersourceInstanceR === void 0 ? void 0 : _cybersourceInstanceR.createToken(options, function (err, response) {
17453
+ if (err) {
17454
+ dispatch({
17455
+ type: DISABLE_SUBMIT,
17456
+ payload: false
17457
+ });
17458
+ dispatch({
17459
+ type: LOADING,
17460
+ payload: false
17461
+ });
17462
+ return dispatch({
17463
+ type: SHOW_ALERT,
17464
+ payload: {
17465
+ type: "error",
17466
+ content: cybersourceErrorHandle(err)
17467
+ }
17468
+ });
17469
+ }
17470
+ handleCybersourcePayment(response.token, state);
17471
+ });
17472
+ };
17473
+ function handleCybersourcePayment(paymentRequest, state) {
17474
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
17475
+ if (type === "createPayment") {
17476
+ handleCybersourceSubscription();
17477
+ } else if (type === "orderCreate") {
17478
+ purchase(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
17479
+ } else if (type === "invoicePayment") {
17480
+ payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
17481
+ } else if (type === "updatePaymentSource") {
17482
+ createNewCybersourceCard();
17483
+ }
17484
+ function createNewCybersourceCard() {
17485
+ window.Pelcro.source.create({
17486
+ auth_token: window.Pelcro.user.read().auth_token,
17487
+ token: paymentRequest,
17488
+ gateway: "cybersource"
17489
+ }, (err, res) => {
17490
+ dispatch({
17491
+ type: DISABLE_SUBMIT,
17492
+ payload: false
17493
+ });
17494
+ dispatch({
17495
+ type: LOADING,
17496
+ payload: false
17497
+ });
17498
+ toggleAuthenticationSuccessPendingView(false);
17499
+ if (err) {
17500
+ onFailure(err);
17501
+ return dispatch({
17502
+ type: SHOW_ALERT,
17503
+ payload: {
17504
+ type: "error",
17505
+ content: getErrorMessages(err)
17506
+ }
17507
+ });
17508
+ }
17509
+ dispatch({
17510
+ type: SHOW_ALERT,
17511
+ payload: {
17512
+ type: "success",
17513
+ content: t("messages.sourceUpdated")
17514
+ }
17515
+ });
17516
+ onSuccess(res);
17517
+ } //
17518
+ );
17519
+ }
17520
+
17521
+ function handleCybersourceSubscription() {
17522
+ const payment = new Payment(new CybersourceGateway());
17523
+ const createSubscription = !isGift && !subscriptionIdToRenew;
17524
+ const renewSubscription = !isGift && subscriptionIdToRenew;
17525
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
17526
+ const renewGift = isRenewingGift;
17527
+ const {
17528
+ couponCode
17529
+ } = state;
17530
+ if (renewGift) {
17531
+ return payment.execute({
17532
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
17533
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
17534
+ plan,
17535
+ couponCode,
17536
+ product,
17537
+ isExistingSource: isUsingExistingPaymentMethod,
17538
+ subscriptionIdToRenew,
17539
+ addressId: selectedAddressId
17540
+ }, (err, res) => {
17541
+ if (err) {
17542
+ return handlePaymentError(err);
17543
+ }
17544
+ onSuccess(res);
17545
+ });
17546
+ } else if (giftSubscriprition) {
17547
+ return payment.execute({
17548
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
17549
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
17550
+ quantity: plan.quantity,
17551
+ plan,
17552
+ couponCode,
17553
+ product,
17554
+ isExistingSource: isUsingExistingPaymentMethod,
17555
+ giftRecipient,
17556
+ addressId: selectedAddressId
17557
+ }, (err, res) => {
17558
+ if (err) {
17559
+ return handlePaymentError(err);
17560
+ }
17561
+ onSuccess(res);
17562
+ });
17563
+ } else if (renewSubscription) {
17564
+ return payment.execute({
17565
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
17566
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
17567
+ quantity: plan.quantity,
17568
+ plan,
17569
+ couponCode,
17570
+ product,
17571
+ isExistingSource: isUsingExistingPaymentMethod,
17572
+ subscriptionIdToRenew,
17573
+ addressId: selectedAddressId
17574
+ }, (err, res) => {
17575
+ if (err) {
17576
+ return handlePaymentError(err);
17577
+ }
17578
+ onSuccess(res);
17579
+ });
17580
+ } else if (createSubscription) {
17581
+ return payment.execute({
17582
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
17583
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
17584
+ quantity: plan.quantity,
17585
+ plan,
17586
+ couponCode,
17587
+ product,
17588
+ isExistingSource: isUsingExistingPaymentMethod,
17589
+ addressId: selectedAddressId
17590
+ }, (err, res) => {
17591
+ if (err) {
17592
+ return handlePaymentError(err);
17593
+ }
17594
+ onSuccess(res);
17595
+ });
17596
+ }
17597
+ }
17598
+ }
17599
+ const tokenizeCard = (error, microformInstance) => {
17600
+ if (error) {
17601
+ console.log("tokenizeCard => ", error);
17602
+ return;
17603
+ }
17604
+ cybersourceInstanceRef.current = microformInstance;
17605
+ };
17606
+ const initCybersourceScript = () => {
17607
+ // jwk api call
17608
+ window.Pelcro.payment.getJWK({
17609
+ auth_token: window.Pelcro.user.read().auth_token,
17610
+ site_id: window.Pelcro.siteid
17611
+ }, (err, res) => {
17612
+ if (err) {
17613
+ onFailure(err);
17614
+ dispatch({
17615
+ type: DISABLE_SUBMIT,
17616
+ payload: false
17617
+ });
17618
+ dispatch({
17619
+ type: LOADING,
17620
+ payload: false
17621
+ });
17622
+ return dispatch({
17623
+ type: SHOW_ALERT,
17624
+ payload: {
17625
+ type: "error",
17626
+ content: getErrorMessages(err)
17627
+ }
17628
+ });
17629
+ }
17630
+ const {
17631
+ key: jwk
17632
+ } = res;
17633
+ // SETUP MICROFORM
17634
+ FLEX.microform({
17635
+ keyId: jwk.kid,
17636
+ keystore: jwk,
17637
+ container: "#cybersourceCardNumber",
17638
+ placeholder: "Card Number",
17639
+ styles: {
17640
+ input: {
17641
+ "font-size": "14px",
17642
+ "font-family": "helvetica, tahoma, calibri, sans-serif",
17643
+ color: "#555"
17644
+ },
17645
+ ":focus": {
17646
+ color: "blue"
17647
+ },
17648
+ ":disabled": {
17649
+ cursor: "not-allowed"
17650
+ },
17651
+ valid: {
17652
+ color: "#3c763d"
17653
+ },
17654
+ invalid: {
17655
+ color: "#a94442"
17656
+ }
17657
+ }
17658
+ }, tokenizeCard);
17659
+ });
17660
+ };
17661
+
17662
+ /*====== End Cybersource integration ========*/
17663
+
17198
17664
  /*====== Start Tap integration ========*/
17199
17665
  const submitUsingTap = state => {
17200
- var _ref2, _ref3, _getPlanAmount;
17666
+ var _ref3, _ref4, _getPlanAmount;
17201
17667
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
17202
17668
  if (isUsingExistingPaymentMethod) {
17203
17669
  // no need to create a new source using tap
@@ -17229,7 +17695,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17229
17695
  return plan.amount;
17230
17696
  }
17231
17697
  }
17232
- const totalAmount = (_ref2 = (_ref3 = (_getPlanAmount = getPlanAmount()) !== null && _getPlanAmount !== void 0 ? _getPlanAmount : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref3 !== void 0 ? _ref3 : getOrderItemsTotal()) !== null && _ref2 !== void 0 ? _ref2 : 10;
17698
+ const totalAmount = (_ref3 = (_ref4 = (_getPlanAmount = getPlanAmount()) !== null && _getPlanAmount !== void 0 ? _getPlanAmount : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref4 !== void 0 ? _ref4 : getOrderItemsTotal()) !== null && _ref3 !== void 0 ? _ref3 : 10;
17233
17699
  tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
17234
17700
  if (result.error) {
17235
17701
  // Inform the user if there was an error
@@ -17646,6 +18112,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17646
18112
  const vantivInstanceRef = React__default['default'].useRef(null);
17647
18113
  const tapInstanceRef = React__default['default'].useRef(null);
17648
18114
  const tapInstanceCard = React__default['default'].useRef(null);
18115
+ const cybersourceInstanceRef = React__default['default'].useRef(null);
17649
18116
  React.useEffect(() => {
17650
18117
  if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
17651
18118
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
@@ -17694,6 +18161,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17694
18161
  if (cardProcessor === "tap" && !selectedPaymentMethodId && window.Tapjsli) {
17695
18162
  initTapScript();
17696
18163
  }
18164
+ if (cardProcessor === "cybersource") {
18165
+ if (!window.FLEX) {
18166
+ window.Pelcro.helpers.loadSDK("https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js", "cybersource-cdn");
18167
+ document.querySelector('script[src="https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js"]').addEventListener("load", () => {
18168
+ initCybersourceScript();
18169
+ });
18170
+ return;
18171
+ }
18172
+ if (!selectedPaymentMethodId) {
18173
+ initCybersourceScript();
18174
+ }
18175
+ }
17697
18176
  });
17698
18177
  }, [selectedPaymentMethodId]);
17699
18178
  const initPaymentRequest = (state, dispatch) => {
@@ -17717,13 +18196,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17717
18196
  });
17718
18197
 
17719
18198
  // When Google pay / Apple pay source created
17720
- paymentRequest.on("source", _ref4 => {
18199
+ paymentRequest.on("source", _ref5 => {
17721
18200
  var _source$card;
17722
18201
  let {
17723
18202
  complete,
17724
18203
  source,
17725
18204
  ...data
17726
- } = _ref4;
18205
+ } = _ref5;
17727
18206
  dispatch({
17728
18207
  type: DISABLE_COUPON_BUTTON,
17729
18208
  payload: true
@@ -17738,11 +18217,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17738
18217
  });
17739
18218
  complete("success");
17740
18219
  if ((source === null || source === void 0 ? void 0 : (_source$card = source.card) === null || _source$card === void 0 ? void 0 : _source$card.three_d_secure) === "required") {
17741
- return generate3DSecureSource(source).then(_ref5 => {
18220
+ return generate3DSecureSource(source).then(_ref6 => {
17742
18221
  let {
17743
18222
  source,
17744
18223
  error
17745
- } = _ref5;
18224
+ } = _ref6;
17746
18225
  if (error) {
17747
18226
  return handlePaymentError(error);
17748
18227
  }
@@ -18342,12 +18821,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18342
18821
  const updatePaymentSource = (state, dispatch) => {
18343
18822
  return stripe.createSource({
18344
18823
  type: "card"
18345
- }).then(_ref6 => {
18824
+ }).then(_ref7 => {
18346
18825
  var _source$card2;
18347
18826
  let {
18348
18827
  source,
18349
18828
  error
18350
- } = _ref6;
18829
+ } = _ref7;
18351
18830
  if (error) {
18352
18831
  return handlePaymentError(error);
18353
18832
  }
@@ -18463,12 +18942,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18463
18942
  }
18464
18943
  stripe.createSource({
18465
18944
  type: "card"
18466
- }).then(_ref7 => {
18467
- var _ref8, _ref9, _state$updatedPrice;
18945
+ }).then(_ref8 => {
18946
+ var _ref9, _ref10, _state$updatedPrice;
18468
18947
  let {
18469
18948
  source,
18470
18949
  error
18471
- } = _ref7;
18950
+ } = _ref8;
18472
18951
  if (error) {
18473
18952
  return handlePaymentError(error);
18474
18953
  }
@@ -18487,7 +18966,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18487
18966
  return total + item.price * item.quantity;
18488
18967
  }, 0);
18489
18968
  };
18490
- (_ref8 = (_ref9 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref9 !== void 0 ? _ref9 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref8 !== void 0 ? _ref8 : getOrderItemsTotal();
18969
+ (_ref9 = (_ref10 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref10 !== void 0 ? _ref10 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref9 !== void 0 ? _ref9 : getOrderItemsTotal();
18491
18970
  return handlePayment(source);
18492
18971
  }).catch(error => {
18493
18972
  return handlePaymentError(error);
@@ -18711,6 +19190,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18711
19190
  return submitUsingTap(state);
18712
19191
  }
18713
19192
  }
19193
+ if (getSiteCardProcessor() === "cybersource") {
19194
+ return submitUsingCybersource(state, dispatch);
19195
+ }
18714
19196
  if (selectedPaymentMethodId) {
18715
19197
  if (!isAuthenticated() && plan.type === "donation") {
18716
19198
  return sendRegisterRequest(state, () => handlePayment({
@@ -18789,6 +19271,16 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18789
19271
  ...state,
18790
19272
  percentOff: action.payload
18791
19273
  });
19274
+ case SET_MONTH:
19275
+ return lib_7({
19276
+ ...state,
19277
+ month: action.payload
19278
+ });
19279
+ case SET_YEAR:
19280
+ return lib_7({
19281
+ ...state,
19282
+ year: action.payload
19283
+ });
18792
19284
  case SET_FIRST_NAME:
18793
19285
  return lib_7({
18794
19286
  ...state,
@@ -18901,6 +19393,114 @@ const PaymentMethodContainer = props => {
18901
19393
  return null;
18902
19394
  };
18903
19395
 
19396
+ function Select(_ref) {
19397
+ let {
19398
+ label = "",
19399
+ required,
19400
+ id,
19401
+ errorId,
19402
+ error = "",
19403
+ className = "",
19404
+ labelClassName = "",
19405
+ errorClassName = "",
19406
+ wrapperClassName = "",
19407
+ children,
19408
+ ...otherProps
19409
+ } = _ref;
19410
+ return /*#__PURE__*/React__default['default'].createElement("div", {
19411
+ className: `pelcro-input-wrapper ${wrapperClassName}`
19412
+ }, /*#__PURE__*/React__default['default'].createElement("label", {
19413
+ htmlFor: id,
19414
+ className: `pelcro-input-label ${labelClassName}`
19415
+ }, `${label}${required ? "*" : ""}`), /*#__PURE__*/React__default['default'].createElement("select", Object.assign({
19416
+ id: id,
19417
+ className: `pelcro-input-field ${className} ${error ? "pelcro-input-invalid" : ""}`,
19418
+ "aria-describedby": errorId,
19419
+ "aria-invalid": Boolean(error)
19420
+ }, otherProps), children), error && /*#__PURE__*/React__default['default'].createElement("p", {
19421
+ id: errorId,
19422
+ "aria-live": "assertive",
19423
+ className: `pelcro-input-error ${errorClassName}`
19424
+ }, error));
19425
+ }
19426
+
19427
+ function MonthSelect(_ref) {
19428
+ let {
19429
+ placeholder,
19430
+ store,
19431
+ ...otherProps
19432
+ } = _ref;
19433
+ const {
19434
+ dispatch,
19435
+ state: {
19436
+ month
19437
+ }
19438
+ } = React.useContext(store);
19439
+ const get2digits = num => num < 10 ? "0" + num.toString() : num.toString();
19440
+ const createMonthsItems = React.useMemo(() => {
19441
+ return [...Array.from({
19442
+ length: 12
19443
+ }, (_, i) => i + 1)].map(i => {
19444
+ return /*#__PURE__*/React__default['default'].createElement("option", {
19445
+ key: i,
19446
+ value: get2digits(i)
19447
+ }, get2digits(i));
19448
+ });
19449
+ }, []);
19450
+ const handleInputChange = value => {
19451
+ dispatch({
19452
+ type: SET_MONTH,
19453
+ payload: value
19454
+ });
19455
+ };
19456
+ return /*#__PURE__*/React__default['default'].createElement(Select, Object.assign({
19457
+ value: month,
19458
+ onChange: e => handleInputChange(e.target.value)
19459
+ }, otherProps), /*#__PURE__*/React__default['default'].createElement("option", {
19460
+ value: "",
19461
+ disabled: true,
19462
+ selected: true
19463
+ }, placeholder), createMonthsItems);
19464
+ }
19465
+
19466
+ function YearSelect(_ref) {
19467
+ let {
19468
+ placeholder,
19469
+ store,
19470
+ ...otherProps
19471
+ } = _ref;
19472
+ const {
19473
+ dispatch,
19474
+ state: {
19475
+ year
19476
+ }
19477
+ } = React.useContext(store);
19478
+ const createYearsItems = React.useMemo(() => {
19479
+ return Array.from({
19480
+ length: 10
19481
+ }, (_, i) => i + new Date().getFullYear()).map(i => {
19482
+ return /*#__PURE__*/React__default['default'].createElement("option", {
19483
+ key: i,
19484
+ value: i
19485
+ }, i);
19486
+ });
19487
+ }, []);
19488
+ const handleInputChange = value => {
19489
+ dispatch({
19490
+ type: SET_YEAR,
19491
+ payload: value
19492
+ });
19493
+ };
19494
+ return /*#__PURE__*/React__default['default'].createElement(Select, Object.assign({
19495
+ value: year,
19496
+ onChange: e => handleInputChange(e.target.value)
19497
+ }, otherProps), /*#__PURE__*/React__default['default'].createElement("option", {
19498
+ value: "",
19499
+ disabled: true,
19500
+ selected: true
19501
+ }, placeholder), createYearsItems);
19502
+ }
19503
+
18904
19504
  const StripeInputStyle = {
18905
19505
  base: "plc-w-full plc-p-3 plc-border plc-border-gray-300 plc-appearance-none plc-outline-none plc-rounded-sm plc-bg-gray-50 pelcro-input-input",
18906
19506
  focus: "plc-ring-2 plc-ring-primary-400",
@@ -18990,6 +19590,24 @@ const CheckoutForm = () => {
18990
19590
  id: "tapPaymentIframe"
18991
19591
  });
18992
19592
  }
19593
+ if (cardProcessor === "cybersource") {
19594
+ return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("div", {
19595
+ id: "cybersourceCardNumber",
19596
+ className: "pelcro-input-field plc-h-12"
19597
+ }), /*#__PURE__*/React__default['default'].createElement("div", {
19598
+ className: "plc-flex plc-items-end plc-justify-between plc-my-2"
19599
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
19600
+ className: "plc-w-6/12 plc-pr-4"
19601
+ }, /*#__PURE__*/React__default['default'].createElement(MonthSelect, {
19602
+ store: store$k,
19603
+ placeholder: "Exp Month"
19604
+ })), /*#__PURE__*/React__default['default'].createElement("div", {
19605
+ className: "plc-w-6/12"
19606
+ }, /*#__PURE__*/React__default['default'].createElement(YearSelect, {
19607
+ store: store$k,
19608
+ placeholder: "Exp Year"
19609
+ }))));
19610
+ }
18993
19611
  if (cardProcessor === "stripe") {
18994
19612
  return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(PelcroCardNumber, {
18995
19613
  autoFocus: true
@@ -19741,7 +20359,7 @@ const DonationEmail = props => /*#__PURE__*/React__default['default'].createElem
19741
20359
  *
19742
20360
  */
19743
20361
  function PaymentMethodView(_ref) {
19744
- var _window$Pelcro$site$r, _window$Pelcro$site$r2, _calcAndFormatItemsTo, _order$;
20362
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _calcAndFormatItemsTo, _order$;
19745
20363
  let {
19746
20364
  onSuccess,
19747
20365
  onGiftRenewalSuccess,
@@ -19763,6 +20381,7 @@ function PaymentMethodView(_ref) {
19763
20381
  const cardProcessor = getSiteCardProcessor();
19764
20382
  const supportsVantiv = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings);
19765
20383
  const supportsTap = Boolean((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.tap_gateway_settings);
20384
+ const supportsCybersource = Boolean((_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.cybersource_gateway_settings);
19766
20385
  const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
19767
20386
  const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
19768
20387
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
@@ -19826,7 +20445,7 @@ function PaymentMethodView(_ref) {
19826
20445
  className: "plc-mb-2"
19827
20446
  }, /*#__PURE__*/React__default['default'].createElement(CouponCode, null), /*#__PURE__*/React__default['default'].createElement(DiscountedPrice, null)), /*#__PURE__*/React__default['default'].createElement(TaxAmount, null), /*#__PURE__*/React__default['default'].createElement("div", {
19828
20447
  className: "plc-grid plc-mt-4 plc-gap-y-2"
19829
- }, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : null)))));
20448
+ }, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : null)))));
19830
20449
  }
19831
20450
 
19832
20451
  const SubscriptionRenewView = _ref => {
@@ -22850,37 +23469,6 @@ const AddressCreateSubmit = _ref => {
22850
23469
  }, otherProps), name !== null && name !== void 0 ? name : t("buttons.submit"));
22851
23470
  };
22852
23471
 
22853
- function Select(_ref) {
22854
- let {
22855
- label = "",
22856
- required,
22857
- id,
22858
- errorId,
22859
- error = "",
22860
- className = "",
22861
- labelClassName = "",
22862
- errorClassName = "",
22863
- wrapperClassName = "",
22864
- children,
22865
- ...otherProps
22866
- } = _ref;
22867
- return /*#__PURE__*/React__default['default'].createElement("div", {
22868
- className: `pelcro-input-wrapper ${wrapperClassName}`
22869
- }, /*#__PURE__*/React__default['default'].createElement("label", {
22870
- htmlFor: id,
22871
- className: `pelcro-input-label ${labelClassName}`
22872
- }, `${label}${required ? "*" : ""}`), /*#__PURE__*/React__default['default'].createElement("select", Object.assign({
22873
- id: id,
22874
- className: `pelcro-input-field ${className} ${error ? "pelcro-input-invalid" : ""}`,
22875
- "aria-describedby": errorId,
22876
- "aria-invalid": Boolean(error)
22877
- }, otherProps), children), error && /*#__PURE__*/React__default['default'].createElement("p", {
22878
- id: errorId,
22879
- "aria-live": "assertive",
22880
- className: `pelcro-input-error ${errorClassName}`
22881
- }, error));
22882
- }
22883
-
22884
23472
  function CountrySelect(_ref) {
22885
23473
  let {
22886
23474
  placeholder,