@payfurl/client 3.0.3 → 3.1.0

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.
@@ -85,6 +85,52 @@ function normalizeClass(value) {
85
85
  }
86
86
  return res.trim();
87
87
  }
88
+ function looseCompareArrays(a, b) {
89
+ if (a.length !== b.length)
90
+ return false;
91
+ let equal = true;
92
+ for (let i = 0; equal && i < a.length; i++) {
93
+ equal = looseEqual(a[i], b[i]);
94
+ }
95
+ return equal;
96
+ }
97
+ function looseEqual(a, b) {
98
+ if (a === b)
99
+ return true;
100
+ let aValidType = isDate(a);
101
+ let bValidType = isDate(b);
102
+ if (aValidType || bValidType) {
103
+ return aValidType && bValidType ? a.getTime() === b.getTime() : false;
104
+ }
105
+ aValidType = isArray(a);
106
+ bValidType = isArray(b);
107
+ if (aValidType || bValidType) {
108
+ return aValidType && bValidType ? looseCompareArrays(a, b) : false;
109
+ }
110
+ aValidType = isObject(a);
111
+ bValidType = isObject(b);
112
+ if (aValidType || bValidType) {
113
+ if (!aValidType || !bValidType) {
114
+ return false;
115
+ }
116
+ const aKeysCount = Object.keys(a).length;
117
+ const bKeysCount = Object.keys(b).length;
118
+ if (aKeysCount !== bKeysCount) {
119
+ return false;
120
+ }
121
+ for (const key in a) {
122
+ const aHasKey = a.hasOwnProperty(key);
123
+ const bHasKey = b.hasOwnProperty(key);
124
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
125
+ return false;
126
+ }
127
+ }
128
+ }
129
+ return String(a) === String(b);
130
+ }
131
+ function looseIndexOf(arr, val) {
132
+ return arr.findIndex((item) => looseEqual(item, val));
133
+ }
88
134
  const toDisplayString = (val) => {
89
135
  return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
90
136
  };
@@ -127,6 +173,7 @@ const hasOwn = (val, key) => hasOwnProperty.call(val, key);
127
173
  const isArray = Array.isArray;
128
174
  const isMap = (val) => toTypeString(val) === "[object Map]";
129
175
  const isSet = (val) => toTypeString(val) === "[object Set]";
176
+ const isDate = (val) => val instanceof Date;
130
177
  const isFunction = (val) => typeof val === "function";
131
178
  const isString = (val) => typeof val === "string";
132
179
  const isSymbol = (val) => typeof val === "symbol";
@@ -379,7 +426,7 @@ function trackEffects(dep, debuggerEventExtraInfo) {
379
426
  activeEffect.deps.push(dep);
380
427
  }
381
428
  }
382
- function trigger(target, type, key, newValue, oldValue, oldTarget) {
429
+ function trigger$1(target, type, key, newValue, oldValue, oldTarget) {
383
430
  const depsMap = targetMap.get(target);
384
431
  if (!depsMap) {
385
432
  return;
@@ -541,9 +588,9 @@ function createSetter(shallow = false) {
541
588
  const result = Reflect.set(target, key, value, receiver);
542
589
  if (target === toRaw(receiver)) {
543
590
  if (!hadKey) {
544
- trigger(target, "add", key, value);
591
+ trigger$1(target, "add", key, value);
545
592
  } else if (hasChanged(value, oldValue)) {
546
- trigger(target, "set", key, value);
593
+ trigger$1(target, "set", key, value);
547
594
  }
548
595
  }
549
596
  return result;
@@ -554,7 +601,7 @@ function deleteProperty(target, key) {
554
601
  target[key];
555
602
  const result = Reflect.deleteProperty(target, key);
556
603
  if (result && hadKey) {
557
- trigger(target, "delete", key, void 0);
604
+ trigger$1(target, "delete", key, void 0);
558
605
  }
559
606
  return result;
560
607
  }
@@ -631,7 +678,7 @@ function add(value) {
631
678
  const hadKey = proto.has.call(target, value);
632
679
  if (!hadKey) {
633
680
  target.add(value);
634
- trigger(target, "add", value, value);
681
+ trigger$1(target, "add", value, value);
635
682
  }
636
683
  return this;
637
684
  }
@@ -647,9 +694,9 @@ function set$1(key, value) {
647
694
  const oldValue = get2.call(target, key);
648
695
  target.set(key, value);
649
696
  if (!hadKey) {
650
- trigger(target, "add", key, value);
697
+ trigger$1(target, "add", key, value);
651
698
  } else if (hasChanged(value, oldValue)) {
652
- trigger(target, "set", key, value);
699
+ trigger$1(target, "set", key, value);
653
700
  }
654
701
  return this;
655
702
  }
@@ -664,7 +711,7 @@ function deleteEntry(key) {
664
711
  get2 ? get2.call(target, key) : void 0;
665
712
  const result = target.delete(key);
666
713
  if (hadKey) {
667
- trigger(target, "delete", key, void 0);
714
+ trigger$1(target, "delete", key, void 0);
668
715
  }
669
716
  return result;
670
717
  }
@@ -673,7 +720,7 @@ function clear() {
673
720
  const hadItems = target.size !== 0;
674
721
  const result = target.clear();
675
722
  if (hadItems) {
676
- trigger(target, "clear", void 0, void 0);
723
+ trigger$1(target, "clear", void 0, void 0);
677
724
  }
678
725
  return result;
679
726
  }
@@ -2104,7 +2151,7 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
2104
2151
  }
2105
2152
  }
2106
2153
  if (hasAttrsChanged) {
2107
- trigger(instance, "set", "$attrs");
2154
+ trigger$1(instance, "set", "$attrs");
2108
2155
  }
2109
2156
  }
2110
2157
  function setFullProps(instance, rawProps, props, attrs) {
@@ -4363,6 +4410,124 @@ function shouldSetAsProp(el, key, value, isSVG) {
4363
4410
  }
4364
4411
  return key in el;
4365
4412
  }
4413
+ const getModelAssigner = (vnode) => {
4414
+ const fn = vnode.props["onUpdate:modelValue"];
4415
+ return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
4416
+ };
4417
+ function onCompositionStart(e) {
4418
+ e.target.composing = true;
4419
+ }
4420
+ function onCompositionEnd(e) {
4421
+ const target = e.target;
4422
+ if (target.composing) {
4423
+ target.composing = false;
4424
+ trigger(target, "input");
4425
+ }
4426
+ }
4427
+ function trigger(el, type) {
4428
+ const e = document.createEvent("HTMLEvents");
4429
+ e.initEvent(type, true, true);
4430
+ el.dispatchEvent(e);
4431
+ }
4432
+ const vModelText = {
4433
+ created(el, { modifiers: { lazy, trim, number } }, vnode) {
4434
+ el._assign = getModelAssigner(vnode);
4435
+ const castToNumber = number || vnode.props && vnode.props.type === "number";
4436
+ addEventListener(el, lazy ? "change" : "input", (e) => {
4437
+ if (e.target.composing)
4438
+ return;
4439
+ let domValue = el.value;
4440
+ if (trim) {
4441
+ domValue = domValue.trim();
4442
+ } else if (castToNumber) {
4443
+ domValue = toNumber(domValue);
4444
+ }
4445
+ el._assign(domValue);
4446
+ });
4447
+ if (trim) {
4448
+ addEventListener(el, "change", () => {
4449
+ el.value = el.value.trim();
4450
+ });
4451
+ }
4452
+ if (!lazy) {
4453
+ addEventListener(el, "compositionstart", onCompositionStart);
4454
+ addEventListener(el, "compositionend", onCompositionEnd);
4455
+ addEventListener(el, "change", onCompositionEnd);
4456
+ }
4457
+ },
4458
+ mounted(el, { value }) {
4459
+ el.value = value == null ? "" : value;
4460
+ },
4461
+ beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
4462
+ el._assign = getModelAssigner(vnode);
4463
+ if (el.composing)
4464
+ return;
4465
+ if (document.activeElement === el) {
4466
+ if (lazy) {
4467
+ return;
4468
+ }
4469
+ if (trim && el.value.trim() === value) {
4470
+ return;
4471
+ }
4472
+ if ((number || el.type === "number") && toNumber(el.value) === value) {
4473
+ return;
4474
+ }
4475
+ }
4476
+ const newValue = value == null ? "" : value;
4477
+ if (el.value !== newValue) {
4478
+ el.value = newValue;
4479
+ }
4480
+ }
4481
+ };
4482
+ const vModelSelect = {
4483
+ deep: true,
4484
+ created(el, { value, modifiers: { number } }, vnode) {
4485
+ const isSetModel = isSet(value);
4486
+ addEventListener(el, "change", () => {
4487
+ const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map((o) => number ? toNumber(getValue(o)) : getValue(o));
4488
+ el._assign(el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]);
4489
+ });
4490
+ el._assign = getModelAssigner(vnode);
4491
+ },
4492
+ mounted(el, { value }) {
4493
+ setSelected(el, value);
4494
+ },
4495
+ beforeUpdate(el, _binding, vnode) {
4496
+ el._assign = getModelAssigner(vnode);
4497
+ },
4498
+ updated(el, { value }) {
4499
+ setSelected(el, value);
4500
+ }
4501
+ };
4502
+ function setSelected(el, value) {
4503
+ const isMultiple = el.multiple;
4504
+ if (isMultiple && !isArray(value) && !isSet(value)) {
4505
+ return;
4506
+ }
4507
+ for (let i = 0, l = el.options.length; i < l; i++) {
4508
+ const option = el.options[i];
4509
+ const optionValue = getValue(option);
4510
+ if (isMultiple) {
4511
+ if (isArray(value)) {
4512
+ option.selected = looseIndexOf(value, optionValue) > -1;
4513
+ } else {
4514
+ option.selected = value.has(optionValue);
4515
+ }
4516
+ } else {
4517
+ if (looseEqual(getValue(option), value)) {
4518
+ if (el.selectedIndex !== i)
4519
+ el.selectedIndex = i;
4520
+ return;
4521
+ }
4522
+ }
4523
+ }
4524
+ if (!isMultiple && el.selectedIndex !== -1) {
4525
+ el.selectedIndex = -1;
4526
+ }
4527
+ }
4528
+ function getValue(el) {
4529
+ return "_value" in el ? el._value : el.value;
4530
+ }
4366
4531
  const vShow = {
4367
4532
  beforeMount(el, { value }, { transition }) {
4368
4533
  el._vod = el.style.display === "none" ? "" : el.style.display;
@@ -4436,31 +4601,39 @@ function renderComponent(options) {
4436
4601
  return { vnode, destroy: destroy2 };
4437
4602
  }
4438
4603
  var localConfig = {
4439
- baseUrl: "http://localhost:3001",
4440
- cssUrl: "http://localhost:3001/dist/sdk/",
4441
- url: "http://localhost:3001/dist/iframe/",
4442
- apiUrl: "https://localhost:5001"
4604
+ baseUrl: "",
4605
+ cssUrl: "",
4606
+ url: "",
4607
+ apiUrl: ""
4608
+ };
4609
+ var developmentConfig = {
4610
+ baseUrl: "https://assets.payfurl.com",
4611
+ cssUrl: "https://assets.payfurl.com/v3.1.0/js/",
4612
+ url: "https://assets.payfurl.com/v3.1.0/iframe/index.html",
4613
+ apiUrl: "https://develop-api.payfurl.com"
4443
4614
  };
4444
4615
  var sandboxConfig = {
4445
4616
  baseUrl: "https://assets.payfurl.com",
4446
- cssUrl: "https://assets.payfurl.com/v3.0.3/js/",
4447
- url: "https://assets.payfurl.com/v3.0.3/iframe/index.html",
4617
+ cssUrl: "https://assets.payfurl.com/v3.1.0/js/",
4618
+ url: "https://assets.payfurl.com/v3.1.0/iframe/index.html",
4448
4619
  apiUrl: "https://sandbox-api.payfurl.com"
4449
4620
  };
4450
4621
  var productionConfig = {
4451
4622
  baseUrl: "https://assets.payfurl.com",
4452
- cssUrl: "https://assets.payfurl.com/v3.0.3/js/",
4453
- url: "https://assets.payfurl.com/v3.0.3/iframe/index.html",
4623
+ cssUrl: "https://assets.payfurl.com/v3.1.0/js/",
4624
+ url: "https://assets.payfurl.com/v3.1.0/iframe/index.html",
4454
4625
  apiUrl: "https://api.payfurl.com"
4455
4626
  };
4456
4627
  var Environment;
4457
4628
  (function(Environment2) {
4629
+ Environment2["LOCAL"] = "local";
4458
4630
  Environment2["DEVELOPMENT"] = "development";
4459
4631
  Environment2["SANDBOX"] = "sandbox";
4460
4632
  Environment2["PRODUCTION"] = "production";
4461
4633
  })(Environment || (Environment = {}));
4462
4634
  const config = {
4463
- [Environment.DEVELOPMENT]: localConfig,
4635
+ [Environment.LOCAL]: localConfig,
4636
+ [Environment.DEVELOPMENT]: developmentConfig,
4464
4637
  [Environment.SANDBOX]: sandboxConfig,
4465
4638
  [Environment.PRODUCTION]: productionConfig
4466
4639
  };
@@ -4673,6 +4846,23 @@ var dayjs_min = { exports: {} };
4673
4846
  }, w.en = D[v], w.Ls = D, w.p = {}, w;
4674
4847
  });
4675
4848
  })(dayjs_min);
4849
+ function digitisePhone(phone) {
4850
+ return phone.slice().replaceAll(/[^0-9]/g, "");
4851
+ }
4852
+ function get10DigitsPhone(phone) {
4853
+ let result = digitisePhone(phone);
4854
+ if (result.length > 9) {
4855
+ result = result.slice(result.length - 9);
4856
+ }
4857
+ return "0" + result;
4858
+ }
4859
+ function checkPhone(phone) {
4860
+ const normalisedPhone = digitisePhone(phone);
4861
+ return normalisedPhone.search(/^0[0-9]{9}$/) > -1 || normalisedPhone.search(/^61[0-9]{9}$/) > -1;
4862
+ }
4863
+ function checkEmail(email) {
4864
+ return email.search(/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/) > -1;
4865
+ }
4676
4866
  function checkEmpty(value) {
4677
4867
  if (!value)
4678
4868
  return false;
@@ -4692,6 +4882,21 @@ function validateInput(value, validator, errorText, failureCallback) {
4692
4882
  failureCallback({ error: errorText });
4693
4883
  }
4694
4884
  }
4885
+ function checkABN(abn) {
4886
+ const weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19];
4887
+ if (abn.length !== 11)
4888
+ return false;
4889
+ if (abn.search(/\D/) > -1)
4890
+ return false;
4891
+ let sum = 0;
4892
+ let weight = 0;
4893
+ for (let i = 0; i <= weights.length - 1; i++) {
4894
+ weight = weights[i];
4895
+ const digit = parseInt(abn[i], 10) - (i ? 0 : 1);
4896
+ sum += weight * digit;
4897
+ }
4898
+ return sum % 89 === 0;
4899
+ }
4695
4900
  var Error_vue_vue_type_style_index_0_lang = "";
4696
4901
  var Error_vue_vue_type_style_index_1_scoped_true_lang = "";
4697
4902
  var _export_sfc = (sfc, props) => {
@@ -4701,8 +4906,8 @@ var _export_sfc = (sfc, props) => {
4701
4906
  }
4702
4907
  return target;
4703
4908
  };
4704
- const _hoisted_1$8 = { class: "message" };
4705
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
4909
+ const _hoisted_1$b = { class: "message" };
4910
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4706
4911
  props: {
4707
4912
  error: null
4708
4913
  },
@@ -4710,13 +4915,13 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4710
4915
  const props = __props;
4711
4916
  const error = ref(props.error);
4712
4917
  return (_ctx, _cache) => {
4713
- return openBlock(), createElementBlock("div", _hoisted_1$8, toDisplayString(error.value), 1);
4918
+ return openBlock(), createElementBlock("div", _hoisted_1$b, toDisplayString(error.value), 1);
4714
4919
  };
4715
4920
  }
4716
4921
  });
4717
- var Error2 = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-78588f23"]]);
4922
+ var Error2 = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-78588f23"]]);
4718
4923
  var PaypalIcon_vue_vue_type_style_index_0_scoped_true_lang = "";
4719
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4924
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
4720
4925
  props: {
4721
4926
  size: null,
4722
4927
  grayscale: { type: Boolean }
@@ -4754,16 +4959,16 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4754
4959
  };
4755
4960
  }
4756
4961
  });
4757
- var PaypalIcon = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-6c3f4e5e"]]);
4962
+ var PaypalIcon = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-6c3f4e5e"]]);
4758
4963
  var CreditCardIcon_vue_vue_type_style_index_0_scoped_true_lang = "";
4759
- const _withScopeId$3 = (n) => (pushScopeId("data-v-09c4ea7e"), n = n(), popScopeId(), n);
4760
- const _hoisted_1$7 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ createBaseVNode("path", { d: "M1188.420307 68.911452c16.92562 0 32.642267 14.507674 32.642267 32.642267v822.101535c0 16.92562-14.507674 32.642267-32.642267 32.642267h-1088.075561c-16.92562 0-32.642267-14.507674-32.642267-32.642267v-822.101535c0-16.92562 14.507674-32.642267 32.642267-32.642267h1088.075561m0-68.911452h-1088.075561C44.731995 0 0 45.940968 0 100.344746v822.101535c0 55.612751 44.731995 100.344746 100.344746 100.344746h1088.075561c55.612751 0 100.344746-44.731995 100.344746-100.344746v-822.101535c1.208973-54.403778-44.731995-100.344746-100.344746-100.344746z" }, null, -1));
4761
- const _hoisted_2$7 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ createBaseVNode("path", { d: "M41.105077 252.675325h1221.062574v258.720189H41.105077zM177.719008 778.578512h174.09209v71.329398H177.719008zM432.812279 778.578512h259.929161v71.329398H432.812279z" }, null, -1));
4762
- const _hoisted_3$4 = [
4763
- _hoisted_1$7,
4764
- _hoisted_2$7
4964
+ const _withScopeId$5 = (n) => (pushScopeId("data-v-09c4ea7e"), n = n(), popScopeId(), n);
4965
+ const _hoisted_1$a = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ createBaseVNode("path", { d: "M1188.420307 68.911452c16.92562 0 32.642267 14.507674 32.642267 32.642267v822.101535c0 16.92562-14.507674 32.642267-32.642267 32.642267h-1088.075561c-16.92562 0-32.642267-14.507674-32.642267-32.642267v-822.101535c0-16.92562 14.507674-32.642267 32.642267-32.642267h1088.075561m0-68.911452h-1088.075561C44.731995 0 0 45.940968 0 100.344746v822.101535c0 55.612751 44.731995 100.344746 100.344746 100.344746h1088.075561c55.612751 0 100.344746-44.731995 100.344746-100.344746v-822.101535c1.208973-54.403778-44.731995-100.344746-100.344746-100.344746z" }, null, -1));
4966
+ const _hoisted_2$9 = /* @__PURE__ */ _withScopeId$5(() => /* @__PURE__ */ createBaseVNode("path", { d: "M41.105077 252.675325h1221.062574v258.720189H41.105077zM177.719008 778.578512h174.09209v71.329398H177.719008zM432.812279 778.578512h259.929161v71.329398H432.812279z" }, null, -1));
4967
+ const _hoisted_3$5 = [
4968
+ _hoisted_1$a,
4969
+ _hoisted_2$9
4765
4970
  ];
4766
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
4971
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
4767
4972
  props: {
4768
4973
  size: null,
4769
4974
  grayscale: { type: Boolean },
@@ -4781,18 +4986,45 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
4781
4986
  xmlns: "http://www.w3.org/2000/svg",
4782
4987
  style: normalizeStyle([{ "width": "1.2587890625em", "height": "1em", "vertical-align": "middle", "overflow": "hidden" }, unref(style)]),
4783
4988
  viewBox: "0 0 1289 1024"
4784
- }, _hoisted_3$4, 4);
4989
+ }, _hoisted_3$5, 4);
4990
+ };
4991
+ }
4992
+ });
4993
+ var CreditCardIcon = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-09c4ea7e"]]);
4994
+ var PayToIcon_vue_vue_type_style_index_0_scoped_true_lang = "";
4995
+ const _hoisted_1$9 = ["fill"];
4996
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4997
+ props: {
4998
+ size: null,
4999
+ grayscale: { type: Boolean }
5000
+ },
5001
+ setup(__props) {
5002
+ const props = __props;
5003
+ const color = props.grayscale ? "#000" : "#000";
5004
+ const style = `--size: ${props.size}px`;
5005
+ return (_ctx, _cache) => {
5006
+ return openBlock(), createElementBlock("svg", {
5007
+ id: "payto-icon",
5008
+ viewBox: "0 0 120 57",
5009
+ xmlns: "http://www.w3.org/2000/svg",
5010
+ style
5011
+ }, [
5012
+ createBaseVNode("path", {
5013
+ d: "m8.285 27.63c.8 0 1.562-.06 2.285-.176a6.262 6.262 0 0 0 1.937-.624 3.529 3.529 0 0 0 1.354-1.227c.335-.52.502-1.194.502-2.025s-.169-1.463-.502-1.97a3.492 3.492 0 0 0 -1.337-1.187c-.555-.287-1.186-.473-1.897-.565a17.32 17.32 0 0 0 -2.188-.136h-3.56v7.91zm-8.285-12.04h8.945c1.573 0 2.994.144 4.258.429 1.265.288 2.349.754 3.254 1.404.902.648 1.599 1.479 2.092 2.493.488 1.012.736 2.235.736 3.663 0 1.533-.283 2.818-.853 3.858a6.956 6.956 0 0 1 -2.303 2.512c-.968.637-2.098 1.097-3.388 1.383-1.29.285-2.66.43-4.103.43h-3.76v11.415h-4.878zm32.679 19.054h-1.043c-.751 0-1.538.034-2.364.098s-1.588.207-2.283.427c-.697.223-1.279.534-1.742.937-.464.403-.696.954-.696 1.655 0 .442.095.812.29 1.11.195.3.446.54.755.721.31.183.659.311 1.045.39a5.94 5.94 0 0 0 1.161.117c1.6 0 2.813-.427 3.639-1.287.826-.857 1.238-2.026 1.238-3.505zm.078 6.156h-.116c-.466.832-1.213 1.516-2.247 2.047-1.034.532-2.206.8-3.523.8-.749 0-1.53-.099-2.343-.293a6.902 6.902 0 0 1 -2.245-.972 5.624 5.624 0 0 1 -1.705-1.793c-.45-.74-.676-1.656-.676-2.745 0-1.404.394-2.52 1.18-3.351.787-.831 1.8-1.468 3.04-1.91 1.24-.44 2.614-.732 4.124-.875a47.58 47.58 0 0 1 4.433-.215v-.47c0-1.168-.42-2.031-1.259-2.589s-1.839-.839-3-.839c-.981 0-1.923.21-2.826.624-.903.417-1.652.924-2.246 1.521l-2.4-2.844a10.478 10.478 0 0 1 3.659-2.222 12.448 12.448 0 0 1 4.203-.74c1.651 0 3.013.233 4.084.7 1.072.468 1.916 1.079 2.536 1.83a6.571 6.571 0 0 1 1.298 2.534c.245.936.369 1.869.369 2.806v11.376h-4.338v-2.377l-.002-.004zm5.719-16.325h5.15l5.189 13.599h.078l4.607-13.6h4.84l-8.791 22.717a16.433 16.433 0 0 1 -1.083 2.278 6.33 6.33 0 0 1 -1.395 1.676 5.56 5.56 0 0 1 -1.916 1.032c-.736.234-1.62.351-2.654.351-.386 0-.78-.019-1.182-.058a8.113 8.113 0 0 1 -1.219-.215l.386-4.052c.31.104.614.175.91.215s.575.058.834.058c.49 0 .902-.058 1.238-.175.337-.117.62-.298.852-.545.232-.248.438-.552.618-.917.181-.364.376-.792.582-1.286l.93-2.376-7.977-18.702zm42.808 14.279c.893 0 2.072-.328 2.536-.49v3.735c-.468.183-1.478.535-2.536.535-3.691 0-6.695-3.064-6.697-6.831v-11.228h-4.225v-3.675h4.225v-4.66h3.665v4.66h10a13.83 13.83 0 0 0 -3.625 3.675h-6.375v11.228c0 1.688 1.39 3.05 3.032 3.05zm15 3.78c-6.038 0-10.801-4.79-10.801-10.866s4.845-10.868 10.8-10.868h12.183l.004-3.376 6.267 5.245-6.278 5.256.004-3.45h-12.337c-3.775 0-6.897 3.396-6.897 7.193s3.11 7.13 7.053 7.13c3.942 0 7.053-3.163 7.053-7.13 0-1.755-.62-3.377-1.386-4.553h4.139c.65 1.402.993 3.006.993 4.553 0 6.076-4.761 10.866-10.801 10.866zm10.909-42.534h-31.031c-7.074 0-12.807 5.77-12.807 12.886v31.226c0 7.117 5.735 12.886 12.807 12.886h31.031c7.074 0 12.806-5.77 12.806-12.886v-31.226c0-7.116-5.734-12.886-12.806-12.886z",
5014
+ fill: unref(color)
5015
+ }, null, 8, _hoisted_1$9)
5016
+ ]);
4785
5017
  };
4786
5018
  }
4787
5019
  });
4788
- var CreditCardIcon = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-09c4ea7e"]]);
5020
+ var PayToIcon = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-45e10a6c"]]);
4789
5021
  var Combined_vue_vue_type_style_index_0_scoped_true_lang = "";
4790
- const _hoisted_1$6 = { class: "combined-container" };
4791
- const _hoisted_2$6 = { class: "combined-tabs" };
4792
- const _hoisted_3$3 = ["onClick"];
4793
- const _hoisted_4$2 = { class: "combined-components" };
4794
- const _hoisted_5$2 = ["id"];
4795
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
5022
+ const _hoisted_1$8 = { class: "combined-container" };
5023
+ const _hoisted_2$8 = { class: "combined-tabs" };
5024
+ const _hoisted_3$4 = ["id", "onClick"];
5025
+ const _hoisted_4$3 = { class: "combined-components" };
5026
+ const _hoisted_5$3 = ["id"];
5027
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4796
5028
  props: {
4797
5029
  elements: null
4798
5030
  },
@@ -4804,6 +5036,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4804
5036
  activeIndex.value = index;
4805
5037
  setTimeout(() => {
4806
5038
  onRender(index);
5039
+ props.elements[index].activate();
4807
5040
  }, 200);
4808
5041
  }
4809
5042
  function getColor(index) {
@@ -4826,13 +5059,15 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4826
5059
  props.elements.forEach((_, index) => {
4827
5060
  onRender(index);
4828
5061
  });
5062
+ setActive(0);
4829
5063
  });
4830
5064
  return (_ctx, _cache) => {
4831
- return openBlock(), createElementBlock("div", _hoisted_1$6, [
4832
- createBaseVNode("div", _hoisted_2$6, [
5065
+ return openBlock(), createElementBlock("div", _hoisted_1$8, [
5066
+ createBaseVNode("div", _hoisted_2$8, [
4833
5067
  (openBlock(true), createElementBlock(Fragment, null, renderList(props.elements, (element, index) => {
4834
5068
  return openBlock(), createElementBlock("div", {
4835
5069
  class: normalizeClass(["combined-tab", index === activeIndex.value ? "active" : ""]),
5070
+ id: element.id || `combined-tab${index}`,
4836
5071
  onClick: ($event) => setActive(index)
4837
5072
  }, [
4838
5073
  element.icon ? (openBlock(), createBlock(resolveDynamicComponent(element.icon), {
@@ -4842,16 +5077,16 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4842
5077
  grayscale: ""
4843
5078
  }, null, 8, ["color"])) : createCommentVNode("", true),
4844
5079
  createTextVNode(" " + toDisplayString(element.title), 1)
4845
- ], 10, _hoisted_3$3);
5080
+ ], 10, _hoisted_3$4);
4846
5081
  }), 256))
4847
5082
  ]),
4848
- createBaseVNode("div", _hoisted_4$2, [
5083
+ createBaseVNode("div", _hoisted_4$3, [
4849
5084
  (openBlock(true), createElementBlock(Fragment, null, renderList(props.elements, (_, index) => {
4850
5085
  return withDirectives((openBlock(), createElementBlock("div", {
4851
5086
  key: `container-component${index}`,
4852
5087
  class: "container-component",
4853
5088
  id: `container-component${index}`
4854
- }, null, 8, _hoisted_5$2)), [
5089
+ }, null, 8, _hoisted_5$3)), [
4855
5090
  [vShow, getVisibility(index)]
4856
5091
  ]);
4857
5092
  }), 128))
@@ -4860,7 +5095,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4860
5095
  };
4861
5096
  }
4862
5097
  });
4863
- var Combined = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-0a65580e"]]);
5098
+ var Combined = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-022194b8"]]);
4864
5099
  class HttpInvoker {
4865
5100
  constructor(publicKey) {
4866
5101
  __publicField(this, "publicKey", "");
@@ -4901,9 +5136,9 @@ function getEmptyThreeDSData() {
4901
5136
  }
4902
5137
  var Success_vue_vue_type_style_index_0_lang = "";
4903
5138
  var Success_vue_vue_type_style_index_1_scoped_true_lang = "";
4904
- const _hoisted_1$5 = { class: "message" };
4905
- const _hoisted_2$5 = { key: 0 };
4906
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
5139
+ const _hoisted_1$7 = { class: "message" };
5140
+ const _hoisted_2$7 = { key: 0 };
5141
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
4907
5142
  props: {
4908
5143
  message: null,
4909
5144
  token: null
@@ -4912,13 +5147,13 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
4912
5147
  const props = __props;
4913
5148
  return (_ctx, _cache) => {
4914
5149
  return openBlock(), createElementBlock(Fragment, null, [
4915
- createBaseVNode("div", _hoisted_1$5, toDisplayString(props.message), 1),
4916
- props.token ? (openBlock(), createElementBlock("div", _hoisted_2$5, "TokenId = " + toDisplayString(props.token), 1)) : createCommentVNode("", true)
5150
+ createBaseVNode("div", _hoisted_1$7, toDisplayString(props.message), 1),
5151
+ props.token ? (openBlock(), createElementBlock("div", _hoisted_2$7, "TokenId = " + toDisplayString(props.token), 1)) : createCommentVNode("", true)
4917
5152
  ], 64);
4918
5153
  };
4919
5154
  }
4920
5155
  });
4921
- var Success = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-0c5d4794"]]);
5156
+ var Success = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-0c5d4794"]]);
4922
5157
  function showError(container, message) {
4923
5158
  renderComponent({
4924
5159
  el: container,
@@ -5208,30 +5443,30 @@ function getScreenColorDepth() {
5208
5443
  return currentColourDepth;
5209
5444
  }
5210
5445
  var CloseIcon_vue_vue_type_style_index_0_scoped_true_lang = "";
5211
- const _sfc_main$5 = {};
5212
- const _withScopeId$2 = (n) => (pushScopeId("data-v-ad18c358"), n = n(), popScopeId(), n);
5213
- const _hoisted_1$4 = {
5446
+ const _sfc_main$7 = {};
5447
+ const _withScopeId$4 = (n) => (pushScopeId("data-v-ad18c358"), n = n(), popScopeId(), n);
5448
+ const _hoisted_1$6 = {
5214
5449
  xmlns: "http://www.w3.org/2000/svg",
5215
5450
  viewBox: "0 0 48 48"
5216
5451
  };
5217
- const _hoisted_2$4 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ createBaseVNode("polygon", { points: "39 10.44 37.56 9 24 22.56 10.44 9 9 10.44 22.56 24 9 37.56 10.44 39 24 25.44 37.56 39 39 37.56 25.44 24 39 10.44" }, null, -1));
5218
- const _hoisted_3$2 = [
5219
- _hoisted_2$4
5452
+ const _hoisted_2$6 = /* @__PURE__ */ _withScopeId$4(() => /* @__PURE__ */ createBaseVNode("polygon", { points: "39 10.44 37.56 9 24 22.56 10.44 9 9 10.44 22.56 24 9 37.56 10.44 39 24 25.44 37.56 39 39 37.56 25.44 24 39 10.44" }, null, -1));
5453
+ const _hoisted_3$3 = [
5454
+ _hoisted_2$6
5220
5455
  ];
5221
5456
  function _sfc_render(_ctx, _cache) {
5222
- return openBlock(), createElementBlock("svg", _hoisted_1$4, _hoisted_3$2);
5457
+ return openBlock(), createElementBlock("svg", _hoisted_1$6, _hoisted_3$3);
5223
5458
  }
5224
- var CloseIcon = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render], ["__scopeId", "data-v-ad18c358"]]);
5459
+ var CloseIcon = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render], ["__scopeId", "data-v-ad18c358"]]);
5225
5460
  var ThreeDsChallenge_vue_vue_type_style_index_0_lang = "";
5226
5461
  var ThreeDsChallenge_vue_vue_type_style_index_1_scoped_true_lang = "";
5227
- const _withScopeId$1 = (n) => (pushScopeId("data-v-7bf4e048"), n = n(), popScopeId(), n);
5228
- const _hoisted_1$3 = { class: "mask" };
5229
- const _hoisted_2$3 = { class: "wrapper" };
5230
- const _hoisted_3$1 = { class: "container" };
5231
- const _hoisted_4$1 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("iframe", { name: "ThreeDsChallengeIFrame" }, null, -1));
5232
- const _hoisted_5$1 = ["action"];
5233
- const _hoisted_6$1 = ["value"];
5234
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
5462
+ const _withScopeId$3 = (n) => (pushScopeId("data-v-7bf4e048"), n = n(), popScopeId(), n);
5463
+ const _hoisted_1$5 = { class: "mask" };
5464
+ const _hoisted_2$5 = { class: "wrapper" };
5465
+ const _hoisted_3$2 = { class: "container" };
5466
+ const _hoisted_4$2 = /* @__PURE__ */ _withScopeId$3(() => /* @__PURE__ */ createBaseVNode("iframe", { name: "ThreeDsChallengeIFrame" }, null, -1));
5467
+ const _hoisted_5$2 = ["action"];
5468
+ const _hoisted_6$2 = ["value"];
5469
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
5235
5470
  props: {
5236
5471
  threeDSServerTransID: null,
5237
5472
  acsTransID: null,
@@ -5254,13 +5489,13 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
5254
5489
  (_a = form.value) == null ? void 0 : _a.submit();
5255
5490
  });
5256
5491
  return (_ctx, _cache) => {
5257
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
5258
- createBaseVNode("div", _hoisted_2$3, [
5259
- createBaseVNode("div", _hoisted_3$1, [
5492
+ return openBlock(), createElementBlock("div", _hoisted_1$5, [
5493
+ createBaseVNode("div", _hoisted_2$5, [
5494
+ createBaseVNode("div", _hoisted_3$2, [
5260
5495
  createVNode(CloseIcon, {
5261
5496
  onClick: _cache[0] || (_cache[0] = ($event) => emit("close"))
5262
5497
  }),
5263
- _hoisted_4$1,
5498
+ _hoisted_4$2,
5264
5499
  createBaseVNode("form", {
5265
5500
  action: props.formAction,
5266
5501
  target: "ThreeDsChallengeIFrame",
@@ -5272,33 +5507,33 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
5272
5507
  type: "hidden",
5273
5508
  name: "creq",
5274
5509
  value: unref(value)
5275
- }, null, 8, _hoisted_6$1)
5276
- ], 8, _hoisted_5$1)
5510
+ }, null, 8, _hoisted_6$2)
5511
+ ], 8, _hoisted_5$2)
5277
5512
  ])
5278
5513
  ])
5279
5514
  ]);
5280
5515
  };
5281
5516
  }
5282
5517
  });
5283
- var ThreeDsChallenge = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-7bf4e048"]]);
5518
+ var ThreeDsChallenge = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-7bf4e048"]]);
5284
5519
  var Spinner_vue_vue_type_style_index_0_scoped_true_lang = "";
5285
- const _withScopeId = (n) => (pushScopeId("data-v-4280055c"), n = n(), popScopeId(), n);
5286
- const _hoisted_1$2 = {
5520
+ const _withScopeId$2 = (n) => (pushScopeId("data-v-4280055c"), n = n(), popScopeId(), n);
5521
+ const _hoisted_1$4 = {
5287
5522
  x1: "8.042%",
5288
5523
  y1: "0%",
5289
5524
  x2: "65.682%",
5290
5525
  y2: "23.865%",
5291
5526
  id: "a"
5292
5527
  };
5293
- const _hoisted_2$2 = ["stop-color"];
5294
- const _hoisted_3 = ["stop-color"];
5295
- const _hoisted_4 = ["stop-color"];
5296
- const _hoisted_5 = {
5528
+ const _hoisted_2$4 = ["stop-color"];
5529
+ const _hoisted_3$1 = ["stop-color"];
5530
+ const _hoisted_4$1 = ["stop-color"];
5531
+ const _hoisted_5$1 = {
5297
5532
  fill: "none",
5298
5533
  "fill-rule": "evenodd"
5299
5534
  };
5300
- const _hoisted_6 = { transform: "translate(1 1)" };
5301
- const _hoisted_7 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBaseVNode("path", {
5535
+ const _hoisted_6$1 = { transform: "translate(1 1)" };
5536
+ const _hoisted_7$1 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ createBaseVNode("path", {
5302
5537
  d: "M36 18c0-9.94-8.06-18-18-18",
5303
5538
  id: "Oval-2",
5304
5539
  stroke: "url(#a)",
@@ -5313,8 +5548,8 @@ const _hoisted_7 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBase
5313
5548
  repeatCount: "indefinite"
5314
5549
  })
5315
5550
  ], -1));
5316
- const _hoisted_8 = ["fill"];
5317
- const _hoisted_9 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBaseVNode("animateTransform", {
5551
+ const _hoisted_8$1 = ["fill"];
5552
+ const _hoisted_9$1 = /* @__PURE__ */ _withScopeId$2(() => /* @__PURE__ */ createBaseVNode("animateTransform", {
5318
5553
  attributeName: "transform",
5319
5554
  type: "rotate",
5320
5555
  from: "0 18 18",
@@ -5322,10 +5557,10 @@ const _hoisted_9 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBase
5322
5557
  dur: "0.9s",
5323
5558
  repeatCount: "indefinite"
5324
5559
  }, null, -1));
5325
- const _hoisted_10 = [
5326
- _hoisted_9
5560
+ const _hoisted_10$1 = [
5561
+ _hoisted_9$1
5327
5562
  ];
5328
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
5563
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
5329
5564
  props: {
5330
5565
  color: { default: "#1a82b7" },
5331
5566
  size: { default: 50 }
@@ -5345,55 +5580,58 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
5345
5580
  style: normalizeStyle(unref(style))
5346
5581
  }, [
5347
5582
  createBaseVNode("defs", null, [
5348
- createBaseVNode("linearGradient", _hoisted_1$2, [
5583
+ createBaseVNode("linearGradient", _hoisted_1$4, [
5349
5584
  createBaseVNode("stop", {
5350
5585
  "stop-color": color.value,
5351
5586
  "stop-opacity": "0",
5352
5587
  offset: "0%"
5353
- }, null, 8, _hoisted_2$2),
5588
+ }, null, 8, _hoisted_2$4),
5354
5589
  createBaseVNode("stop", {
5355
5590
  "stop-color": color.value,
5356
5591
  "stop-opacity": ".631",
5357
5592
  offset: "63.146%"
5358
- }, null, 8, _hoisted_3),
5593
+ }, null, 8, _hoisted_3$1),
5359
5594
  createBaseVNode("stop", {
5360
5595
  "stop-color": color.value,
5361
5596
  offset: "100%"
5362
- }, null, 8, _hoisted_4)
5597
+ }, null, 8, _hoisted_4$1)
5363
5598
  ])
5364
5599
  ]),
5365
- createBaseVNode("g", _hoisted_5, [
5366
- createBaseVNode("g", _hoisted_6, [
5367
- _hoisted_7,
5600
+ createBaseVNode("g", _hoisted_5$1, [
5601
+ createBaseVNode("g", _hoisted_6$1, [
5602
+ _hoisted_7$1,
5368
5603
  createBaseVNode("circle", {
5369
5604
  fill: color.value,
5370
5605
  cx: "36",
5371
5606
  cy: "18",
5372
5607
  r: "1"
5373
- }, _hoisted_10, 8, _hoisted_8)
5608
+ }, _hoisted_10$1, 8, _hoisted_8$1)
5374
5609
  ])
5375
5610
  ])
5376
5611
  ], 4);
5377
5612
  };
5378
5613
  }
5379
5614
  });
5380
- var Spinner = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-4280055c"]]);
5615
+ var Spinner = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-4280055c"]]);
5381
5616
  let destroy = () => {
5382
5617
  };
5383
5618
  function showSpinner(container) {
5619
+ var _a;
5384
5620
  destroy();
5385
5621
  const iframe = container.getElementsByTagName("iframe");
5386
5622
  if (iframe[0]) {
5387
- iframe[0].style.display = "none";
5623
+ destroy = () => {
5624
+ var _a2;
5625
+ (_a2 = iframe[0].contentWindow) == null ? void 0 : _a2.postMessage({ type: "hide_spinner" });
5626
+ };
5627
+ (_a = iframe[0].contentWindow) == null ? void 0 : _a.postMessage({ type: "show_spinner" });
5628
+ return;
5388
5629
  }
5389
5630
  const res = renderComponent({
5390
5631
  el: container,
5391
5632
  component: Spinner
5392
5633
  });
5393
5634
  destroy = () => {
5394
- if (iframe[0]) {
5395
- iframe[0].style.display = "visible";
5396
- }
5397
5635
  res.destroy();
5398
5636
  };
5399
5637
  }
@@ -5676,35 +5914,37 @@ class ThreeDsProcessor {
5676
5914
  }
5677
5915
  var PaypalLoading_vue_vue_type_style_index_0_lang = "";
5678
5916
  var PaypalLoading_vue_vue_type_style_index_1_scoped_true_lang = "";
5679
- const _hoisted_1$1 = { class: "loading" };
5680
- const _hoisted_2$1 = /* @__PURE__ */ createTextVNode(" Paypal ");
5681
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5917
+ const _hoisted_1$3 = { class: "loading" };
5918
+ const _hoisted_2$3 = /* @__PURE__ */ createTextVNode(" Paypal ");
5919
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
5682
5920
  setup(__props) {
5683
5921
  return (_ctx, _cache) => {
5684
- return openBlock(), createElementBlock("div", _hoisted_1$1, [
5922
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
5685
5923
  createVNode(PaypalIcon, {
5686
5924
  size: 20,
5687
5925
  grayscale: ""
5688
5926
  }),
5689
- _hoisted_2$1,
5927
+ _hoisted_2$3,
5690
5928
  createVNode(Spinner, { size: 20 })
5691
5929
  ]);
5692
5930
  };
5693
5931
  }
5694
5932
  });
5695
- var PaypalLoading = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-ed95d8b0"]]);
5696
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
5933
+ var PaypalLoading = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-ed95d8b0"]]);
5934
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
5697
5935
  props: {
5698
5936
  el: null,
5937
+ form: null,
5699
5938
  clientId: null,
5700
5939
  currency: null,
5701
5940
  enablePayIn4: { type: Boolean },
5702
5941
  buttonStyle: null,
5703
5942
  checkoutId: null
5704
5943
  },
5705
- emits: ["approve"],
5944
+ emits: ["approve", "submit"],
5706
5945
  setup(__props, { emit }) {
5707
5946
  const props = __props;
5947
+ const active = ref(true);
5708
5948
  const src = `https://www.paypal.com/sdk/js?client-id=${props.clientId}&currency=${props.currency.toUpperCase()}&disable-funding=card${props.enablePayIn4 ? "&enable-funding=paylater" : ""}`;
5709
5949
  function onLoad() {
5710
5950
  window.paypal.Buttons({
@@ -5719,7 +5959,33 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
5719
5959
  }
5720
5960
  }).render(props.el);
5721
5961
  }
5962
+ function messageHandler(event) {
5963
+ var _a;
5964
+ if (!((_a = event == null ? void 0 : event.data) == null ? void 0 : _a.status))
5965
+ return;
5966
+ if (event.data.status === "submit-form") {
5967
+ event.stopPropagation();
5968
+ if (!props.form)
5969
+ return;
5970
+ const input = props.form.querySelector('input[name="token"]');
5971
+ if (input == null ? void 0 : input.value) {
5972
+ props.form.submit();
5973
+ return;
5974
+ }
5975
+ emit("submit");
5976
+ }
5977
+ if (event.data.status === "activate" && event.data.component === "paypal") {
5978
+ active.value = true;
5979
+ }
5980
+ if (event.data.status === "deactivate" && event.data.component === "paypal") {
5981
+ active.value = false;
5982
+ }
5983
+ }
5984
+ onUnmounted(() => {
5985
+ window.removeEventListener("message", messageHandler);
5986
+ });
5722
5987
  onMounted(() => {
5988
+ window.addEventListener("message", messageHandler);
5723
5989
  window.paypal = null;
5724
5990
  const scriptTag = document.createElement("script");
5725
5991
  scriptTag.src = src;
@@ -5736,6 +6002,7 @@ class PaypalProcessor {
5736
6002
  __publicField(this, "container", document.body);
5737
6003
  __publicField(this, "log");
5738
6004
  __publicField(this, "apiUrl", "");
6005
+ __publicField(this, "form", null);
5739
6006
  __publicField(this, "getPaymentOptions");
5740
6007
  __publicField(this, "failureCallback", null);
5741
6008
  __publicField(this, "successCallback", null);
@@ -5748,20 +6015,21 @@ class PaypalProcessor {
5748
6015
  this.successCallback = config2.onSuccess || null;
5749
6016
  this.httpInvoker = new HttpInvoker(config2.publicKey);
5750
6017
  }
5751
- addPaypal(container, amount, currency, providerId, options) {
6018
+ addPaypal(container, form, amount, currency, providerId, options) {
5752
6019
  this.log("[addPaypal]", { amount, currency, providerId, options });
5753
6020
  this.container = container;
6021
+ this.form = form;
5754
6022
  if (!checkCurrency(currency)) {
5755
6023
  throw new Error2("invalid currency: " + currency);
5756
6024
  }
5757
6025
  if (!checkAmount(amount)) {
5758
6026
  throw new Error2("invalid amount: " + amount);
5759
6027
  }
5760
- const callback = (hasCardProviders, required3dsProvider, providerId2) => {
6028
+ const callback = (hasCardProviders, required3dsProvider, paypalProviderId, payToProviderId) => {
5761
6029
  var _a, _b;
5762
- this.log("[getPaymentOptions][callback]", { hasCardProviders, required3dsProvider, providerId: providerId2 });
5763
- if (!providerId2) {
5764
- throw new Error2("invalid providerId: " + providerId2);
6030
+ this.log("[getPaymentOptions][callback]", { hasCardProviders, required3dsProvider, providerId: paypalProviderId });
6031
+ if (!paypalProviderId) {
6032
+ throw new Error2("invalid providerId: " + paypalProviderId);
5765
6033
  }
5766
6034
  const { destroy: destroy2 } = renderComponent({
5767
6035
  el: this.container,
@@ -5777,7 +6045,7 @@ class PaypalProcessor {
5777
6045
  }
5778
6046
  const url = this.apiUrl + "/payment_method/checkout";
5779
6047
  const data = {
5780
- ProviderId: providerId2,
6048
+ ProviderId: paypalProviderId,
5781
6049
  Amount: amount,
5782
6050
  Currency: currency,
5783
6051
  Options: {
@@ -5803,6 +6071,7 @@ class PaypalProcessor {
5803
6071
  try {
5804
6072
  const decodedData = window.atob(checkoutData.checkoutId);
5805
6073
  data2 = JSON.parse(decodedData);
6074
+ this.log("decodedData", data2);
5806
6075
  } catch (err) {
5807
6076
  this.log("invalid checkoutId", err);
5808
6077
  return;
@@ -5840,9 +6109,10 @@ class PaypalProcessor {
5840
6109
  const checkoutId = data2.CheckoutId;
5841
6110
  renderComponent({
5842
6111
  el: this.container,
5843
- component: _sfc_main$1,
6112
+ component: _sfc_main$3,
5844
6113
  props: {
5845
6114
  el: this.container,
6115
+ form: this.form,
5846
6116
  clientId: data2.AdditionalParameters,
5847
6117
  currency,
5848
6118
  enablePayIn4: Boolean(options.paypalEnablePayIn4),
@@ -5873,21 +6143,22 @@ class PaypalProcessor {
5873
6143
  if (providerId) {
5874
6144
  callback(false, "", providerId);
5875
6145
  } else {
5876
- this.getPaymentOptions(amount, currency, "", callback);
6146
+ this.getPaymentOptions(amount, currency, "", "", callback);
5877
6147
  }
5878
6148
  }
5879
6149
  }
5880
- var Card_vue_vue_type_style_index_0_scoped_true_lang = "";
5881
- const _hoisted_1 = ["src"];
5882
- const _hoisted_2 = {
6150
+ var CardForm_vue_vue_type_style_index_0_scoped_true_lang = "";
6151
+ const _hoisted_1$2 = ["src"];
6152
+ const _hoisted_2$2 = {
5883
6153
  key: 0,
5884
6154
  id: "threeDs"
5885
6155
  };
5886
- const _sfc_main = /* @__PURE__ */ defineComponent({
6156
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5887
6157
  props: {
5888
6158
  debug: { type: Boolean },
5889
6159
  apiUrl: null,
5890
6160
  iframeSrc: null,
6161
+ form: null,
5891
6162
  publicKey: null,
5892
6163
  providerId: null,
5893
6164
  amount: null,
@@ -5904,6 +6175,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5904
6175
  const threeDSEnabled = ref(props.threeDSEnabled);
5905
6176
  ref(props.showSubmitButton);
5906
6177
  const ready = ref(false);
6178
+ const active = ref(true);
5907
6179
  function messageHandler(event) {
5908
6180
  var _a, _b;
5909
6181
  if (!((_a = event == null ? void 0 : event.data) == null ? void 0 : _a.status))
@@ -5912,10 +6184,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5912
6184
  event.stopPropagation();
5913
6185
  adjustIFrameHeight(((_b = event.data.message) == null ? void 0 : _b.height) || 0);
5914
6186
  }
5915
- if (event.data.status === "submit-card-form") {
6187
+ if (event.data.status === "submit-form") {
6188
+ if (!props.form)
6189
+ return;
6190
+ if (!active.value)
6191
+ return;
5916
6192
  event.stopPropagation();
6193
+ const input = props.form.querySelector('input[name="token"]');
6194
+ if (input == null ? void 0 : input.value) {
6195
+ props.form.submit();
6196
+ return;
6197
+ }
5917
6198
  emit("submit");
5918
6199
  }
6200
+ if (event.data.status === "activate" && event.data.component === "card") {
6201
+ active.value = true;
6202
+ }
6203
+ if (event.data.status === "deactivate" && event.data.component === "card") {
6204
+ active.value = false;
6205
+ }
5919
6206
  }
5920
6207
  onUnmounted(() => {
5921
6208
  window.removeEventListener("message", messageHandler);
@@ -5938,22 +6225,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5938
6225
  src: src.value,
5939
6226
  onLoad: onload,
5940
6227
  ref_key: "iframe",
5941
- ref: iframe
5942
- }, null, 40, _hoisted_1),
5943
- threeDSEnabled.value ? (openBlock(), createElementBlock("div", _hoisted_2)) : createCommentVNode("", true)
6228
+ ref: iframe,
6229
+ id: "payfurl-card-iframe"
6230
+ }, null, 40, _hoisted_1$2),
6231
+ threeDSEnabled.value ? (openBlock(), createElementBlock("div", _hoisted_2$2)) : createCommentVNode("", true)
5944
6232
  ], 64);
5945
6233
  };
5946
6234
  }
5947
6235
  });
5948
- var Card = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3df6a9bb"]]);
6236
+ var CardForm = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-2a78dd48"]]);
5949
6237
  class CardProcessor {
5950
6238
  constructor(log, config2) {
5951
6239
  __publicField(this, "container", document.body);
5952
6240
  __publicField(this, "threeDsContainer", document.body);
5953
6241
  __publicField(this, "iframe", null);
6242
+ __publicField(this, "form", null);
5954
6243
  __publicField(this, "log");
5955
6244
  __publicField(this, "debug", false);
5956
- __publicField(this, "environment", Environment.DEVELOPMENT);
6245
+ __publicField(this, "environment", Environment.LOCAL);
5957
6246
  __publicField(this, "apiUrl", "");
5958
6247
  __publicField(this, "url", "");
5959
6248
  __publicField(this, "publicKey", "");
@@ -5966,7 +6255,7 @@ class CardProcessor {
5966
6255
  __publicField(this, "httpInvoker");
5967
6256
  this.log = log;
5968
6257
  this.debug = config2.debug;
5969
- this.environment = config2.environment || Environment.DEVELOPMENT;
6258
+ this.environment = config2.environment || Environment.LOCAL;
5970
6259
  this.url = config2.url;
5971
6260
  this.apiUrl = config2.apiUrl;
5972
6261
  this.publicKey = config2.publicKey;
@@ -5979,7 +6268,7 @@ class CardProcessor {
5979
6268
  addThreeDsProcessor(threeDsProcessor) {
5980
6269
  this.threeDsProcessor = threeDsProcessor;
5981
6270
  }
5982
- addCard(container, providerId, amount, currency, options) {
6271
+ addCard(container, form, providerId, amount, currency, options) {
5983
6272
  this.log("[addCard]", { providerId, amount, currency, options });
5984
6273
  if (options == null ? void 0 : options.threeDSEnabled) {
5985
6274
  validateInput(amount, checkEmpty, "missing or invalid amount option", this.failureCallback);
@@ -5987,14 +6276,16 @@ class CardProcessor {
5987
6276
  this.threeDSEnabled = true;
5988
6277
  }
5989
6278
  this.container = container || document.body;
6279
+ this.form = form;
5990
6280
  this.email = (options == null ? void 0 : options.threeDSEmail) || "";
5991
6281
  renderComponent({
5992
6282
  el: this.container,
5993
- component: Card,
6283
+ component: CardForm,
5994
6284
  props: {
5995
6285
  debug: this.debug,
5996
6286
  apiUrl: this.apiUrl,
5997
6287
  iframeSrc: this.url,
6288
+ form: this.form,
5998
6289
  publicKey: this.publicKey,
5999
6290
  providerId,
6000
6291
  amount,
@@ -6036,6 +6327,7 @@ class CardProcessor {
6036
6327
  return;
6037
6328
  this.log("[sdk][cardProcessor]: message received", event.data);
6038
6329
  if (event.data.status === "failure") {
6330
+ hideSpinner(this.container);
6039
6331
  this.log("unable to tokenise payment information", event.data);
6040
6332
  showError(this.container, "Unable to tokenise payment information");
6041
6333
  (_b = this.failureCallback) == null ? void 0 : _b.call(this, {
@@ -6044,6 +6336,7 @@ class CardProcessor {
6044
6336
  return;
6045
6337
  }
6046
6338
  if (event.data.status === "success") {
6339
+ hideSpinner(this.container);
6047
6340
  event.stopPropagation();
6048
6341
  this.iframe = null;
6049
6342
  showSuccess(this.container, "Success");
@@ -6072,11 +6365,14 @@ class CardProcessor {
6072
6365
  var _a;
6073
6366
  this.log("submit card form");
6074
6367
  if (!this.threeDSEnabled) {
6075
- this.tokenise(null);
6368
+ showSpinner(this.container);
6369
+ setTimeout(() => {
6370
+ this.tokenise(null);
6371
+ }, 500);
6076
6372
  return;
6077
6373
  }
6078
6374
  this.threeDsContainer = document.getElementById("threeDs") || document.body;
6079
- (_a = this.threeDsProcessor) == null ? void 0 : _a.requestThreeDs(this.threeDsContainer, this.iframe, this.environment === Environment.DEVELOPMENT || this.environment === Environment.SANDBOX, (postAuthData) => {
6375
+ (_a = this.threeDsProcessor) == null ? void 0 : _a.requestThreeDs(this.threeDsContainer, this.iframe, this.environment === Environment.LOCAL || this.environment === Environment.DEVELOPMENT || this.environment === Environment.SANDBOX, (postAuthData) => {
6080
6376
  this.log("threeDs, postAuthData", postAuthData);
6081
6377
  this.tokenise(postAuthData.threeDSServerTransID);
6082
6378
  }, threeDsData);
@@ -6095,11 +6391,385 @@ class CardProcessor {
6095
6391
  (_b = this.threeDsProcessor) == null ? void 0 : _b.setAmount(amount);
6096
6392
  }
6097
6393
  }
6394
+ function capitalizeFirstLetter(str) {
6395
+ return str.charAt(0).toUpperCase() + str.slice(1);
6396
+ }
6397
+ const isLoading = ref(false);
6398
+ function useLoading() {
6399
+ const startLoading = () => {
6400
+ isLoading.value = true;
6401
+ };
6402
+ const stopLoading = () => {
6403
+ isLoading.value = false;
6404
+ };
6405
+ return {
6406
+ isLoading,
6407
+ startLoading,
6408
+ stopLoading
6409
+ };
6410
+ }
6411
+ const errorMessage = ref("");
6412
+ function useErrorMessage() {
6413
+ const showErrorMessage = (message) => {
6414
+ errorMessage.value = message;
6415
+ };
6416
+ const hideErrorMessage = () => {
6417
+ errorMessage.value = "";
6418
+ };
6419
+ return {
6420
+ errorMessage,
6421
+ showErrorMessage,
6422
+ hideErrorMessage
6423
+ };
6424
+ }
6425
+ var PayToForm_vue_vue_type_style_index_0_lang = "";
6426
+ var PayToForm_vue_vue_type_style_index_1_scoped_true_lang = "";
6427
+ const _withScopeId$1 = (n) => (pushScopeId("data-v-59338927"), n = n(), popScopeId(), n);
6428
+ const _hoisted_1$1 = {
6429
+ id: "payfurl-payto-form",
6430
+ class: "payfurl-form"
6431
+ };
6432
+ const _hoisted_2$1 = {
6433
+ key: 0,
6434
+ class: "error text-normal"
6435
+ };
6436
+ const _hoisted_3 = { class: "row" };
6437
+ const _hoisted_4 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("label", null, "Payer Name", -1));
6438
+ const _hoisted_5 = { class: "row" };
6439
+ const _hoisted_6 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("label", null, "Payer Id Type", -1));
6440
+ const _hoisted_7 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("option", { value: "PHONE" }, "Phone", -1));
6441
+ const _hoisted_8 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("option", { value: "EMAIL" }, "Email", -1));
6442
+ const _hoisted_9 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("option", { value: "ABN" }, "Abn", -1));
6443
+ const _hoisted_10 = [
6444
+ _hoisted_7,
6445
+ _hoisted_8,
6446
+ _hoisted_9
6447
+ ];
6448
+ const _hoisted_11 = { class: "row" };
6449
+ const _hoisted_12 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("label", null, " Pay Id ", -1));
6450
+ const _hoisted_13 = ["placeholder"];
6451
+ const _hoisted_14 = {
6452
+ key: 0,
6453
+ class: "small"
6454
+ };
6455
+ const _hoisted_15 = {
6456
+ key: 1,
6457
+ class: "error"
6458
+ };
6459
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6460
+ props: {
6461
+ log: null
6462
+ },
6463
+ emits: ["submit"],
6464
+ setup(__props, { emit }) {
6465
+ const props = __props;
6466
+ const errors = ref({});
6467
+ const { isLoading: isLoading2 } = useLoading();
6468
+ const payerName = ref("");
6469
+ const payIdType = ref("PHONE");
6470
+ const payId = ref("");
6471
+ const payIdTypeFormatted = computed(() => payIdType.value === "PHONE" ? "0405123456 or 0212341234" : capitalizeFirstLetter(payIdType.value.toLowerCase()));
6472
+ const active = ref(true);
6473
+ const { errorMessage: errorMessage2 } = useErrorMessage();
6474
+ function validatePayId() {
6475
+ errors.value.payId = "";
6476
+ if (payIdType.value === "PHONE") {
6477
+ if (!checkPhone(payId.value)) {
6478
+ errors.value.payId = "Invalid phone number";
6479
+ }
6480
+ }
6481
+ if (payIdType.value === "EMAIL") {
6482
+ if (!checkEmail(payId.value)) {
6483
+ errors.value.payId = "Invalid email";
6484
+ }
6485
+ }
6486
+ if (payIdType.value === "ABN") {
6487
+ if (!checkABN(payId.value)) {
6488
+ errors.value.payId = "Invalid ABN";
6489
+ }
6490
+ }
6491
+ return errors.value.payId === "";
6492
+ }
6493
+ function messageHandler(event) {
6494
+ var _a;
6495
+ if (!((_a = event == null ? void 0 : event.data) == null ? void 0 : _a.status))
6496
+ return;
6497
+ if (props.log) {
6498
+ props.log("[PayTo]: message received", event.data);
6499
+ }
6500
+ if (event.data.status === "submit-form") {
6501
+ if (!active.value)
6502
+ return;
6503
+ event.stopPropagation();
6504
+ if (props.log) {
6505
+ props.log("[PayTo]: form submit", {
6506
+ payerName: payerName.value,
6507
+ payIdType: payIdType.value,
6508
+ payId: payId.value
6509
+ });
6510
+ }
6511
+ if (!validatePayId())
6512
+ return;
6513
+ emit("submit", {
6514
+ payerName: payerName.value,
6515
+ payIdType: payIdType.value,
6516
+ payId: payIdType.value === "PHONE" ? get10DigitsPhone(payId.value) : String(payId.value).toLowerCase()
6517
+ });
6518
+ }
6519
+ if (event.data.status === "activate" && event.data.component === "payto") {
6520
+ active.value = true;
6521
+ }
6522
+ if (event.data.status === "deactivate" && event.data.component === "payto") {
6523
+ active.value = false;
6524
+ }
6525
+ }
6526
+ onMounted(() => {
6527
+ window.addEventListener("message", messageHandler);
6528
+ window.addEventListener("keypress", function(event) {
6529
+ if (event.altKey && event.code === "KeyP") {
6530
+ event.preventDefault();
6531
+ payerName.value = "test";
6532
+ payIdType.value = "ABN";
6533
+ payId.value = "67384721620";
6534
+ }
6535
+ });
6536
+ });
6537
+ onUnmounted(() => {
6538
+ window.removeEventListener("message", messageHandler);
6539
+ });
6540
+ return (_ctx, _cache) => {
6541
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [
6542
+ withDirectives(createVNode(Spinner, null, null, 512), [
6543
+ [vShow, unref(isLoading2)]
6544
+ ]),
6545
+ createBaseVNode("div", {
6546
+ class: "container-form",
6547
+ style: normalizeStyle(`visibility: ${unref(isLoading2) ? "hidden" : "visible"}`)
6548
+ }, [
6549
+ unref(errorMessage2) ? (openBlock(), createElementBlock("div", _hoisted_2$1, toDisplayString(unref(errorMessage2)), 1)) : createCommentVNode("", true),
6550
+ createBaseVNode("div", _hoisted_3, [
6551
+ _hoisted_4,
6552
+ createBaseVNode("div", null, [
6553
+ withDirectives(createBaseVNode("input", {
6554
+ type: "text",
6555
+ maxlength: "100",
6556
+ placeholder: "Payer Name",
6557
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => payerName.value = $event)
6558
+ }, null, 512), [
6559
+ [vModelText, payerName.value]
6560
+ ])
6561
+ ])
6562
+ ]),
6563
+ createBaseVNode("div", _hoisted_5, [
6564
+ _hoisted_6,
6565
+ createBaseVNode("div", null, [
6566
+ withDirectives(createBaseVNode("select", {
6567
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => payIdType.value = $event)
6568
+ }, _hoisted_10, 512), [
6569
+ [vModelSelect, payIdType.value]
6570
+ ])
6571
+ ])
6572
+ ]),
6573
+ createBaseVNode("div", _hoisted_11, [
6574
+ _hoisted_12,
6575
+ createBaseVNode("div", null, [
6576
+ withDirectives(createBaseVNode("input", {
6577
+ type: "text",
6578
+ maxlength: "100",
6579
+ placeholder: unref(payIdTypeFormatted),
6580
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => payId.value = $event),
6581
+ onKeyup: validatePayId
6582
+ }, null, 40, _hoisted_13), [
6583
+ [vModelText, payId.value]
6584
+ ]),
6585
+ payIdType.value === "PHONE" ? (openBlock(), createElementBlock("div", _hoisted_14, "(mobile or landline with area code)")) : createCommentVNode("", true),
6586
+ errors.value.payId ? (openBlock(), createElementBlock("p", _hoisted_15, toDisplayString(errors.value.payId), 1)) : createCommentVNode("", true)
6587
+ ])
6588
+ ])
6589
+ ], 4)
6590
+ ]);
6591
+ };
6592
+ }
6593
+ });
6594
+ var PayToForm = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-59338927"]]);
6595
+ var PayToAgreement_vue_vue_type_style_index_0_lang = "";
6596
+ var PayToAgreement_vue_vue_type_style_index_1_scoped_true_lang = "";
6597
+ const _withScopeId = (n) => (pushScopeId("data-v-97983732"), n = n(), popScopeId(), n);
6598
+ const _hoisted_1 = {
6599
+ id: "payfurl-payto-agreement",
6600
+ class: "payfurl-form"
6601
+ };
6602
+ const _hoisted_2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBaseVNode("div", { class: "message" }, "Approve the agreement in your banking app", -1));
6603
+ const _sfc_main = /* @__PURE__ */ defineComponent({
6604
+ props: {
6605
+ debug: { type: Boolean }
6606
+ },
6607
+ setup(__props) {
6608
+ return (_ctx, _cache) => {
6609
+ return openBlock(), createElementBlock("div", _hoisted_1, [
6610
+ createVNode(Spinner),
6611
+ _hoisted_2
6612
+ ]);
6613
+ };
6614
+ }
6615
+ });
6616
+ var PayToAgreement = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-97983732"]]);
6617
+ const endpointTypes = {
6618
+ TOKENISE: "TOKENISE",
6619
+ TOKEN_STATUS: "TOKEN_STATUS"
6620
+ };
6621
+ const endpoints = (baseUrl, token) => ({
6622
+ [endpointTypes.TOKENISE]: {
6623
+ url: baseUrl + "/token/payto",
6624
+ method: "POST"
6625
+ },
6626
+ [endpointTypes.TOKEN_STATUS]: {
6627
+ url: baseUrl + "/token/" + token,
6628
+ method: "GET"
6629
+ }
6630
+ });
6631
+ class PayToProcessor {
6632
+ constructor(log, config2) {
6633
+ __publicField(this, "container", document.body);
6634
+ __publicField(this, "debug", false);
6635
+ __publicField(this, "log");
6636
+ __publicField(this, "apiUrl", "");
6637
+ __publicField(this, "getPaymentOptions");
6638
+ __publicField(this, "options", null);
6639
+ __publicField(this, "providerId", "");
6640
+ __publicField(this, "tokenId", "");
6641
+ __publicField(this, "checkAgreementHandler", null);
6642
+ __publicField(this, "failureCallback", null);
6643
+ __publicField(this, "successCallback", null);
6644
+ __publicField(this, "httpInvoker", null);
6645
+ __publicField(this, "successPayToHandler", (status, body) => {
6646
+ this.log("successPayToHandler", status, body);
6647
+ const data = JSON.parse(body);
6648
+ if (!data || !(data == null ? void 0 : data.tokenId)) {
6649
+ return this.failurePayToHandler(status, body);
6650
+ }
6651
+ this.tokenId = data.tokenId;
6652
+ renderComponent({
6653
+ el: this.container,
6654
+ component: PayToAgreement,
6655
+ props: {
6656
+ el: this.container,
6657
+ log: this.log
6658
+ }
6659
+ });
6660
+ this.checkAgreement();
6661
+ });
6662
+ __publicField(this, "failurePayToHandler", (status, body) => {
6663
+ this.log("failurePayToHandler", status, body);
6664
+ useLoading().stopLoading();
6665
+ useErrorMessage().showErrorMessage("Invalid payment details");
6666
+ });
6667
+ __publicField(this, "failurePayToAgreementHandler", (status, body) => {
6668
+ var _a;
6669
+ useLoading().stopLoading();
6670
+ this.log("failurePayToAgreementHandler", status, body);
6671
+ showError(this.container, "Agreement has been canceled");
6672
+ (_a = this.failureCallback) == null ? void 0 : _a.call(this, { error: "Agreement has been canceled", body });
6673
+ });
6674
+ this.log = log;
6675
+ this.debug = config2.debug;
6676
+ this.apiUrl = config2.apiUrl;
6677
+ this.getPaymentOptions = config2.getPaymentOptions;
6678
+ this.failureCallback = config2.onFailure || null;
6679
+ this.successCallback = config2.onSuccess || null;
6680
+ this.httpInvoker = new HttpInvoker(config2.publicKey);
6681
+ }
6682
+ addPayTo(container, amount, providerId, options) {
6683
+ this.log("[addPayTo]", { amount, providerId, options });
6684
+ this.container = container;
6685
+ this.providerId = providerId;
6686
+ this.options = options;
6687
+ if (!checkAmount(amount)) {
6688
+ showError(container, "Invalid amount: " + amount);
6689
+ throw new Error2("invalid amount: " + amount);
6690
+ }
6691
+ if (!String(options.description).trim()) {
6692
+ showError(container, "Invalid description");
6693
+ throw new Error2("invalid description");
6694
+ }
6695
+ if (!options.maximumAmount) {
6696
+ options.maximumAmount = 1e3;
6697
+ }
6698
+ if (options.maximumAmount < 0 || options.maximumAmount > 9999) {
6699
+ showError(container, "Invalid maximum amount: " + options.maximumAmount);
6700
+ throw new Error2("invalid maximumAmount: " + options.maximumAmount);
6701
+ }
6702
+ renderComponent({
6703
+ el: this.container,
6704
+ component: PayToForm,
6705
+ props: {
6706
+ el: this.container,
6707
+ log: this.log
6708
+ },
6709
+ on: {
6710
+ submit: (data) => {
6711
+ this.log("submit payto form", data);
6712
+ useLoading().startLoading();
6713
+ setTimeout(() => {
6714
+ this.tokenise(data);
6715
+ }, 500);
6716
+ }
6717
+ }
6718
+ });
6719
+ }
6720
+ tokenise(data) {
6721
+ var _a, _b, _c;
6722
+ const body = {
6723
+ payerName: data.payerName,
6724
+ description: (_a = this.options) == null ? void 0 : _a.description,
6725
+ maximumAmount: (_b = this.options) == null ? void 0 : _b.maximumAmount,
6726
+ providerId: this.providerId,
6727
+ payerPayIdDetails: {
6728
+ payIdType: data.payIdType.toUpperCase(),
6729
+ payId: data.payId
6730
+ }
6731
+ };
6732
+ (_c = this.httpInvoker) == null ? void 0 : _c.invoke(endpoints(this.apiUrl)[endpointTypes.TOKENISE].url, endpoints(this.apiUrl)[endpointTypes.TOKENISE].method, JSON.stringify(body), this.successPayToHandler.bind(this), this.failurePayToHandler.bind(this));
6733
+ }
6734
+ successPayToAgreementHandler() {
6735
+ var _a;
6736
+ useLoading().stopLoading();
6737
+ this.log("success agreement", this.tokenId);
6738
+ showSuccess(this.container, "PayTo Agreement Approved");
6739
+ (_a = this.successCallback) == null ? void 0 : _a.call(this, { token: this.tokenId });
6740
+ }
6741
+ checkAgreement() {
6742
+ var _a;
6743
+ if (!this.checkAgreementHandler) {
6744
+ this.checkAgreementHandler = setInterval(this.checkAgreement.bind(this), 5e3);
6745
+ }
6746
+ (_a = this.httpInvoker) == null ? void 0 : _a.invoke(endpoints(this.apiUrl, this.tokenId)[endpointTypes.TOKEN_STATUS].url, endpoints(this.apiUrl, this.tokenId)[endpointTypes.TOKEN_STATUS].method, {}, (status, body) => {
6747
+ this.log("checkAgreement", status, body);
6748
+ const data = JSON.parse(body);
6749
+ if (!data) {
6750
+ clearInterval(this.checkAgreementHandler);
6751
+ return this.failurePayToAgreementHandler(status, body);
6752
+ }
6753
+ if (data.payToStatus === "PENDING")
6754
+ return;
6755
+ if (data.payToStatus === "ACTIVE") {
6756
+ clearInterval(this.checkAgreementHandler);
6757
+ return this.successPayToAgreementHandler();
6758
+ }
6759
+ clearInterval(this.checkAgreementHandler);
6760
+ return this.failurePayToAgreementHandler(status, "");
6761
+ }, (status, body) => {
6762
+ this.log("checkAgreement", status, body);
6763
+ clearInterval(this.checkAgreementHandler);
6764
+ return this.failurePayToAgreementHandler(status, body);
6765
+ });
6766
+ }
6767
+ }
6098
6768
  class Payfurl {
6099
6769
  constructor() {
6770
+ __publicField(this, "container", null);
6100
6771
  __publicField(this, "form", null);
6101
- __publicField(this, "formToken", null);
6102
- __publicField(this, "environment", Environment.DEVELOPMENT);
6772
+ __publicField(this, "environment", Environment.LOCAL);
6103
6773
  __publicField(this, "debug", false);
6104
6774
  __publicField(this, "config", getConfig(Environment.PRODUCTION));
6105
6775
  __publicField(this, "publicKey", "");
@@ -6107,6 +6777,7 @@ class Payfurl {
6107
6777
  __publicField(this, "threeDsProcessor", null);
6108
6778
  __publicField(this, "paypalProcessor", null);
6109
6779
  __publicField(this, "cardProcessor", null);
6780
+ __publicField(this, "payToProcessor", null);
6110
6781
  __publicField(this, "userOnSuccess", null);
6111
6782
  __publicField(this, "userOnFailure", null);
6112
6783
  }
@@ -6124,12 +6795,15 @@ class Payfurl {
6124
6795
  apiUrl: this.config.apiUrl,
6125
6796
  getPaymentOptions: this.getPaymentOptions.bind(this),
6126
6797
  onSuccess: (data) => {
6127
- var _a, _b;
6798
+ var _a;
6128
6799
  if (data.token) {
6129
6800
  this._setToken(data.token);
6130
- (_a = this.form) == null ? void 0 : _a.submit();
6801
+ setTimeout(() => {
6802
+ var _a2;
6803
+ (_a2 = this.form) == null ? void 0 : _a2.submit();
6804
+ }, 500);
6131
6805
  }
6132
- (_b = this.userOnSuccess) == null ? void 0 : _b.call(this, { token: data.token });
6806
+ (_a = this.userOnSuccess) == null ? void 0 : _a.call(this, { token: data.token });
6133
6807
  },
6134
6808
  onFailure: (data) => {
6135
6809
  var _a;
@@ -6171,6 +6845,27 @@ class Payfurl {
6171
6845
  }
6172
6846
  });
6173
6847
  this.cardProcessor.addThreeDsProcessor(this.threeDsProcessor);
6848
+ this.payToProcessor = new PayToProcessor(this.log.bind(this), {
6849
+ debug: this.debug,
6850
+ publicKey: this.publicKey,
6851
+ apiUrl: this.config.apiUrl,
6852
+ getPaymentOptions: this.getPaymentOptions.bind(this),
6853
+ onSuccess: (data) => {
6854
+ var _a;
6855
+ if (data.token) {
6856
+ this._setToken(data.token);
6857
+ setTimeout(() => {
6858
+ var _a2;
6859
+ (_a2 = this.form) == null ? void 0 : _a2.submit();
6860
+ }, 500);
6861
+ }
6862
+ (_a = this.userOnSuccess) == null ? void 0 : _a.call(this, { token: data.token });
6863
+ },
6864
+ onFailure: (data) => {
6865
+ var _a;
6866
+ (_a = this.userOnFailure) == null ? void 0 : _a.call(this, { error: data.error });
6867
+ }
6868
+ });
6174
6869
  this.loadCss();
6175
6870
  return this;
6176
6871
  }
@@ -6188,6 +6883,7 @@ class Payfurl {
6188
6883
  }
6189
6884
  _initForm(container) {
6190
6885
  var _a;
6886
+ this.container = container;
6191
6887
  this.form = ((_a = container == null ? void 0 : container.parentElement) == null ? void 0 : _a.closest("form")) || null;
6192
6888
  if (!this.form)
6193
6889
  return;
@@ -6206,17 +6902,8 @@ class Payfurl {
6206
6902
  input.value = token;
6207
6903
  }
6208
6904
  _submitForm(event) {
6209
- this.log("form submitted");
6210
6905
  event.preventDefault();
6211
- if (!this.form)
6212
- return;
6213
- const input = this.form.querySelector('input[name="token"]');
6214
- this.log("token value", input == null ? void 0 : input.value);
6215
- if (input == null ? void 0 : input.value) {
6216
- this.form.submit();
6217
- return;
6218
- }
6219
- window.postMessage({ status: "submit-card-form" }, "*");
6906
+ window.postMessage({ status: "submit-form" }, "*");
6220
6907
  }
6221
6908
  addCard(iframeParentId, providerId, options) {
6222
6909
  var _a;
@@ -6225,7 +6912,7 @@ class Payfurl {
6225
6912
  }
6226
6913
  const container = document.getElementById(iframeParentId) || document.body;
6227
6914
  this._initForm(container);
6228
- (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container, providerId, 0, "", options);
6915
+ (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container, this.form, providerId, 0, "", options);
6229
6916
  return this;
6230
6917
  }
6231
6918
  addCardLeastCost(iframeParentId, amount, currency, options) {
@@ -6235,17 +6922,17 @@ class Payfurl {
6235
6922
  }
6236
6923
  const container = document.getElementById(iframeParentId) || document.body;
6237
6924
  this._initForm(container);
6238
- (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container, "", amount, currency, options);
6925
+ (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container, this.form, "", amount, currency, options);
6239
6926
  return this;
6240
6927
  }
6241
6928
  _addDropIn(dropinParentId, amount, currency, options) {
6242
- this.log("[addDropIn]", { dropinParentId, options, amount, currency });
6929
+ this.log("[addDropIn]", { dropinParentId, amount, currency, options });
6243
6930
  const container = document.getElementById(dropinParentId) || document.body;
6244
6931
  this._initForm(container);
6245
- const paymentMethodsCallback = (hasCardProviders, required3dsProvider, paypalProviderId) => {
6932
+ const paymentMethodsCallback = (hasCardProviders, required3dsProvider, paypalProviderId, payToProviderId) => {
6246
6933
  var _a;
6247
- this.log("[paymentMethodsCallback]", { hasCardProviders, required3dsProvider, paypalProviderId });
6248
- const showTabs = hasCardProviders && paypalProviderId;
6934
+ this.log("[paymentMethodsCallback]", { hasCardProviders, required3dsProvider, paypalProviderId, payToProviderId });
6935
+ const showTabs = hasCardProviders && paypalProviderId || hasCardProviders && payToProviderId || paypalProviderId && payToProviderId;
6249
6936
  const cardOptions = required3dsProvider ? {
6250
6937
  threeDSEnabled: true,
6251
6938
  threeDsProviderId: required3dsProvider,
@@ -6255,53 +6942,88 @@ class Payfurl {
6255
6942
  threeDsProviderId: "",
6256
6943
  threeDSEmail: (options == null ? void 0 : options.threeDSEmail) || ""
6257
6944
  };
6258
- if (!showTabs && hasCardProviders) {
6259
- const container2 = document.getElementById(dropinParentId) || document.body;
6260
- (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container2, (options == null ? void 0 : options.cardProviderId) || "", amount, currency, cardOptions);
6261
- return;
6262
- }
6263
6945
  const paypalOptions = {
6264
6946
  hideShipping: false,
6265
6947
  paypalButtonStyle: null,
6266
6948
  paypalEnablePayIn4: false,
6267
6949
  transfer: null
6268
6950
  };
6951
+ const payToOptions = {
6952
+ description: String(options == null ? void 0 : options.payToDescription).trim() || "",
6953
+ maximumAmount: (options == null ? void 0 : options.payToMaximumAmount) || 0
6954
+ };
6955
+ if (!showTabs && hasCardProviders) {
6956
+ const container2 = document.getElementById(dropinParentId) || document.body;
6957
+ (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container2, this.form, (options == null ? void 0 : options.cardProviderId) || "", amount, currency, cardOptions);
6958
+ return;
6959
+ }
6269
6960
  if (!showTabs && paypalProviderId) {
6270
6961
  this.addPaypal(dropinParentId, amount, currency, paypalProviderId, paypalOptions);
6271
6962
  return;
6272
6963
  }
6964
+ if (!showTabs && payToProviderId) {
6965
+ this.addPayTo(dropinParentId, amount, payToProviderId, payToOptions);
6966
+ return;
6967
+ }
6273
6968
  if (showTabs) {
6274
- renderComponent({
6275
- el: document.getElementById(dropinParentId),
6276
- component: Combined,
6277
- props: {
6278
- elements: [
6279
- {
6280
- title: "Credit Card",
6281
- icon: CreditCardIcon,
6282
- render: (container2) => {
6283
- var _a2;
6284
- (_a2 = this.cardProcessor) == null ? void 0 : _a2.addCard(container2, (options == null ? void 0 : options.cardProviderId) || "", amount, currency, cardOptions);
6285
- }
6969
+ const elements = [];
6970
+ if (hasCardProviders) {
6971
+ elements.push({
6972
+ title: "Credit Card",
6973
+ icon: CreditCardIcon,
6974
+ render: (container2) => {
6975
+ var _a2;
6976
+ (_a2 = this.cardProcessor) == null ? void 0 : _a2.addCard(container2, this.form, (options == null ? void 0 : options.cardProviderId) || "", amount, currency, cardOptions);
6977
+ },
6978
+ activate: () => {
6979
+ window.postMessage({ status: "activate", component: "card" }, "*");
6980
+ window.postMessage({ status: "deactivate", component: "paypal" }, "*");
6981
+ window.postMessage({ status: "deactivate", component: "payto" }, "*");
6982
+ }
6983
+ });
6984
+ }
6985
+ if (paypalProviderId) {
6986
+ elements.push({
6987
+ title: "Paypal",
6988
+ icon: PaypalIcon,
6989
+ render: (container2) => {
6990
+ var _a2;
6991
+ (_a2 = this.paypalProcessor) == null ? void 0 : _a2.addPaypal(container2, this.form, amount, currency, paypalProviderId, paypalOptions);
6992
+ },
6993
+ activate: () => {
6994
+ window.postMessage({ status: "activate", component: "paypal" }, "*");
6995
+ window.postMessage({ status: "deactivate", component: "card" }, "*");
6996
+ window.postMessage({ status: "deactivate", component: "payto" }, "*");
6997
+ }
6998
+ });
6999
+ }
7000
+ if (payToProviderId) {
7001
+ if (!checkEmpty(payToOptions.description)) {
7002
+ console.log("Missing parameter: PayTo Description");
7003
+ } else {
7004
+ elements.push({
7005
+ title: "PayTo",
7006
+ icon: PayToIcon,
7007
+ render: (container2) => {
7008
+ var _a2;
7009
+ (_a2 = this.payToProcessor) == null ? void 0 : _a2.addPayTo(container2, amount, payToProviderId, payToOptions);
6286
7010
  },
6287
- {
6288
- title: "Paypal",
6289
- icon: PaypalIcon,
6290
- render: (container2) => {
6291
- var _a2;
6292
- (_a2 = this.paypalProcessor) == null ? void 0 : _a2.addPaypal(container2, amount, currency, paypalProviderId, paypalOptions);
6293
- }
7011
+ activate: () => {
7012
+ window.postMessage({ status: "activate", component: "payto" }, "*");
7013
+ window.postMessage({ status: "deactivate", component: "card" }, "*");
7014
+ window.postMessage({ status: "deactivate", component: "paypal" }, "*");
6294
7015
  }
6295
- ]
7016
+ });
6296
7017
  }
7018
+ }
7019
+ renderComponent({
7020
+ el: document.getElementById(dropinParentId),
7021
+ component: Combined,
7022
+ props: { elements }
6297
7023
  });
6298
7024
  }
6299
7025
  };
6300
- if (options == null ? void 0 : options.paypalProviderId) {
6301
- this.getPaymentOptions(amount, currency, options.paypalProviderId, paymentMethodsCallback);
6302
- } else {
6303
- this.getPaymentOptions(amount, currency, "", paymentMethodsCallback);
6304
- }
7026
+ this.getPaymentOptions(amount, currency, (options == null ? void 0 : options.paypalProviderId) || "", (options == null ? void 0 : options.payToProviderId) || "", paymentMethodsCallback);
6305
7027
  return this;
6306
7028
  }
6307
7029
  addDropIn(dropinParentId, amount, currency, options) {
@@ -6315,7 +7037,17 @@ class Payfurl {
6315
7037
  var _a;
6316
7038
  const container = document.getElementById(parentId) || document.body;
6317
7039
  this._initForm(container);
6318
- (_a = this.paypalProcessor) == null ? void 0 : _a.addPaypal(container, amount, currency, providerId, options);
7040
+ (_a = this.paypalProcessor) == null ? void 0 : _a.addPaypal(container, this.form, amount, currency, providerId, options);
7041
+ return this;
7042
+ }
7043
+ addPayTo(parentId, amount, providerId, options) {
7044
+ var _a;
7045
+ if (!checkEmpty(options.description)) {
7046
+ throw new Error2("Missing parameter: description");
7047
+ }
7048
+ const container = document.getElementById(parentId) || document.body;
7049
+ this._initForm(container);
7050
+ (_a = this.payToProcessor) == null ? void 0 : _a.addPayTo(container, amount, providerId, options);
6319
7051
  return this;
6320
7052
  }
6321
7053
  addThreeDsWithFullParameters(parentId, cardNumber, cardExpiry, cardHolderName, email, amount, currency) {
@@ -6325,27 +7057,26 @@ class Payfurl {
6325
7057
  (_a = this.threeDsProcessor) == null ? void 0 : _a.addThreeDsWithFullParameters(container, cardNumber, cardExpiry, cardHolderName, email, amount, currency);
6326
7058
  return this;
6327
7059
  }
6328
- getPaymentOptions(amount, currency, overridePaypalProviderId, callback) {
7060
+ getPaymentOptions(amount, currency, overridePaypalProviderId, overridePayToProviderId, callback) {
6329
7061
  var _a;
6330
7062
  this.log("getPaymentOptions", {
6331
7063
  amount,
6332
7064
  currency,
6333
- overridePaypalProviderId
7065
+ overridePaypalProviderId,
7066
+ overridePayToProviderId
6334
7067
  });
6335
7068
  const url = this.config.apiUrl + "/info/providers?amount=" + amount + "&currency=" + currency;
6336
7069
  const failureHandler = (httpStatus, body) => {
7070
+ this.showErrorMessage("Unable to configure SDK");
6337
7071
  throw new Error2("failed to configure, error: " + body);
6338
7072
  };
6339
7073
  const successHandler = (httpStatus, body) => {
7074
+ var _a2, _b;
6340
7075
  const bodyData = JSON.parse(body);
6341
- let paypalProviderId = null;
6342
- if (overridePaypalProviderId) {
6343
- paypalProviderId = overridePaypalProviderId;
6344
- } else if (bodyData.paypalProviders.length) {
6345
- paypalProviderId = bodyData.paypalProviders[0];
6346
- }
6347
- this.log("getPaymentOptions", paypalProviderId, bodyData);
6348
- callback(bodyData.hasCardProviders, bodyData.required3dsProvider, paypalProviderId);
7076
+ const paypalProviderId = overridePaypalProviderId || ((_a2 = bodyData.paypalProviders) == null ? void 0 : _a2[0]) || null;
7077
+ const payToProviderId = overridePayToProviderId || ((_b = bodyData.payToProviders) == null ? void 0 : _b[0]) || null;
7078
+ this.log("getPaymentOptions", paypalProviderId, payToProviderId, bodyData);
7079
+ callback(bodyData.hasCardProviders, bodyData.required3dsProvider, paypalProviderId, payToProviderId);
6349
7080
  };
6350
7081
  (_a = this.httpInvoker) == null ? void 0 : _a.invoke(url, "GET", "", successHandler, failureHandler);
6351
7082
  }
@@ -6364,6 +7095,10 @@ class Payfurl {
6364
7095
  onFailure(f) {
6365
7096
  this.userOnFailure = f;
6366
7097
  }
7098
+ showErrorMessage(message) {
7099
+ this.log(message);
7100
+ showError(this.container || document.body, message);
7101
+ }
6367
7102
  }
6368
7103
  var main = new Payfurl();
6369
7104
  export { main as default };