@payfurl/client 3.0.5 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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;
@@ -4441,26 +4606,34 @@ var localConfig = {
4441
4606
  url: "",
4442
4607
  apiUrl: ""
4443
4608
  };
4609
+ var developmentConfig = {
4610
+ baseUrl: "https://assets.payfurl.com",
4611
+ cssUrl: "https://assets.payfurl.com/v3.1.1/js/",
4612
+ url: "https://assets.payfurl.com/v3.1.1/iframe/index.html",
4613
+ apiUrl: "https://develop-api.payfurl.com"
4614
+ };
4444
4615
  var sandboxConfig = {
4445
4616
  baseUrl: "https://assets.payfurl.com",
4446
- cssUrl: "https://assets.payfurl.com/v3.0.5/js/",
4447
- url: "https://assets.payfurl.com/v3.0.5/iframe/index.html",
4617
+ cssUrl: "https://assets.payfurl.com/v3.1.1/js/",
4618
+ url: "https://assets.payfurl.com/v3.1.1/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.5/js/",
4453
- url: "https://assets.payfurl.com/v3.0.5/iframe/index.html",
4623
+ cssUrl: "https://assets.payfurl.com/v3.1.1/js/",
4624
+ url: "https://assets.payfurl.com/v3.1.1/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-e78635f4"]]);
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 = ["id", "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,10 +5059,11 @@ 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" : ""]),
@@ -4843,16 +5077,16 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4843
5077
  grayscale: ""
4844
5078
  }, null, 8, ["color"])) : createCommentVNode("", true),
4845
5079
  createTextVNode(" " + toDisplayString(element.title), 1)
4846
- ], 10, _hoisted_3$3);
5080
+ ], 10, _hoisted_3$4);
4847
5081
  }), 256))
4848
5082
  ]),
4849
- createBaseVNode("div", _hoisted_4$2, [
5083
+ createBaseVNode("div", _hoisted_4$3, [
4850
5084
  (openBlock(true), createElementBlock(Fragment, null, renderList(props.elements, (_, index) => {
4851
5085
  return withDirectives((openBlock(), createElementBlock("div", {
4852
5086
  key: `container-component${index}`,
4853
5087
  class: "container-component",
4854
5088
  id: `container-component${index}`
4855
- }, null, 8, _hoisted_5$2)), [
5089
+ }, null, 8, _hoisted_5$3)), [
4856
5090
  [vShow, getVisibility(index)]
4857
5091
  ]);
4858
5092
  }), 128))
@@ -4861,7 +5095,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
4861
5095
  };
4862
5096
  }
4863
5097
  });
4864
- var Combined = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-5dce19d0"]]);
5098
+ var Combined = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-022194b8"]]);
4865
5099
  class HttpInvoker {
4866
5100
  constructor(publicKey) {
4867
5101
  __publicField(this, "publicKey", "");
@@ -4902,9 +5136,9 @@ function getEmptyThreeDSData() {
4902
5136
  }
4903
5137
  var Success_vue_vue_type_style_index_0_lang = "";
4904
5138
  var Success_vue_vue_type_style_index_1_scoped_true_lang = "";
4905
- const _hoisted_1$5 = { class: "message" };
4906
- const _hoisted_2$5 = { key: 0 };
4907
- 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({
4908
5142
  props: {
4909
5143
  message: null,
4910
5144
  token: null
@@ -4913,13 +5147,13 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
4913
5147
  const props = __props;
4914
5148
  return (_ctx, _cache) => {
4915
5149
  return openBlock(), createElementBlock(Fragment, null, [
4916
- createBaseVNode("div", _hoisted_1$5, toDisplayString(props.message), 1),
4917
- 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)
4918
5152
  ], 64);
4919
5153
  };
4920
5154
  }
4921
5155
  });
4922
- var Success = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-0c5d4794"]]);
5156
+ var Success = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-1f496df5"]]);
4923
5157
  function showError(container, message) {
4924
5158
  renderComponent({
4925
5159
  el: container,
@@ -5209,30 +5443,30 @@ function getScreenColorDepth() {
5209
5443
  return currentColourDepth;
5210
5444
  }
5211
5445
  var CloseIcon_vue_vue_type_style_index_0_scoped_true_lang = "";
5212
- const _sfc_main$5 = {};
5213
- const _withScopeId$2 = (n) => (pushScopeId("data-v-ad18c358"), n = n(), popScopeId(), n);
5214
- 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 = {
5215
5449
  xmlns: "http://www.w3.org/2000/svg",
5216
5450
  viewBox: "0 0 48 48"
5217
5451
  };
5218
- 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));
5219
- const _hoisted_3$2 = [
5220
- _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
5221
5455
  ];
5222
5456
  function _sfc_render(_ctx, _cache) {
5223
- return openBlock(), createElementBlock("svg", _hoisted_1$4, _hoisted_3$2);
5457
+ return openBlock(), createElementBlock("svg", _hoisted_1$6, _hoisted_3$3);
5224
5458
  }
5225
- 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"]]);
5226
5460
  var ThreeDsChallenge_vue_vue_type_style_index_0_lang = "";
5227
5461
  var ThreeDsChallenge_vue_vue_type_style_index_1_scoped_true_lang = "";
5228
- const _withScopeId$1 = (n) => (pushScopeId("data-v-7bf4e048"), n = n(), popScopeId(), n);
5229
- const _hoisted_1$3 = { class: "mask" };
5230
- const _hoisted_2$3 = { class: "wrapper" };
5231
- const _hoisted_3$1 = { class: "container" };
5232
- const _hoisted_4$1 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("iframe", { name: "ThreeDsChallengeIFrame" }, null, -1));
5233
- const _hoisted_5$1 = ["action"];
5234
- const _hoisted_6$1 = ["value"];
5235
- 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({
5236
5470
  props: {
5237
5471
  threeDSServerTransID: null,
5238
5472
  acsTransID: null,
@@ -5255,13 +5489,13 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
5255
5489
  (_a = form.value) == null ? void 0 : _a.submit();
5256
5490
  });
5257
5491
  return (_ctx, _cache) => {
5258
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
5259
- createBaseVNode("div", _hoisted_2$3, [
5260
- 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, [
5261
5495
  createVNode(CloseIcon, {
5262
5496
  onClick: _cache[0] || (_cache[0] = ($event) => emit("close"))
5263
5497
  }),
5264
- _hoisted_4$1,
5498
+ _hoisted_4$2,
5265
5499
  createBaseVNode("form", {
5266
5500
  action: props.formAction,
5267
5501
  target: "ThreeDsChallengeIFrame",
@@ -5273,33 +5507,33 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
5273
5507
  type: "hidden",
5274
5508
  name: "creq",
5275
5509
  value: unref(value)
5276
- }, null, 8, _hoisted_6$1)
5277
- ], 8, _hoisted_5$1)
5510
+ }, null, 8, _hoisted_6$2)
5511
+ ], 8, _hoisted_5$2)
5278
5512
  ])
5279
5513
  ])
5280
5514
  ]);
5281
5515
  };
5282
5516
  }
5283
5517
  });
5284
- 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"]]);
5285
5519
  var Spinner_vue_vue_type_style_index_0_scoped_true_lang = "";
5286
- const _withScopeId = (n) => (pushScopeId("data-v-4280055c"), n = n(), popScopeId(), n);
5287
- const _hoisted_1$2 = {
5520
+ const _withScopeId$2 = (n) => (pushScopeId("data-v-4280055c"), n = n(), popScopeId(), n);
5521
+ const _hoisted_1$4 = {
5288
5522
  x1: "8.042%",
5289
5523
  y1: "0%",
5290
5524
  x2: "65.682%",
5291
5525
  y2: "23.865%",
5292
5526
  id: "a"
5293
5527
  };
5294
- const _hoisted_2$2 = ["stop-color"];
5295
- const _hoisted_3 = ["stop-color"];
5296
- const _hoisted_4 = ["stop-color"];
5297
- 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 = {
5298
5532
  fill: "none",
5299
5533
  "fill-rule": "evenodd"
5300
5534
  };
5301
- const _hoisted_6 = { transform: "translate(1 1)" };
5302
- 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", {
5303
5537
  d: "M36 18c0-9.94-8.06-18-18-18",
5304
5538
  id: "Oval-2",
5305
5539
  stroke: "url(#a)",
@@ -5314,8 +5548,8 @@ const _hoisted_7 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBase
5314
5548
  repeatCount: "indefinite"
5315
5549
  })
5316
5550
  ], -1));
5317
- const _hoisted_8 = ["fill"];
5318
- 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", {
5319
5553
  attributeName: "transform",
5320
5554
  type: "rotate",
5321
5555
  from: "0 18 18",
@@ -5323,10 +5557,10 @@ const _hoisted_9 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBase
5323
5557
  dur: "0.9s",
5324
5558
  repeatCount: "indefinite"
5325
5559
  }, null, -1));
5326
- const _hoisted_10 = [
5327
- _hoisted_9
5560
+ const _hoisted_10$1 = [
5561
+ _hoisted_9$1
5328
5562
  ];
5329
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
5563
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
5330
5564
  props: {
5331
5565
  color: { default: "#1a82b7" },
5332
5566
  size: { default: 50 }
@@ -5346,39 +5580,39 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
5346
5580
  style: normalizeStyle(unref(style))
5347
5581
  }, [
5348
5582
  createBaseVNode("defs", null, [
5349
- createBaseVNode("linearGradient", _hoisted_1$2, [
5583
+ createBaseVNode("linearGradient", _hoisted_1$4, [
5350
5584
  createBaseVNode("stop", {
5351
5585
  "stop-color": color.value,
5352
5586
  "stop-opacity": "0",
5353
5587
  offset: "0%"
5354
- }, null, 8, _hoisted_2$2),
5588
+ }, null, 8, _hoisted_2$4),
5355
5589
  createBaseVNode("stop", {
5356
5590
  "stop-color": color.value,
5357
5591
  "stop-opacity": ".631",
5358
5592
  offset: "63.146%"
5359
- }, null, 8, _hoisted_3),
5593
+ }, null, 8, _hoisted_3$1),
5360
5594
  createBaseVNode("stop", {
5361
5595
  "stop-color": color.value,
5362
5596
  offset: "100%"
5363
- }, null, 8, _hoisted_4)
5597
+ }, null, 8, _hoisted_4$1)
5364
5598
  ])
5365
5599
  ]),
5366
- createBaseVNode("g", _hoisted_5, [
5367
- createBaseVNode("g", _hoisted_6, [
5368
- _hoisted_7,
5600
+ createBaseVNode("g", _hoisted_5$1, [
5601
+ createBaseVNode("g", _hoisted_6$1, [
5602
+ _hoisted_7$1,
5369
5603
  createBaseVNode("circle", {
5370
5604
  fill: color.value,
5371
5605
  cx: "36",
5372
5606
  cy: "18",
5373
5607
  r: "1"
5374
- }, _hoisted_10, 8, _hoisted_8)
5608
+ }, _hoisted_10$1, 8, _hoisted_8$1)
5375
5609
  ])
5376
5610
  ])
5377
5611
  ], 4);
5378
5612
  };
5379
5613
  }
5380
5614
  });
5381
- 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"]]);
5382
5616
  let destroy = () => {
5383
5617
  };
5384
5618
  function showSpinner(container) {
@@ -5680,35 +5914,38 @@ class ThreeDsProcessor {
5680
5914
  }
5681
5915
  var PaypalLoading_vue_vue_type_style_index_0_lang = "";
5682
5916
  var PaypalLoading_vue_vue_type_style_index_1_scoped_true_lang = "";
5683
- const _hoisted_1$1 = { class: "loading" };
5684
- const _hoisted_2$1 = /* @__PURE__ */ createTextVNode(" Paypal ");
5685
- 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({
5686
5920
  setup(__props) {
5687
5921
  return (_ctx, _cache) => {
5688
- return openBlock(), createElementBlock("div", _hoisted_1$1, [
5922
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
5689
5923
  createVNode(PaypalIcon, {
5690
5924
  size: 20,
5691
5925
  grayscale: ""
5692
5926
  }),
5693
- _hoisted_2$1,
5927
+ _hoisted_2$3,
5694
5928
  createVNode(Spinner, { size: 20 })
5695
5929
  ]);
5696
5930
  };
5697
5931
  }
5698
5932
  });
5699
- var PaypalLoading = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-ed95d8b0"]]);
5700
- 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({
5701
5935
  props: {
5936
+ log: null,
5702
5937
  el: null,
5938
+ form: null,
5703
5939
  clientId: null,
5704
5940
  currency: null,
5705
5941
  enablePayIn4: { type: Boolean },
5706
5942
  buttonStyle: null,
5707
5943
  checkoutId: null
5708
5944
  },
5709
- emits: ["approve"],
5945
+ emits: ["approve", "submit"],
5710
5946
  setup(__props, { emit }) {
5711
5947
  const props = __props;
5948
+ const active = ref(true);
5712
5949
  const src = `https://www.paypal.com/sdk/js?client-id=${props.clientId}&currency=${props.currency.toUpperCase()}&disable-funding=card${props.enablePayIn4 ? "&enable-funding=paylater" : ""}`;
5713
5950
  function onLoad() {
5714
5951
  window.paypal.Buttons({
@@ -5723,7 +5960,25 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
5723
5960
  }
5724
5961
  }).render(props.el);
5725
5962
  }
5963
+ function messageHandler(event) {
5964
+ var _a;
5965
+ if (!((_a = event == null ? void 0 : event.data) == null ? void 0 : _a.status))
5966
+ return;
5967
+ if (props.log) {
5968
+ props.log("[Paypal]: message received", event.data);
5969
+ }
5970
+ if (event.data.status === "activate" && event.data.component === "paypal") {
5971
+ active.value = true;
5972
+ }
5973
+ if (event.data.status === "deactivate" && event.data.component === "paypal") {
5974
+ active.value = false;
5975
+ }
5976
+ }
5977
+ onUnmounted(() => {
5978
+ window.removeEventListener("message", messageHandler);
5979
+ });
5726
5980
  onMounted(() => {
5981
+ window.addEventListener("message", messageHandler);
5727
5982
  window.paypal = null;
5728
5983
  const scriptTag = document.createElement("script");
5729
5984
  scriptTag.src = src;
@@ -5740,6 +5995,7 @@ class PaypalProcessor {
5740
5995
  __publicField(this, "container", document.body);
5741
5996
  __publicField(this, "log");
5742
5997
  __publicField(this, "apiUrl", "");
5998
+ __publicField(this, "form", null);
5743
5999
  __publicField(this, "getPaymentOptions");
5744
6000
  __publicField(this, "failureCallback", null);
5745
6001
  __publicField(this, "successCallback", null);
@@ -5752,20 +6008,21 @@ class PaypalProcessor {
5752
6008
  this.successCallback = config2.onSuccess || null;
5753
6009
  this.httpInvoker = new HttpInvoker(config2.publicKey);
5754
6010
  }
5755
- addPaypal(container, amount, currency, providerId, options) {
6011
+ addPaypal(container, form, amount, currency, providerId, options) {
5756
6012
  this.log("[addPaypal]", { amount, currency, providerId, options });
5757
6013
  this.container = container;
6014
+ this.form = form;
5758
6015
  if (!checkCurrency(currency)) {
5759
6016
  throw new Error2("invalid currency: " + currency);
5760
6017
  }
5761
6018
  if (!checkAmount(amount)) {
5762
6019
  throw new Error2("invalid amount: " + amount);
5763
6020
  }
5764
- const callback = (hasCardProviders, required3dsProvider, providerId2) => {
6021
+ const callback = (hasCardProviders, required3dsProvider, paypalProviderId, payToProviderId) => {
5765
6022
  var _a, _b;
5766
- this.log("[getPaymentOptions][callback]", { hasCardProviders, required3dsProvider, providerId: providerId2 });
5767
- if (!providerId2) {
5768
- throw new Error2("invalid providerId: " + providerId2);
6023
+ this.log("[getPaymentOptions][callback]", { hasCardProviders, required3dsProvider, providerId: paypalProviderId });
6024
+ if (!paypalProviderId) {
6025
+ throw new Error2("invalid providerId: " + paypalProviderId);
5769
6026
  }
5770
6027
  const { destroy: destroy2 } = renderComponent({
5771
6028
  el: this.container,
@@ -5781,7 +6038,7 @@ class PaypalProcessor {
5781
6038
  }
5782
6039
  const url = this.apiUrl + "/payment_method/checkout";
5783
6040
  const data = {
5784
- ProviderId: providerId2,
6041
+ ProviderId: paypalProviderId,
5785
6042
  Amount: amount,
5786
6043
  Currency: currency,
5787
6044
  Options: {
@@ -5807,6 +6064,7 @@ class PaypalProcessor {
5807
6064
  try {
5808
6065
  const decodedData = window.atob(checkoutData.checkoutId);
5809
6066
  data2 = JSON.parse(decodedData);
6067
+ this.log("decodedData", data2);
5810
6068
  } catch (err) {
5811
6069
  this.log("invalid checkoutId", err);
5812
6070
  return;
@@ -5844,9 +6102,11 @@ class PaypalProcessor {
5844
6102
  const checkoutId = data2.CheckoutId;
5845
6103
  renderComponent({
5846
6104
  el: this.container,
5847
- component: _sfc_main$1,
6105
+ component: _sfc_main$3,
5848
6106
  props: {
6107
+ log: this.log,
5849
6108
  el: this.container,
6109
+ form: this.form,
5850
6110
  clientId: data2.AdditionalParameters,
5851
6111
  currency,
5852
6112
  enablePayIn4: Boolean(options.paypalEnablePayIn4),
@@ -5855,12 +6115,12 @@ class PaypalProcessor {
5855
6115
  },
5856
6116
  on: {
5857
6117
  approve: ({ data: data3, actions }) => {
5858
- this.log("approved", { data: data3, actions });
6118
+ this.log("[Paypal]: approved", { data: data3, actions });
5859
6119
  const order = actions.order.get();
5860
- this.log("order", order);
6120
+ this.log("[Paypal]: order", order);
5861
6121
  const interval = setInterval(() => {
5862
6122
  var _a2;
5863
- this.log("setInterval resolved = " + order.resolved);
6123
+ this.log("[Paypal]: setInterval resolved = " + order.resolved);
5864
6124
  if (order.resolved) {
5865
6125
  clearInterval(interval);
5866
6126
  this.paypalData.payer = order.value.payer;
@@ -5877,21 +6137,22 @@ class PaypalProcessor {
5877
6137
  if (providerId) {
5878
6138
  callback(false, "", providerId);
5879
6139
  } else {
5880
- this.getPaymentOptions(amount, currency, "", callback);
6140
+ this.getPaymentOptions(amount, currency, "", "", callback);
5881
6141
  }
5882
6142
  }
5883
6143
  }
5884
- var Card_vue_vue_type_style_index_0_scoped_true_lang = "";
5885
- const _hoisted_1 = ["src"];
5886
- const _hoisted_2 = {
6144
+ var CardForm_vue_vue_type_style_index_0_scoped_true_lang = "";
6145
+ const _hoisted_1$2 = ["src"];
6146
+ const _hoisted_2$2 = {
5887
6147
  key: 0,
5888
6148
  id: "threeDs"
5889
6149
  };
5890
- const _sfc_main = /* @__PURE__ */ defineComponent({
6150
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5891
6151
  props: {
5892
6152
  debug: { type: Boolean },
5893
6153
  apiUrl: null,
5894
6154
  iframeSrc: null,
6155
+ form: null,
5895
6156
  publicKey: null,
5896
6157
  providerId: null,
5897
6158
  amount: null,
@@ -5908,6 +6169,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5908
6169
  const threeDSEnabled = ref(props.threeDSEnabled);
5909
6170
  ref(props.showSubmitButton);
5910
6171
  const ready = ref(false);
6172
+ const active = ref(true);
5911
6173
  function messageHandler(event) {
5912
6174
  var _a, _b;
5913
6175
  if (!((_a = event == null ? void 0 : event.data) == null ? void 0 : _a.status))
@@ -5916,10 +6178,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5916
6178
  event.stopPropagation();
5917
6179
  adjustIFrameHeight(((_b = event.data.message) == null ? void 0 : _b.height) || 0);
5918
6180
  }
5919
- if (event.data.status === "submit-card-form") {
6181
+ if (event.data.status === "submit-form") {
6182
+ if (!props.form)
6183
+ return;
6184
+ if (!active.value)
6185
+ return;
5920
6186
  event.stopPropagation();
6187
+ const input = props.form.querySelector('input[name="token"]');
6188
+ if (input == null ? void 0 : input.value) {
6189
+ props.form.submit();
6190
+ return;
6191
+ }
5921
6192
  emit("submit");
5922
6193
  }
6194
+ if (event.data.status === "activate" && event.data.component === "card") {
6195
+ active.value = true;
6196
+ }
6197
+ if (event.data.status === "deactivate" && event.data.component === "card") {
6198
+ active.value = false;
6199
+ }
5923
6200
  }
5924
6201
  onUnmounted(() => {
5925
6202
  window.removeEventListener("message", messageHandler);
@@ -5944,21 +6221,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5944
6221
  ref_key: "iframe",
5945
6222
  ref: iframe,
5946
6223
  id: "payfurl-card-iframe"
5947
- }, null, 40, _hoisted_1),
5948
- threeDSEnabled.value ? (openBlock(), createElementBlock("div", _hoisted_2)) : createCommentVNode("", true)
6224
+ }, null, 40, _hoisted_1$2),
6225
+ threeDSEnabled.value ? (openBlock(), createElementBlock("div", _hoisted_2$2)) : createCommentVNode("", true)
5949
6226
  ], 64);
5950
6227
  };
5951
6228
  }
5952
6229
  });
5953
- var Card = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4a2f1e14"]]);
6230
+ var CardForm = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-2a78dd48"]]);
5954
6231
  class CardProcessor {
5955
6232
  constructor(log, config2) {
5956
6233
  __publicField(this, "container", document.body);
5957
6234
  __publicField(this, "threeDsContainer", document.body);
5958
6235
  __publicField(this, "iframe", null);
6236
+ __publicField(this, "form", null);
5959
6237
  __publicField(this, "log");
5960
6238
  __publicField(this, "debug", false);
5961
- __publicField(this, "environment", Environment.DEVELOPMENT);
6239
+ __publicField(this, "environment", Environment.LOCAL);
5962
6240
  __publicField(this, "apiUrl", "");
5963
6241
  __publicField(this, "url", "");
5964
6242
  __publicField(this, "publicKey", "");
@@ -5971,7 +6249,7 @@ class CardProcessor {
5971
6249
  __publicField(this, "httpInvoker");
5972
6250
  this.log = log;
5973
6251
  this.debug = config2.debug;
5974
- this.environment = config2.environment || Environment.DEVELOPMENT;
6252
+ this.environment = config2.environment || Environment.LOCAL;
5975
6253
  this.url = config2.url;
5976
6254
  this.apiUrl = config2.apiUrl;
5977
6255
  this.publicKey = config2.publicKey;
@@ -5984,7 +6262,7 @@ class CardProcessor {
5984
6262
  addThreeDsProcessor(threeDsProcessor) {
5985
6263
  this.threeDsProcessor = threeDsProcessor;
5986
6264
  }
5987
- addCard(container, providerId, amount, currency, options) {
6265
+ addCard(container, form, providerId, amount, currency, options) {
5988
6266
  this.log("[addCard]", { providerId, amount, currency, options });
5989
6267
  if (options == null ? void 0 : options.threeDSEnabled) {
5990
6268
  validateInput(amount, checkEmpty, "missing or invalid amount option", this.failureCallback);
@@ -5992,14 +6270,16 @@ class CardProcessor {
5992
6270
  this.threeDSEnabled = true;
5993
6271
  }
5994
6272
  this.container = container || document.body;
6273
+ this.form = form;
5995
6274
  this.email = (options == null ? void 0 : options.threeDSEmail) || "";
5996
6275
  renderComponent({
5997
6276
  el: this.container,
5998
- component: Card,
6277
+ component: CardForm,
5999
6278
  props: {
6000
6279
  debug: this.debug,
6001
6280
  apiUrl: this.apiUrl,
6002
6281
  iframeSrc: this.url,
6282
+ form: this.form,
6003
6283
  publicKey: this.publicKey,
6004
6284
  providerId,
6005
6285
  amount,
@@ -6086,7 +6366,7 @@ class CardProcessor {
6086
6366
  return;
6087
6367
  }
6088
6368
  this.threeDsContainer = document.getElementById("threeDs") || document.body;
6089
- (_a = this.threeDsProcessor) == null ? void 0 : _a.requestThreeDs(this.threeDsContainer, this.iframe, this.environment === Environment.DEVELOPMENT || this.environment === Environment.SANDBOX, (postAuthData) => {
6369
+ (_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) => {
6090
6370
  this.log("threeDs, postAuthData", postAuthData);
6091
6371
  this.tokenise(postAuthData.threeDSServerTransID);
6092
6372
  }, threeDsData);
@@ -6105,10 +6385,385 @@ class CardProcessor {
6105
6385
  (_b = this.threeDsProcessor) == null ? void 0 : _b.setAmount(amount);
6106
6386
  }
6107
6387
  }
6388
+ function capitalizeFirstLetter(str) {
6389
+ return str.charAt(0).toUpperCase() + str.slice(1);
6390
+ }
6391
+ const isLoading = ref(false);
6392
+ function useLoading() {
6393
+ const startLoading = () => {
6394
+ isLoading.value = true;
6395
+ };
6396
+ const stopLoading = () => {
6397
+ isLoading.value = false;
6398
+ };
6399
+ return {
6400
+ isLoading,
6401
+ startLoading,
6402
+ stopLoading
6403
+ };
6404
+ }
6405
+ const errorMessage = ref("");
6406
+ function useErrorMessage() {
6407
+ const showErrorMessage = (message) => {
6408
+ errorMessage.value = message;
6409
+ };
6410
+ const hideErrorMessage = () => {
6411
+ errorMessage.value = "";
6412
+ };
6413
+ return {
6414
+ errorMessage,
6415
+ showErrorMessage,
6416
+ hideErrorMessage
6417
+ };
6418
+ }
6419
+ var PayToForm_vue_vue_type_style_index_0_lang = "";
6420
+ var PayToForm_vue_vue_type_style_index_1_scoped_true_lang = "";
6421
+ const _withScopeId$1 = (n) => (pushScopeId("data-v-59338927"), n = n(), popScopeId(), n);
6422
+ const _hoisted_1$1 = {
6423
+ id: "payfurl-payto-form",
6424
+ class: "payfurl-form"
6425
+ };
6426
+ const _hoisted_2$1 = {
6427
+ key: 0,
6428
+ class: "error text-normal"
6429
+ };
6430
+ const _hoisted_3 = { class: "row" };
6431
+ const _hoisted_4 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("label", null, "Payer Name", -1));
6432
+ const _hoisted_5 = { class: "row" };
6433
+ const _hoisted_6 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("label", null, "Payer Id Type", -1));
6434
+ const _hoisted_7 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("option", { value: "PHONE" }, "Phone", -1));
6435
+ const _hoisted_8 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("option", { value: "EMAIL" }, "Email", -1));
6436
+ const _hoisted_9 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("option", { value: "ABN" }, "Abn", -1));
6437
+ const _hoisted_10 = [
6438
+ _hoisted_7,
6439
+ _hoisted_8,
6440
+ _hoisted_9
6441
+ ];
6442
+ const _hoisted_11 = { class: "row" };
6443
+ const _hoisted_12 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createBaseVNode("label", null, " Pay Id ", -1));
6444
+ const _hoisted_13 = ["placeholder"];
6445
+ const _hoisted_14 = {
6446
+ key: 0,
6447
+ class: "small"
6448
+ };
6449
+ const _hoisted_15 = {
6450
+ key: 1,
6451
+ class: "error"
6452
+ };
6453
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6454
+ props: {
6455
+ log: null
6456
+ },
6457
+ emits: ["submit"],
6458
+ setup(__props, { emit }) {
6459
+ const props = __props;
6460
+ const errors = ref({});
6461
+ const { isLoading: isLoading2 } = useLoading();
6462
+ const payerName = ref("");
6463
+ const payIdType = ref("PHONE");
6464
+ const payId = ref("");
6465
+ const payIdTypeFormatted = computed(() => payIdType.value === "PHONE" ? "0405123456 or 0212341234" : capitalizeFirstLetter(payIdType.value.toLowerCase()));
6466
+ const active = ref(true);
6467
+ const { errorMessage: errorMessage2 } = useErrorMessage();
6468
+ function validatePayId() {
6469
+ errors.value.payId = "";
6470
+ if (payIdType.value === "PHONE") {
6471
+ if (!checkPhone(payId.value)) {
6472
+ errors.value.payId = "Invalid phone number";
6473
+ }
6474
+ }
6475
+ if (payIdType.value === "EMAIL") {
6476
+ if (!checkEmail(payId.value)) {
6477
+ errors.value.payId = "Invalid email";
6478
+ }
6479
+ }
6480
+ if (payIdType.value === "ABN") {
6481
+ if (!checkABN(payId.value)) {
6482
+ errors.value.payId = "Invalid ABN";
6483
+ }
6484
+ }
6485
+ return errors.value.payId === "";
6486
+ }
6487
+ function messageHandler(event) {
6488
+ var _a;
6489
+ if (!((_a = event == null ? void 0 : event.data) == null ? void 0 : _a.status))
6490
+ return;
6491
+ if (props.log) {
6492
+ props.log("[PayTo]: message received", event.data);
6493
+ }
6494
+ if (event.data.status === "submit-form") {
6495
+ if (!active.value)
6496
+ return;
6497
+ event.stopPropagation();
6498
+ if (props.log) {
6499
+ props.log("[PayTo]: form submit", {
6500
+ payerName: payerName.value,
6501
+ payIdType: payIdType.value,
6502
+ payId: payId.value
6503
+ });
6504
+ }
6505
+ if (!validatePayId())
6506
+ return;
6507
+ emit("submit", {
6508
+ payerName: payerName.value,
6509
+ payIdType: payIdType.value,
6510
+ payId: payIdType.value === "PHONE" ? get10DigitsPhone(payId.value) : String(payId.value).toLowerCase()
6511
+ });
6512
+ }
6513
+ if (event.data.status === "activate" && event.data.component === "payto") {
6514
+ active.value = true;
6515
+ }
6516
+ if (event.data.status === "deactivate" && event.data.component === "payto") {
6517
+ active.value = false;
6518
+ }
6519
+ }
6520
+ onMounted(() => {
6521
+ window.addEventListener("message", messageHandler);
6522
+ window.addEventListener("keypress", function(event) {
6523
+ if (event.altKey && event.code === "KeyP") {
6524
+ event.preventDefault();
6525
+ payerName.value = "test";
6526
+ payIdType.value = "ABN";
6527
+ payId.value = "67384721620";
6528
+ }
6529
+ });
6530
+ });
6531
+ onUnmounted(() => {
6532
+ window.removeEventListener("message", messageHandler);
6533
+ });
6534
+ return (_ctx, _cache) => {
6535
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [
6536
+ withDirectives(createVNode(Spinner, null, null, 512), [
6537
+ [vShow, unref(isLoading2)]
6538
+ ]),
6539
+ createBaseVNode("div", {
6540
+ class: "container-form",
6541
+ style: normalizeStyle(`visibility: ${unref(isLoading2) ? "hidden" : "visible"}`)
6542
+ }, [
6543
+ unref(errorMessage2) ? (openBlock(), createElementBlock("div", _hoisted_2$1, toDisplayString(unref(errorMessage2)), 1)) : createCommentVNode("", true),
6544
+ createBaseVNode("div", _hoisted_3, [
6545
+ _hoisted_4,
6546
+ createBaseVNode("div", null, [
6547
+ withDirectives(createBaseVNode("input", {
6548
+ type: "text",
6549
+ maxlength: "100",
6550
+ placeholder: "Payer Name",
6551
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => payerName.value = $event)
6552
+ }, null, 512), [
6553
+ [vModelText, payerName.value]
6554
+ ])
6555
+ ])
6556
+ ]),
6557
+ createBaseVNode("div", _hoisted_5, [
6558
+ _hoisted_6,
6559
+ createBaseVNode("div", null, [
6560
+ withDirectives(createBaseVNode("select", {
6561
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => payIdType.value = $event)
6562
+ }, _hoisted_10, 512), [
6563
+ [vModelSelect, payIdType.value]
6564
+ ])
6565
+ ])
6566
+ ]),
6567
+ createBaseVNode("div", _hoisted_11, [
6568
+ _hoisted_12,
6569
+ createBaseVNode("div", null, [
6570
+ withDirectives(createBaseVNode("input", {
6571
+ type: "text",
6572
+ maxlength: "100",
6573
+ placeholder: unref(payIdTypeFormatted),
6574
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => payId.value = $event),
6575
+ onKeyup: validatePayId
6576
+ }, null, 40, _hoisted_13), [
6577
+ [vModelText, payId.value]
6578
+ ]),
6579
+ payIdType.value === "PHONE" ? (openBlock(), createElementBlock("div", _hoisted_14, "(mobile or landline with area code)")) : createCommentVNode("", true),
6580
+ errors.value.payId ? (openBlock(), createElementBlock("p", _hoisted_15, toDisplayString(errors.value.payId), 1)) : createCommentVNode("", true)
6581
+ ])
6582
+ ])
6583
+ ], 4)
6584
+ ]);
6585
+ };
6586
+ }
6587
+ });
6588
+ var PayToForm = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-59338927"]]);
6589
+ var PayToAgreement_vue_vue_type_style_index_0_lang = "";
6590
+ var PayToAgreement_vue_vue_type_style_index_1_scoped_true_lang = "";
6591
+ const _withScopeId = (n) => (pushScopeId("data-v-ca368eb8"), n = n(), popScopeId(), n);
6592
+ const _hoisted_1 = {
6593
+ id: "payfurl-payto-agreement",
6594
+ class: "payfurl-form"
6595
+ };
6596
+ const _hoisted_2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createBaseVNode("div", { class: "message" }, "Approve the agreement in your banking app", -1));
6597
+ const _sfc_main = /* @__PURE__ */ defineComponent({
6598
+ props: {
6599
+ debug: { type: Boolean }
6600
+ },
6601
+ setup(__props) {
6602
+ return (_ctx, _cache) => {
6603
+ return openBlock(), createElementBlock("div", _hoisted_1, [
6604
+ createVNode(Spinner),
6605
+ _hoisted_2
6606
+ ]);
6607
+ };
6608
+ }
6609
+ });
6610
+ var PayToAgreement = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ca368eb8"]]);
6611
+ const endpointTypes = {
6612
+ TOKENISE: "TOKENISE",
6613
+ TOKEN_STATUS: "TOKEN_STATUS"
6614
+ };
6615
+ const endpoints = (baseUrl, token) => ({
6616
+ [endpointTypes.TOKENISE]: {
6617
+ url: baseUrl + "/token/payto",
6618
+ method: "POST"
6619
+ },
6620
+ [endpointTypes.TOKEN_STATUS]: {
6621
+ url: baseUrl + "/token/" + token,
6622
+ method: "GET"
6623
+ }
6624
+ });
6625
+ class PayToProcessor {
6626
+ constructor(log, config2) {
6627
+ __publicField(this, "container", document.body);
6628
+ __publicField(this, "debug", false);
6629
+ __publicField(this, "log");
6630
+ __publicField(this, "apiUrl", "");
6631
+ __publicField(this, "getPaymentOptions");
6632
+ __publicField(this, "options", null);
6633
+ __publicField(this, "providerId", "");
6634
+ __publicField(this, "tokenId", "");
6635
+ __publicField(this, "checkAgreementHandler", null);
6636
+ __publicField(this, "failureCallback", null);
6637
+ __publicField(this, "successCallback", null);
6638
+ __publicField(this, "httpInvoker", null);
6639
+ __publicField(this, "successPayToHandler", (status, body) => {
6640
+ this.log("successPayToHandler", status, body);
6641
+ const data = JSON.parse(body);
6642
+ if (!data || !(data == null ? void 0 : data.tokenId)) {
6643
+ return this.failurePayToHandler(status, body);
6644
+ }
6645
+ this.tokenId = data.tokenId;
6646
+ renderComponent({
6647
+ el: this.container,
6648
+ component: PayToAgreement,
6649
+ props: {
6650
+ el: this.container,
6651
+ log: this.log
6652
+ }
6653
+ });
6654
+ this.checkAgreement();
6655
+ });
6656
+ __publicField(this, "failurePayToHandler", (status, body) => {
6657
+ this.log("failurePayToHandler", status, body);
6658
+ useLoading().stopLoading();
6659
+ useErrorMessage().showErrorMessage("Invalid payment details");
6660
+ });
6661
+ __publicField(this, "failurePayToAgreementHandler", (status, body) => {
6662
+ var _a;
6663
+ useLoading().stopLoading();
6664
+ this.log("failurePayToAgreementHandler", status, body);
6665
+ showError(this.container, "Agreement has been canceled");
6666
+ (_a = this.failureCallback) == null ? void 0 : _a.call(this, { error: "Agreement has been canceled", body });
6667
+ });
6668
+ this.log = log;
6669
+ this.debug = config2.debug;
6670
+ this.apiUrl = config2.apiUrl;
6671
+ this.getPaymentOptions = config2.getPaymentOptions;
6672
+ this.failureCallback = config2.onFailure || null;
6673
+ this.successCallback = config2.onSuccess || null;
6674
+ this.httpInvoker = new HttpInvoker(config2.publicKey);
6675
+ }
6676
+ addPayTo(container, amount, providerId, options) {
6677
+ this.log("[addPayTo]", { amount, providerId, options });
6678
+ this.container = container;
6679
+ this.providerId = providerId;
6680
+ this.options = options;
6681
+ if (!checkAmount(amount)) {
6682
+ showError(container, "Invalid amount: " + amount);
6683
+ throw new Error2("invalid amount: " + amount);
6684
+ }
6685
+ if (!String(options.description).trim()) {
6686
+ showError(container, "Invalid description");
6687
+ throw new Error2("invalid description");
6688
+ }
6689
+ if (!options.maximumAmount) {
6690
+ options.maximumAmount = 1e3;
6691
+ }
6692
+ if (options.maximumAmount < 0 || options.maximumAmount > 9999) {
6693
+ showError(container, "Invalid maximum amount: " + options.maximumAmount);
6694
+ throw new Error2("invalid maximumAmount: " + options.maximumAmount);
6695
+ }
6696
+ renderComponent({
6697
+ el: this.container,
6698
+ component: PayToForm,
6699
+ props: {
6700
+ el: this.container,
6701
+ log: this.log
6702
+ },
6703
+ on: {
6704
+ submit: (data) => {
6705
+ this.log("submit payto form", data);
6706
+ useLoading().startLoading();
6707
+ setTimeout(() => {
6708
+ this.tokenise(data);
6709
+ }, 500);
6710
+ }
6711
+ }
6712
+ });
6713
+ }
6714
+ tokenise(data) {
6715
+ var _a, _b, _c;
6716
+ const body = {
6717
+ payerName: data.payerName,
6718
+ description: (_a = this.options) == null ? void 0 : _a.description,
6719
+ maximumAmount: (_b = this.options) == null ? void 0 : _b.maximumAmount,
6720
+ providerId: this.providerId,
6721
+ payerPayIdDetails: {
6722
+ payIdType: data.payIdType.toUpperCase(),
6723
+ payId: data.payId
6724
+ }
6725
+ };
6726
+ (_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));
6727
+ }
6728
+ successPayToAgreementHandler() {
6729
+ var _a;
6730
+ useLoading().stopLoading();
6731
+ this.log("success agreement", this.tokenId);
6732
+ showSuccess(this.container, "PayTo Agreement Approved");
6733
+ (_a = this.successCallback) == null ? void 0 : _a.call(this, { token: this.tokenId });
6734
+ }
6735
+ checkAgreement() {
6736
+ var _a;
6737
+ if (!this.checkAgreementHandler) {
6738
+ this.checkAgreementHandler = setInterval(this.checkAgreement.bind(this), 5e3);
6739
+ }
6740
+ (_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) => {
6741
+ this.log("checkAgreement", status, body);
6742
+ const data = JSON.parse(body);
6743
+ if (!data) {
6744
+ clearInterval(this.checkAgreementHandler);
6745
+ return this.failurePayToAgreementHandler(status, body);
6746
+ }
6747
+ if (data.payToStatus === "PENDING")
6748
+ return;
6749
+ if (data.payToStatus === "ACTIVE") {
6750
+ clearInterval(this.checkAgreementHandler);
6751
+ return this.successPayToAgreementHandler();
6752
+ }
6753
+ clearInterval(this.checkAgreementHandler);
6754
+ return this.failurePayToAgreementHandler(status, "");
6755
+ }, (status, body) => {
6756
+ this.log("checkAgreement", status, body);
6757
+ clearInterval(this.checkAgreementHandler);
6758
+ return this.failurePayToAgreementHandler(status, body);
6759
+ });
6760
+ }
6761
+ }
6108
6762
  class Payfurl {
6109
6763
  constructor() {
6764
+ __publicField(this, "container", null);
6110
6765
  __publicField(this, "form", null);
6111
- __publicField(this, "environment", Environment.DEVELOPMENT);
6766
+ __publicField(this, "environment", Environment.LOCAL);
6112
6767
  __publicField(this, "debug", false);
6113
6768
  __publicField(this, "config", getConfig(Environment.PRODUCTION));
6114
6769
  __publicField(this, "publicKey", "");
@@ -6116,6 +6771,7 @@ class Payfurl {
6116
6771
  __publicField(this, "threeDsProcessor", null);
6117
6772
  __publicField(this, "paypalProcessor", null);
6118
6773
  __publicField(this, "cardProcessor", null);
6774
+ __publicField(this, "payToProcessor", null);
6119
6775
  __publicField(this, "userOnSuccess", null);
6120
6776
  __publicField(this, "userOnFailure", null);
6121
6777
  }
@@ -6137,6 +6793,8 @@ class Payfurl {
6137
6793
  if (data.token) {
6138
6794
  this._setToken(data.token);
6139
6795
  setTimeout(() => {
6796
+ var _a2;
6797
+ (_a2 = this.form) == null ? void 0 : _a2.submit();
6140
6798
  }, 500);
6141
6799
  }
6142
6800
  (_a = this.userOnSuccess) == null ? void 0 : _a.call(this, { token: data.token });
@@ -6181,6 +6839,27 @@ class Payfurl {
6181
6839
  }
6182
6840
  });
6183
6841
  this.cardProcessor.addThreeDsProcessor(this.threeDsProcessor);
6842
+ this.payToProcessor = new PayToProcessor(this.log.bind(this), {
6843
+ debug: this.debug,
6844
+ publicKey: this.publicKey,
6845
+ apiUrl: this.config.apiUrl,
6846
+ getPaymentOptions: this.getPaymentOptions.bind(this),
6847
+ onSuccess: (data) => {
6848
+ var _a;
6849
+ if (data.token) {
6850
+ this._setToken(data.token);
6851
+ setTimeout(() => {
6852
+ var _a2;
6853
+ (_a2 = this.form) == null ? void 0 : _a2.submit();
6854
+ }, 500);
6855
+ }
6856
+ (_a = this.userOnSuccess) == null ? void 0 : _a.call(this, { token: data.token });
6857
+ },
6858
+ onFailure: (data) => {
6859
+ var _a;
6860
+ (_a = this.userOnFailure) == null ? void 0 : _a.call(this, { error: data.error });
6861
+ }
6862
+ });
6184
6863
  this.loadCss();
6185
6864
  return this;
6186
6865
  }
@@ -6198,6 +6877,7 @@ class Payfurl {
6198
6877
  }
6199
6878
  _initForm(container) {
6200
6879
  var _a;
6880
+ this.container = container;
6201
6881
  this.form = ((_a = container == null ? void 0 : container.parentElement) == null ? void 0 : _a.closest("form")) || null;
6202
6882
  if (!this.form)
6203
6883
  return;
@@ -6216,17 +6896,15 @@ class Payfurl {
6216
6896
  input.value = token;
6217
6897
  }
6218
6898
  _submitForm(event) {
6219
- this.log("form submitted");
6220
6899
  event.preventDefault();
6221
- if (!this.form)
6222
- return;
6223
- const input = this.form.querySelector('input[name="token"]');
6224
- this.log("token value", input == null ? void 0 : input.value);
6225
- if (input == null ? void 0 : input.value) {
6226
- this.form.submit();
6227
- return;
6900
+ if (this.form) {
6901
+ const input = this.form.querySelector('input[name="token"]');
6902
+ if (input == null ? void 0 : input.value) {
6903
+ this.form.submit();
6904
+ return;
6905
+ }
6228
6906
  }
6229
- window.postMessage({ status: "submit-card-form" }, "*");
6907
+ window.postMessage({ status: "submit-form" }, "*");
6230
6908
  }
6231
6909
  addCard(iframeParentId, providerId, options) {
6232
6910
  var _a;
@@ -6235,7 +6913,7 @@ class Payfurl {
6235
6913
  }
6236
6914
  const container = document.getElementById(iframeParentId) || document.body;
6237
6915
  this._initForm(container);
6238
- (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container, providerId, 0, "", options);
6916
+ (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container, this.form, providerId, 0, "", options);
6239
6917
  return this;
6240
6918
  }
6241
6919
  addCardLeastCost(iframeParentId, amount, currency, options) {
@@ -6245,17 +6923,17 @@ class Payfurl {
6245
6923
  }
6246
6924
  const container = document.getElementById(iframeParentId) || document.body;
6247
6925
  this._initForm(container);
6248
- (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container, "", amount, currency, options);
6926
+ (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container, this.form, "", amount, currency, options);
6249
6927
  return this;
6250
6928
  }
6251
6929
  _addDropIn(dropinParentId, amount, currency, options) {
6252
- this.log("[addDropIn]", { dropinParentId, options, amount, currency });
6930
+ this.log("[addDropIn]", { dropinParentId, amount, currency, options });
6253
6931
  const container = document.getElementById(dropinParentId) || document.body;
6254
6932
  this._initForm(container);
6255
- const paymentMethodsCallback = (hasCardProviders, required3dsProvider, paypalProviderId) => {
6933
+ const paymentMethodsCallback = (hasCardProviders, required3dsProvider, paypalProviderId, payToProviderId) => {
6256
6934
  var _a;
6257
- this.log("[paymentMethodsCallback]", { hasCardProviders, required3dsProvider, paypalProviderId });
6258
- const showTabs = hasCardProviders && paypalProviderId;
6935
+ this.log("[paymentMethodsCallback]", { hasCardProviders, required3dsProvider, paypalProviderId, payToProviderId });
6936
+ const showTabs = hasCardProviders && paypalProviderId || hasCardProviders && payToProviderId || paypalProviderId && payToProviderId;
6259
6937
  const cardOptions = required3dsProvider ? {
6260
6938
  threeDSEnabled: true,
6261
6939
  threeDsProviderId: required3dsProvider,
@@ -6265,53 +6943,88 @@ class Payfurl {
6265
6943
  threeDsProviderId: "",
6266
6944
  threeDSEmail: (options == null ? void 0 : options.threeDSEmail) || ""
6267
6945
  };
6268
- if (!showTabs && hasCardProviders) {
6269
- const container2 = document.getElementById(dropinParentId) || document.body;
6270
- (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container2, (options == null ? void 0 : options.cardProviderId) || "", amount, currency, cardOptions);
6271
- return;
6272
- }
6273
6946
  const paypalOptions = {
6274
6947
  hideShipping: false,
6275
6948
  paypalButtonStyle: null,
6276
6949
  paypalEnablePayIn4: false,
6277
6950
  transfer: null
6278
6951
  };
6952
+ const payToOptions = {
6953
+ description: String(options == null ? void 0 : options.payToDescription).trim() || "",
6954
+ maximumAmount: (options == null ? void 0 : options.payToMaximumAmount) || 0
6955
+ };
6956
+ if (!showTabs && hasCardProviders) {
6957
+ const container2 = document.getElementById(dropinParentId) || document.body;
6958
+ (_a = this.cardProcessor) == null ? void 0 : _a.addCard(container2, this.form, (options == null ? void 0 : options.cardProviderId) || "", amount, currency, cardOptions);
6959
+ return;
6960
+ }
6279
6961
  if (!showTabs && paypalProviderId) {
6280
6962
  this.addPaypal(dropinParentId, amount, currency, paypalProviderId, paypalOptions);
6281
6963
  return;
6282
6964
  }
6965
+ if (!showTabs && payToProviderId) {
6966
+ this.addPayTo(dropinParentId, amount, payToProviderId, payToOptions);
6967
+ return;
6968
+ }
6283
6969
  if (showTabs) {
6284
- renderComponent({
6285
- el: document.getElementById(dropinParentId),
6286
- component: Combined,
6287
- props: {
6288
- elements: [
6289
- {
6290
- title: "Credit Card",
6291
- icon: CreditCardIcon,
6292
- render: (container2) => {
6293
- var _a2;
6294
- (_a2 = this.cardProcessor) == null ? void 0 : _a2.addCard(container2, (options == null ? void 0 : options.cardProviderId) || "", amount, currency, cardOptions);
6295
- }
6970
+ const elements = [];
6971
+ if (hasCardProviders) {
6972
+ elements.push({
6973
+ title: "Credit Card",
6974
+ icon: CreditCardIcon,
6975
+ render: (container2) => {
6976
+ var _a2;
6977
+ (_a2 = this.cardProcessor) == null ? void 0 : _a2.addCard(container2, this.form, (options == null ? void 0 : options.cardProviderId) || "", amount, currency, cardOptions);
6978
+ },
6979
+ activate: () => {
6980
+ window.postMessage({ status: "activate", component: "card" }, "*");
6981
+ window.postMessage({ status: "deactivate", component: "paypal" }, "*");
6982
+ window.postMessage({ status: "deactivate", component: "payto" }, "*");
6983
+ }
6984
+ });
6985
+ }
6986
+ if (paypalProviderId) {
6987
+ elements.push({
6988
+ title: "Paypal",
6989
+ icon: PaypalIcon,
6990
+ render: (container2) => {
6991
+ var _a2;
6992
+ (_a2 = this.paypalProcessor) == null ? void 0 : _a2.addPaypal(container2, this.form, amount, currency, paypalProviderId, paypalOptions);
6993
+ },
6994
+ activate: () => {
6995
+ window.postMessage({ status: "activate", component: "paypal" }, "*");
6996
+ window.postMessage({ status: "deactivate", component: "card" }, "*");
6997
+ window.postMessage({ status: "deactivate", component: "payto" }, "*");
6998
+ }
6999
+ });
7000
+ }
7001
+ if (payToProviderId) {
7002
+ if (!checkEmpty(payToOptions.description)) {
7003
+ console.log("Missing parameter: PayTo Description");
7004
+ } else {
7005
+ elements.push({
7006
+ title: "PayTo",
7007
+ icon: PayToIcon,
7008
+ render: (container2) => {
7009
+ var _a2;
7010
+ (_a2 = this.payToProcessor) == null ? void 0 : _a2.addPayTo(container2, amount, payToProviderId, payToOptions);
6296
7011
  },
6297
- {
6298
- title: "Paypal",
6299
- icon: PaypalIcon,
6300
- render: (container2) => {
6301
- var _a2;
6302
- (_a2 = this.paypalProcessor) == null ? void 0 : _a2.addPaypal(container2, amount, currency, paypalProviderId, paypalOptions);
6303
- }
7012
+ activate: () => {
7013
+ window.postMessage({ status: "activate", component: "payto" }, "*");
7014
+ window.postMessage({ status: "deactivate", component: "card" }, "*");
7015
+ window.postMessage({ status: "deactivate", component: "paypal" }, "*");
6304
7016
  }
6305
- ]
7017
+ });
6306
7018
  }
7019
+ }
7020
+ renderComponent({
7021
+ el: document.getElementById(dropinParentId),
7022
+ component: Combined,
7023
+ props: { elements }
6307
7024
  });
6308
7025
  }
6309
7026
  };
6310
- if (options == null ? void 0 : options.paypalProviderId) {
6311
- this.getPaymentOptions(amount, currency, options.paypalProviderId, paymentMethodsCallback);
6312
- } else {
6313
- this.getPaymentOptions(amount, currency, "", paymentMethodsCallback);
6314
- }
7027
+ this.getPaymentOptions(amount, currency, (options == null ? void 0 : options.paypalProviderId) || "", (options == null ? void 0 : options.payToProviderId) || "", paymentMethodsCallback);
6315
7028
  return this;
6316
7029
  }
6317
7030
  addDropIn(dropinParentId, amount, currency, options) {
@@ -6325,7 +7038,17 @@ class Payfurl {
6325
7038
  var _a;
6326
7039
  const container = document.getElementById(parentId) || document.body;
6327
7040
  this._initForm(container);
6328
- (_a = this.paypalProcessor) == null ? void 0 : _a.addPaypal(container, amount, currency, providerId, options);
7041
+ (_a = this.paypalProcessor) == null ? void 0 : _a.addPaypal(container, this.form, amount, currency, providerId, options);
7042
+ return this;
7043
+ }
7044
+ addPayTo(parentId, amount, providerId, options) {
7045
+ var _a;
7046
+ if (!checkEmpty(options.description)) {
7047
+ throw new Error2("Missing parameter: description");
7048
+ }
7049
+ const container = document.getElementById(parentId) || document.body;
7050
+ this._initForm(container);
7051
+ (_a = this.payToProcessor) == null ? void 0 : _a.addPayTo(container, amount, providerId, options);
6329
7052
  return this;
6330
7053
  }
6331
7054
  addThreeDsWithFullParameters(parentId, cardNumber, cardExpiry, cardHolderName, email, amount, currency) {
@@ -6335,27 +7058,26 @@ class Payfurl {
6335
7058
  (_a = this.threeDsProcessor) == null ? void 0 : _a.addThreeDsWithFullParameters(container, cardNumber, cardExpiry, cardHolderName, email, amount, currency);
6336
7059
  return this;
6337
7060
  }
6338
- getPaymentOptions(amount, currency, overridePaypalProviderId, callback) {
7061
+ getPaymentOptions(amount, currency, overridePaypalProviderId, overridePayToProviderId, callback) {
6339
7062
  var _a;
6340
7063
  this.log("getPaymentOptions", {
6341
7064
  amount,
6342
7065
  currency,
6343
- overridePaypalProviderId
7066
+ overridePaypalProviderId,
7067
+ overridePayToProviderId
6344
7068
  });
6345
7069
  const url = this.config.apiUrl + "/info/providers?amount=" + amount + "&currency=" + currency;
6346
7070
  const failureHandler = (httpStatus, body) => {
7071
+ this.showErrorMessage("Unable to configure SDK");
6347
7072
  throw new Error2("failed to configure, error: " + body);
6348
7073
  };
6349
7074
  const successHandler = (httpStatus, body) => {
7075
+ var _a2, _b;
6350
7076
  const bodyData = JSON.parse(body);
6351
- let paypalProviderId = null;
6352
- if (overridePaypalProviderId) {
6353
- paypalProviderId = overridePaypalProviderId;
6354
- } else if (bodyData.paypalProviders.length) {
6355
- paypalProviderId = bodyData.paypalProviders[0];
6356
- }
6357
- this.log("getPaymentOptions", paypalProviderId, bodyData);
6358
- callback(bodyData.hasCardProviders, bodyData.required3dsProvider, paypalProviderId);
7077
+ const paypalProviderId = overridePaypalProviderId || ((_a2 = bodyData.paypalProviders) == null ? void 0 : _a2[0]) || null;
7078
+ const payToProviderId = overridePayToProviderId || ((_b = bodyData.payToProviders) == null ? void 0 : _b[0]) || null;
7079
+ this.log("getPaymentOptions", paypalProviderId, payToProviderId, bodyData);
7080
+ callback(bodyData.hasCardProviders, bodyData.required3dsProvider, paypalProviderId, payToProviderId);
6359
7081
  };
6360
7082
  (_a = this.httpInvoker) == null ? void 0 : _a.invoke(url, "GET", "", successHandler, failureHandler);
6361
7083
  }
@@ -6374,6 +7096,10 @@ class Payfurl {
6374
7096
  onFailure(f) {
6375
7097
  this.userOnFailure = f;
6376
7098
  }
7099
+ showErrorMessage(message) {
7100
+ this.log(message);
7101
+ showError(this.container || document.body, message);
7102
+ }
6377
7103
  }
6378
7104
  var main = new Payfurl();
6379
7105
  export { main as default };