@montonio/montonio-js 1.1.1 → 1.1.2

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.
@@ -33,10 +33,10 @@ ${n}
33
33
  Please fix these validation errors and try again.`), this.name = Z.CHECKOUT_OPTIONS_VALIDATION_ERROR;
34
34
  }
35
35
  }
36
- var T;
36
+ var O;
37
37
  (function(e) {
38
- e.CHECKOUT_PAYMENT_COMPONENT_READY = "montonio:checkout.paymentComponentReady", e.CHECKOUT_CHANGE_LOCALE = "montonio:checkout.changeLocale", e.CHECKOUT_SUBMIT_PAYMENT = "montonio:checkout.submitPayment", e.CHECKOUT_START_PAYMENT_AUTH = "montonio:checkout.startPaymentAuth", e.CHECKOUT_SEND_PAYMENT_AUTH_DATA = "montonio:checkout.sendPaymentAuthData", e.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY = "montonio:checkout.paymentAuthComponentReady", e.CHECKOUT_PAYMENT_AUTH_COMPLETED = "montonio:checkout.paymentAuthCompleted", e.CHECKOUT_PAYMENT_COMPLETED = "montonio:checkout.paymentCompleted", e.CHECKOUT_PAYMENT_FAILED = "montonio:checkout.paymentFailed", e.CHECKOUT_SEND_PAYMENT_FAILED_DATA = "montonio:checkout.sendPaymentFailedData", e.CHECKOUT_HEIGHT_CHANGED = "montonio:checkout.heightChanged", e.CHECKOUT_VALIDATE_FIELDS = "montonio:checkout.validateFields", e.CHECKOUT_VALIDATE_FIELDS_RESULT = "montonio:checkout.validateFieldsResult", e.CHECKOUT_PAYMENT_FORM_CHANGED = "montonio:checkout.paymentFormChanged";
39
- })(T || (T = {}));
38
+ e.CHECKOUT_PAYMENT_COMPONENT_READY = "montonio:checkout.paymentComponentReady", e.CHECKOUT_CHANGE_LOCALE = "montonio:checkout.changeLocale", e.CHECKOUT_SUBMIT_PAYMENT = "montonio:checkout.submitPayment", e.CHECKOUT_START_PAYMENT_AUTH = "montonio:checkout.startPaymentAuth", e.CHECKOUT_SEND_PAYMENT_AUTH_DATA = "montonio:checkout.sendPaymentAuthData", e.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY = "montonio:checkout.paymentAuthComponentReady", e.CHECKOUT_PAYMENT_AUTH_COMPLETED = "montonio:checkout.paymentAuthCompleted", e.CHECKOUT_PAYMENT_COMPLETED = "montonio:checkout.paymentCompleted", e.CHECKOUT_PAYMENT_FAILED = "montonio:checkout.paymentFailed", e.CHECKOUT_SEND_PAYMENT_FAILED_DATA = "montonio:checkout.sendPaymentFailedData", e.CHECKOUT_HEIGHT_CHANGED = "montonio:checkout.heightChanged", e.CHECKOUT_VALIDATE_FIELDS = "montonio:checkout.validateFields", e.CHECKOUT_VALIDATE_FIELDS_RESULT = "montonio:checkout.validateFieldsResult", e.CHECKOUT_PAYMENT_FORM_CHANGED = "montonio:checkout.paymentFormChanged", e.CHECKOUT_REDIRECT = "montonio:checkout.redirect";
39
+ })(O || (O = {}));
40
40
  class W {
41
41
  constructor() {
42
42
  this.environmentVariables = {
@@ -90,7 +90,7 @@ class se {
90
90
  try {
91
91
  const i = {
92
92
  Accept: "application/json",
93
- "X-Montonio-Js-Version": "1.1.1"
93
+ "X-Montonio-Js-Version": "1.1.2"
94
94
  };
95
95
  r && (i["Content-Type"] = "application/json");
96
96
  const c = {
@@ -217,14 +217,14 @@ class en {
217
217
  return t.getContentWindow();
218
218
  }
219
219
  }
220
- const O = {
220
+ const T = {
221
221
  log: "log",
222
222
  debug: "debug",
223
223
  info: "info",
224
224
  warn: "warn",
225
225
  error: "error"
226
226
  }, N = console, j = {};
227
- Object.keys(O).forEach((e) => {
227
+ Object.keys(T).forEach((e) => {
228
228
  j[e] = N[e];
229
229
  });
230
230
  const be = "Datadog Browser SDK:", y = {
@@ -2166,7 +2166,7 @@ function Ks(e) {
2166
2166
  return e.site === mo;
2167
2167
  }
2168
2168
  function kt(e, t) {
2169
- mt(O.debug, e, t), Ae().notify({
2169
+ mt(T.debug, e, t), Ae().notify({
2170
2170
  rawEvent: {
2171
2171
  type: X.LOG,
2172
2172
  message: e,
@@ -2589,7 +2589,7 @@ function Ci(e) {
2589
2589
  }
2590
2590
  function vi(e, t, n) {
2591
2591
  const r = e.map((o) => wi(o)).join(" ");
2592
- if (t === O.error) {
2592
+ if (t === T.error) {
2593
2593
  const o = e.find(ne), s = xt({
2594
2594
  originalError: o,
2595
2595
  handlingStack: n,
@@ -2980,9 +2980,9 @@ function Xt() {
2980
2980
  const Bi = 32 * ue;
2981
2981
  function Gi(e, t) {
2982
2982
  e.usePciIntake === !0 && e.site && e.site !== "datadoghq.com" && y.warn("PCI compliance for Logs is only available for Datadog organizations in the US1 site. Default intake will be used.");
2983
- const n = Ro(e, t), r = Zt(e.forwardConsoleLogs, Be(O), "Forward Console Logs"), o = Zt(e.forwardReports, Be(Ke), "Forward Reports");
2983
+ const n = Ro(e, t), r = Zt(e.forwardConsoleLogs, Be(T), "Forward Console Logs"), o = Zt(e.forwardReports, Be(Ke), "Forward Reports");
2984
2984
  if (!(!n || !r || !o))
2985
- return e.forwardErrorsToLogs && !r.includes(O.error) && r.push(O.error), {
2985
+ return e.forwardErrorsToLogs && !r.includes(T.error) && r.push(T.error), {
2986
2986
  forwardErrorsToLogs: e.forwardErrorsToLogs !== !1,
2987
2987
  forwardConsoleLogs: r,
2988
2988
  forwardReports: o,
@@ -3146,11 +3146,11 @@ function Zi(e, t, n, r, o) {
3146
3146
  });
3147
3147
  }
3148
3148
  const Qi = {
3149
- [O.log]: h.info,
3150
- [O.debug]: h.debug,
3151
- [O.info]: h.info,
3152
- [O.warn]: h.warn,
3153
- [O.error]: h.error
3149
+ [T.log]: h.info,
3150
+ [T.debug]: h.debug,
3151
+ [T.info]: h.info,
3152
+ [T.warn]: h.warn,
3153
+ [T.error]: h.error
3154
3154
  };
3155
3155
  function ec(e, t) {
3156
3156
  const n = Ti(e.forwardConsoleLogs).subscribe((r) => {
@@ -3320,15 +3320,15 @@ function dc(e) {
3320
3320
  };
3321
3321
  }
3322
3322
  const fc = {
3323
- [h.ok]: O.debug,
3324
- [h.debug]: O.debug,
3325
- [h.info]: O.info,
3326
- [h.notice]: O.info,
3327
- [h.warn]: O.warn,
3328
- [h.error]: O.error,
3329
- [h.critical]: O.error,
3330
- [h.alert]: O.error,
3331
- [h.emerg]: O.error
3323
+ [h.ok]: T.debug,
3324
+ [h.debug]: T.debug,
3325
+ [h.info]: T.info,
3326
+ [h.notice]: T.info,
3327
+ [h.warn]: T.warn,
3328
+ [h.error]: T.error,
3329
+ [h.critical]: T.error,
3330
+ [h.alert]: T.error,
3331
+ [h.emerg]: T.error
3332
3332
  };
3333
3333
  function pc({ status: e, message: t }, n) {
3334
3334
  j[fc[e]].call(N, t, n);
@@ -3492,7 +3492,7 @@ class ae {
3492
3492
  env: t === Ce.PRODUCTION ? "live-production" : "live-sandbox",
3493
3493
  forwardErrorsToLogs: !0,
3494
3494
  service: "montonio-js",
3495
- version: "1.1.1",
3495
+ version: "1.1.2",
3496
3496
  silentMultipleInit: !0,
3497
3497
  forwardConsoleLogs: "all"
3498
3498
  }), Me.setGlobalContext({
@@ -3531,7 +3531,7 @@ class sr {
3531
3531
  * Listen to height change messages from the child window and change the height of the iframe element
3532
3532
  */
3533
3533
  startResizing(t) {
3534
- this.messagingService.subscribe(T.CHECKOUT_HEIGHT_CHANGED, (n) => {
3534
+ this.messagingService.subscribe(O.CHECKOUT_HEIGHT_CHANGED, (n) => {
3535
3535
  t.style.height = n.payload.height + "px";
3536
3536
  }, this);
3537
3537
  }
@@ -3631,8 +3631,8 @@ class Rc extends ir {
3631
3631
  zIndex: "2147483647"
3632
3632
  },
3633
3633
  resizeOnHeightChange: !1
3634
- }), this.iframe.mount(), await this.messagingService.waitForMessage(T.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY, this.iframe), this.messagingService.postMessage(this.iframe, {
3635
- name: T.CHECKOUT_SEND_PAYMENT_AUTH_DATA,
3634
+ }), this.iframe.mount(), await this.messagingService.waitForMessage(O.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY, this.iframe), this.messagingService.postMessage(this.iframe, {
3635
+ name: O.CHECKOUT_SEND_PAYMENT_AUTH_DATA,
3636
3636
  payload: {
3637
3637
  paymentAuthData: this.options.paymentAuthData
3638
3638
  }
@@ -3677,7 +3677,7 @@ class xc extends ir {
3677
3677
  return this.iframe = new sr({
3678
3678
  src: n.url,
3679
3679
  mountElement: this.mountElement
3680
- }), this.iframe.mount(), await this.messagingService.waitForMessage(T.CHECKOUT_PAYMENT_COMPONENT_READY, this.iframe), this.setUpListeners(), this.loaded = !0, console.log("MONTONIO-JS: initialize: MontonioCheckout initialized successfully"), !0;
3680
+ }), this.iframe.mount(), await this.messagingService.waitForMessage(O.CHECKOUT_PAYMENT_COMPONENT_READY, this.iframe), this.setUpListeners(), this.loaded = !0, console.log("MONTONIO-JS: initialize: MontonioCheckout initialized successfully"), !0;
3681
3681
  } catch (n) {
3682
3682
  throw console.error("MONTONIO-JS: initialize: Error initializing MontonioCheckout:", n), this.cleanup(), n;
3683
3683
  }
@@ -3690,7 +3690,7 @@ class xc extends ir {
3690
3690
  if (console.log("MONTONIO-JS: updateOptions: Updating options to:", t), !this.loaded)
3691
3691
  throw new Mt();
3692
3692
  Ic(t), t.locale !== void 0 && (this.options.locale = t.locale, this.messagingService.postMessage(this.iframe, {
3693
- name: T.CHECKOUT_CHANGE_LOCALE,
3693
+ name: O.CHECKOUT_CHANGE_LOCALE,
3694
3694
  payload: { locale: t.locale }
3695
3695
  }));
3696
3696
  }
@@ -3700,7 +3700,7 @@ class xc extends ir {
3700
3700
  validateOrReject() {
3701
3701
  if (console.log("MONTONIO-JS: validateOrReject: Called validateOrReject, isValid:", this.isValid), !this.isValid)
3702
3702
  throw this.messagingService.postMessage(this.iframe, {
3703
- name: T.CHECKOUT_VALIDATE_FIELDS
3703
+ name: O.CHECKOUT_VALIDATE_FIELDS
3704
3704
  }), new $t();
3705
3705
  }
3706
3706
  /**
@@ -3711,7 +3711,7 @@ class xc extends ir {
3711
3711
  if (!this.loaded)
3712
3712
  throw new Mt();
3713
3713
  this.messagingService.postMessage(this.iframe, {
3714
- name: T.CHECKOUT_SUBMIT_PAYMENT
3714
+ name: O.CHECKOUT_SUBMIT_PAYMENT
3715
3715
  });
3716
3716
  }
3717
3717
  /**
@@ -3725,13 +3725,18 @@ class xc extends ir {
3725
3725
  * Set up global listeners for payment completion, failure, payment auth, and validation.
3726
3726
  */
3727
3727
  setUpListeners() {
3728
- console.log("MONTONIO-JS: setUpListeners: Setting up listeners"), this.setUpFormChangeListener(), this.setUpPaymentCompletedListener(), this.setUpPaymentFailedListener(), this.setUpValidationListener(), this.setUpPaymentAuthListener();
3728
+ console.log("MONTONIO-JS: setUpListeners: Setting up listeners"), this.setUpFormChangeListener(), this.setUpPaymentCompletedListener(), this.setUpPaymentFailedListener(), this.setUpValidationListener(), this.setUpPaymentAuthListener(), this.setUpRedirectListener();
3729
+ }
3730
+ setUpRedirectListener() {
3731
+ this.messagingService.subscribe(O.CHECKOUT_REDIRECT, (t) => {
3732
+ window.location.href = t.payload.redirectUrl;
3733
+ }, this.iframe);
3729
3734
  }
3730
3735
  /**
3731
3736
  * Listen for payment form changes and update the isValid property
3732
3737
  */
3733
3738
  setUpFormChangeListener() {
3734
- this.messagingService.subscribe(T.CHECKOUT_PAYMENT_FORM_CHANGED, (t) => {
3739
+ this.messagingService.subscribe(O.CHECKOUT_PAYMENT_FORM_CHANGED, (t) => {
3735
3740
  this.isValid = t.payload.isValid;
3736
3741
  }, this.iframe);
3737
3742
  }
@@ -3739,7 +3744,7 @@ class xc extends ir {
3739
3744
  * Listen for payment completion messages and handle the payment success
3740
3745
  */
3741
3746
  setUpPaymentCompletedListener() {
3742
- this.messagingService.subscribe(T.CHECKOUT_PAYMENT_COMPLETED, async (t) => {
3747
+ this.messagingService.subscribe(O.CHECKOUT_PAYMENT_COMPLETED, async (t) => {
3743
3748
  console.log("MONTONIO-JS: CHECKOUT_PAYMENT_COMPLETED (from main iframe)", t), this.cleanupPaymentAuth();
3744
3749
  try {
3745
3750
  const n = await this.getPaymentResult(t.payload.paymentIntentUuid);
@@ -3753,9 +3758,9 @@ class xc extends ir {
3753
3758
  * Listen for payment failure messages and handle the error
3754
3759
  */
3755
3760
  setUpPaymentFailedListener() {
3756
- this.messagingService.subscribe(T.CHECKOUT_PAYMENT_FAILED, (t) => {
3761
+ this.messagingService.subscribe(O.CHECKOUT_PAYMENT_FAILED, (t) => {
3757
3762
  console.error("MONTONIO-JS: CHECKOUT_PAYMENT_FAILED (from main iframe)", t), this.cleanupPaymentAuth(), this.messagingService.postMessage(this.iframe, {
3758
- name: T.CHECKOUT_SEND_PAYMENT_FAILED_DATA,
3763
+ name: O.CHECKOUT_SEND_PAYMENT_FAILED_DATA,
3759
3764
  payload: t.payload
3760
3765
  }), this.handlePaymentError(new lr(t.payload));
3761
3766
  }, this.iframe);
@@ -3764,7 +3769,7 @@ class xc extends ir {
3764
3769
  * Listen for validation result messages from the iframe
3765
3770
  */
3766
3771
  setUpValidationListener() {
3767
- this.messagingService.subscribe(T.CHECKOUT_VALIDATE_FIELDS_RESULT, (t) => {
3772
+ this.messagingService.subscribe(O.CHECKOUT_VALIDATE_FIELDS_RESULT, (t) => {
3768
3773
  console.log("MONTONIO-JS: CHECKOUT_VALIDATE_FIELDS_RESULT", t), t.payload.isValid || this.handlePaymentError(new $t());
3769
3774
  }, this.iframe);
3770
3775
  }
@@ -3772,13 +3777,13 @@ class xc extends ir {
3772
3777
  * Listen for payment auth (3DS) requests and initialize the PaymentAuth component
3773
3778
  */
3774
3779
  setUpPaymentAuthListener() {
3775
- this.messagingService.subscribe(T.CHECKOUT_START_PAYMENT_AUTH, async (t) => {
3780
+ this.messagingService.subscribe(O.CHECKOUT_START_PAYMENT_AUTH, async (t) => {
3776
3781
  try {
3777
3782
  console.log("MONTONIO-JS: PAYMENT_AUTH_STARTED", t), this.paymentAuth = new Rc({
3778
3783
  paymentAuthData: t.payload.paymentAuthData
3779
3784
  }), await this.paymentAuth.initialize();
3780
3785
  const n = this.paymentAuth.iframe;
3781
- this.messagingService.addIframeToSubscription(T.CHECKOUT_PAYMENT_COMPLETED, n), this.messagingService.addIframeToSubscription(T.CHECKOUT_PAYMENT_FAILED, n);
3786
+ this.messagingService.addIframeToSubscription(O.CHECKOUT_PAYMENT_COMPLETED, n), this.messagingService.addIframeToSubscription(O.CHECKOUT_PAYMENT_FAILED, n);
3782
3787
  } catch (n) {
3783
3788
  this.handlePaymentError(n);
3784
3789
  }
@@ -3812,7 +3817,7 @@ class xc extends ir {
3812
3817
  * Destroy the PaymentAuth component and remove it from success/failure subscriptions
3813
3818
  */
3814
3819
  cleanupPaymentAuth() {
3815
- this.paymentAuth && (this.messagingService.removeIframeFromSubscription(T.CHECKOUT_PAYMENT_COMPLETED, this.paymentAuth.iframe), this.messagingService.removeIframeFromSubscription(T.CHECKOUT_PAYMENT_FAILED, this.paymentAuth.iframe), this.paymentAuth.cleanup(), this.paymentAuth = null);
3820
+ this.paymentAuth && (this.messagingService.removeIframeFromSubscription(O.CHECKOUT_PAYMENT_COMPLETED, this.paymentAuth.iframe), this.messagingService.removeIframeFromSubscription(O.CHECKOUT_PAYMENT_FAILED, this.paymentAuth.iframe), this.paymentAuth.cleanup(), this.paymentAuth = null);
3816
3821
  }
3817
3822
  /**
3818
3823
  * Handle payment success - calls the onSuccess callback
@@ -3831,7 +3836,7 @@ export {
3831
3836
  Ce as Environment,
3832
3837
  Z as ErrorEnum,
3833
3838
  Ve as LocaleEnum,
3834
- T as MessageTypeEnum,
3839
+ O as MessageTypeEnum,
3835
3840
  xc as MontonioCheckout
3836
3841
  };
3837
3842
  //# sourceMappingURL=montonio.es.js.map