@paynext/sdk 0.0.89 → 0.0.91

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.es.js CHANGED
@@ -320,7 +320,7 @@ let Zi = class {
320
320
  })
321
321
  }));
322
322
  const p = yield this.apple.availability();
323
- this.isAvailable = !0, console.log("Apple Pay availability", p), this.isAvailable || console.error("Apple Pay is not available", p), i && this.apple.on("error", i), o && this.apple.on("cancel", o), this.onReady = a;
323
+ this.isAvailable = p === "available", console.log("Apple Pay availability", p), this.isAvailable || i == null || i(new Error(`Apple Pay is not supported on this device: ${p}`)), i && this.apple.on("error", i), o && this.apple.on("cancel", o), this.onReady = a;
324
324
  });
325
325
  }
326
326
  render(t) {
@@ -4332,7 +4332,8 @@ class al {
4332
4332
  clientId: e.paypal_info.client_id,
4333
4333
  environment: e.paypal_info.environment || "sandbox",
4334
4334
  vault: !0,
4335
- locale: Gc(this.config.state.translate.locale())
4335
+ locale: Gc(this.config.state.translate.locale()),
4336
+ intent: "tokenize"
4336
4337
  }), !this.paypal.isLoaded())
4337
4338
  return !1;
4338
4339
  } catch (c) {
@@ -4631,7 +4632,7 @@ class vl {
4631
4632
  try {
4632
4633
  if (yield this.applePay.init({
4633
4634
  onError: (i) => {
4634
- this.events.error.emit(i), this.attempted.delete(q.APPLE_PAY);
4635
+ this.events.error.emit(i), t == null || t.remove(), this.attempted.delete(q.APPLE_PAY);
4635
4636
  },
4636
4637
  onCancel: () => {
4637
4638
  this.events.cancel.emit(), this.attempted.delete(q.APPLE_PAY);
@@ -4700,7 +4701,7 @@ class vl {
4700
4701
  try {
4701
4702
  if (yield this.googlePay.init({
4702
4703
  onError: (i) => {
4703
- this.events.error.emit(i), this.attempted.delete(q.GOOGLE_PAY);
4704
+ this.events.error.emit(i), t == null || t.remove(), this.attempted.delete(q.GOOGLE_PAY);
4704
4705
  },
4705
4706
  onCancel: () => {
4706
4707
  this.events.cancel.emit(), this.attempted.delete(q.GOOGLE_PAY);
@@ -4769,7 +4770,9 @@ class vl {
4769
4770
  try {
4770
4771
  const a = this.paypal.render();
4771
4772
  if (t == null || t.appendChild(a), yield this.paypal.init({
4772
- onError: (s) => this.events.error.emit(s),
4773
+ onError: (s) => {
4774
+ this.events.error.emit(s), t == null || t.remove();
4775
+ },
4773
4776
  onCancel: () => this.events.cancel.emit(),
4774
4777
  onSuccess: (s) => {
4775
4778
  this.events.success.emit({ paypalId: s, type: "paypal" });
@@ -4822,7 +4825,9 @@ class vl {
4822
4825
  this.isBraintreeReady = !1;
4823
4826
  try {
4824
4827
  if (yield this.braintree.init({
4825
- onError: (i) => this.events.error.emit(i),
4828
+ onError: (i) => {
4829
+ this.events.error.emit(i), t == null || t.remove();
4830
+ },
4826
4831
  onCancel: () => this.events.cancel.emit(),
4827
4832
  onSuccess: (i) => {
4828
4833
  this.events.success.emit({ nonce: i == null ? void 0 : i.nonce, type: "venmo" });
@@ -4884,8 +4889,8 @@ class vl {
4884
4889
  });
4885
4890
  });
4886
4891
  }
4887
- // Waits until an element is visibly rendered (has layout) or times out
4888
- waitForElementVisible(t, e = 2e3) {
4892
+ // wait for element visible
4893
+ waitForElementVisible(t, e = 350) {
4889
4894
  return !t || !(t instanceof HTMLElement) ? Promise.resolve() : new Promise((r) => {
4890
4895
  const a = performance.now(), i = () => {
4891
4896
  const s = t.getBoundingClientRect();
@@ -4932,7 +4937,7 @@ class vl {
4932
4937
  yield Promise.all(c), this.handleReady();
4933
4938
  });
4934
4939
  }
4935
- // Initialize button instances only for active payment methods
4940
+ // initialize button instances only for active payment methods
4936
4941
  initializeButtonInstances(t) {
4937
4942
  const e = t.map(({ type: r }) => r);
4938
4943
  e.includes(q.APPLE_PAY) && !this.applePay && (this.applePay = new Zc(this.config)), e.includes(q.GOOGLE_PAY) && !this.googlePay && (this.googlePay = new nl(this.config)), e.includes(q.PAYPAL) && !this.paypal && (this.paypal = new al(this.config), this.paypal.addEventListener("onPaymentAttempt", (r) => this.events.onPaymentAttempt.emit(r))), e.includes(q.VENMO) && !this.braintree && (this.braintree = new ml(this.config), this.braintree.addEventListener("onPaymentAttempt", (r) => this.events.onPaymentAttempt.emit(r))), e.includes(q.CARD) && !this.card && (this.card = new cl(this.config), this.card.addEventListener(() => {
@@ -8028,7 +8033,7 @@ class Au {
8028
8033
  }), o = (a = (r = this.paypal).Buttons) == null ? void 0 : a.call(r, s);
8029
8034
  if (!o)
8030
8035
  throw new Error("PayPal Buttons instance is null");
8031
- console.log("PayPalService: Buttons instance created, calling render()..."), yield o.render(t);
8036
+ yield o.render(t);
8032
8037
  }
8033
8038
  });
8034
8039
  }