@payfurl/client 3.0.5 → 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;
@@ -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.0/js/",
4612
+ url: "https://assets.payfurl.com/v3.1.0/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.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.5/js/",
4453
- url: "https://assets.payfurl.com/v3.0.5/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 = ["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-0c5d4794"]]);
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,37 @@ 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: {
5702
5936
  el: null,
5937
+ form: null,
5703
5938
  clientId: null,
5704
5939
  currency: null,
5705
5940
  enablePayIn4: { type: Boolean },
5706
5941
  buttonStyle: null,
5707
5942
  checkoutId: null
5708
5943
  },
5709
- emits: ["approve"],
5944
+ emits: ["approve", "submit"],
5710
5945
  setup(__props, { emit }) {
5711
5946
  const props = __props;
5947
+ const active = ref(true);
5712
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" : ""}`;
5713
5949
  function onLoad() {
5714
5950
  window.paypal.Buttons({
@@ -5723,7 +5959,33 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
5723
5959
  }
5724
5960
  }).render(props.el);
5725
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
+ });
5726
5987
  onMounted(() => {
5988
+ window.addEventListener("message", messageHandler);
5727
5989
  window.paypal = null;
5728
5990
  const scriptTag = document.createElement("script");
5729
5991
  scriptTag.src = src;
@@ -5740,6 +6002,7 @@ class PaypalProcessor {
5740
6002
  __publicField(this, "container", document.body);
5741
6003
  __publicField(this, "log");
5742
6004
  __publicField(this, "apiUrl", "");
6005
+ __publicField(this, "form", null);
5743
6006
  __publicField(this, "getPaymentOptions");
5744
6007
  __publicField(this, "failureCallback", null);
5745
6008
  __publicField(this, "successCallback", null);
@@ -5752,20 +6015,21 @@ class PaypalProcessor {
5752
6015
  this.successCallback = config2.onSuccess || null;
5753
6016
  this.httpInvoker = new HttpInvoker(config2.publicKey);
5754
6017
  }
5755
- addPaypal(container, amount, currency, providerId, options) {
6018
+ addPaypal(container, form, amount, currency, providerId, options) {
5756
6019
  this.log("[addPaypal]", { amount, currency, providerId, options });
5757
6020
  this.container = container;
6021
+ this.form = form;
5758
6022
  if (!checkCurrency(currency)) {
5759
6023
  throw new Error2("invalid currency: " + currency);
5760
6024
  }
5761
6025
  if (!checkAmount(amount)) {
5762
6026
  throw new Error2("invalid amount: " + amount);
5763
6027
  }
5764
- const callback = (hasCardProviders, required3dsProvider, providerId2) => {
6028
+ const callback = (hasCardProviders, required3dsProvider, paypalProviderId, payToProviderId) => {
5765
6029
  var _a, _b;
5766
- this.log("[getPaymentOptions][callback]", { hasCardProviders, required3dsProvider, providerId: providerId2 });
5767
- if (!providerId2) {
5768
- 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);
5769
6033
  }
5770
6034
  const { destroy: destroy2 } = renderComponent({
5771
6035
  el: this.container,
@@ -5781,7 +6045,7 @@ class PaypalProcessor {
5781
6045
  }
5782
6046
  const url = this.apiUrl + "/payment_method/checkout";
5783
6047
  const data = {
5784
- ProviderId: providerId2,
6048
+ ProviderId: paypalProviderId,
5785
6049
  Amount: amount,
5786
6050
  Currency: currency,
5787
6051
  Options: {
@@ -5807,6 +6071,7 @@ class PaypalProcessor {
5807
6071
  try {
5808
6072
  const decodedData = window.atob(checkoutData.checkoutId);
5809
6073
  data2 = JSON.parse(decodedData);
6074
+ this.log("decodedData", data2);
5810
6075
  } catch (err) {
5811
6076
  this.log("invalid checkoutId", err);
5812
6077
  return;
@@ -5844,9 +6109,10 @@ class PaypalProcessor {
5844
6109
  const checkoutId = data2.CheckoutId;
5845
6110
  renderComponent({
5846
6111
  el: this.container,
5847
- component: _sfc_main$1,
6112
+ component: _sfc_main$3,
5848
6113
  props: {
5849
6114
  el: this.container,
6115
+ form: this.form,
5850
6116
  clientId: data2.AdditionalParameters,
5851
6117
  currency,
5852
6118
  enablePayIn4: Boolean(options.paypalEnablePayIn4),
@@ -5877,21 +6143,22 @@ class PaypalProcessor {
5877
6143
  if (providerId) {
5878
6144
  callback(false, "", providerId);
5879
6145
  } else {
5880
- this.getPaymentOptions(amount, currency, "", callback);
6146
+ this.getPaymentOptions(amount, currency, "", "", callback);
5881
6147
  }
5882
6148
  }
5883
6149
  }
5884
- var Card_vue_vue_type_style_index_0_scoped_true_lang = "";
5885
- const _hoisted_1 = ["src"];
5886
- 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 = {
5887
6153
  key: 0,
5888
6154
  id: "threeDs"
5889
6155
  };
5890
- const _sfc_main = /* @__PURE__ */ defineComponent({
6156
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
5891
6157
  props: {
5892
6158
  debug: { type: Boolean },
5893
6159
  apiUrl: null,
5894
6160
  iframeSrc: null,
6161
+ form: null,
5895
6162
  publicKey: null,
5896
6163
  providerId: null,
5897
6164
  amount: null,
@@ -5908,6 +6175,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5908
6175
  const threeDSEnabled = ref(props.threeDSEnabled);
5909
6176
  ref(props.showSubmitButton);
5910
6177
  const ready = ref(false);
6178
+ const active = ref(true);
5911
6179
  function messageHandler(event) {
5912
6180
  var _a, _b;
5913
6181
  if (!((_a = event == null ? void 0 : event.data) == null ? void 0 : _a.status))
@@ -5916,10 +6184,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5916
6184
  event.stopPropagation();
5917
6185
  adjustIFrameHeight(((_b = event.data.message) == null ? void 0 : _b.height) || 0);
5918
6186
  }
5919
- 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;
5920
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
+ }
5921
6198
  emit("submit");
5922
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
+ }
5923
6206
  }
5924
6207
  onUnmounted(() => {
5925
6208
  window.removeEventListener("message", messageHandler);
@@ -5944,21 +6227,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
5944
6227
  ref_key: "iframe",
5945
6228
  ref: iframe,
5946
6229
  id: "payfurl-card-iframe"
5947
- }, null, 40, _hoisted_1),
5948
- threeDSEnabled.value ? (openBlock(), createElementBlock("div", _hoisted_2)) : createCommentVNode("", true)
6230
+ }, null, 40, _hoisted_1$2),
6231
+ threeDSEnabled.value ? (openBlock(), createElementBlock("div", _hoisted_2$2)) : createCommentVNode("", true)
5949
6232
  ], 64);
5950
6233
  };
5951
6234
  }
5952
6235
  });
5953
- var Card = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4a2f1e14"]]);
6236
+ var CardForm = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-2a78dd48"]]);
5954
6237
  class CardProcessor {
5955
6238
  constructor(log, config2) {
5956
6239
  __publicField(this, "container", document.body);
5957
6240
  __publicField(this, "threeDsContainer", document.body);
5958
6241
  __publicField(this, "iframe", null);
6242
+ __publicField(this, "form", null);
5959
6243
  __publicField(this, "log");
5960
6244
  __publicField(this, "debug", false);
5961
- __publicField(this, "environment", Environment.DEVELOPMENT);
6245
+ __publicField(this, "environment", Environment.LOCAL);
5962
6246
  __publicField(this, "apiUrl", "");
5963
6247
  __publicField(this, "url", "");
5964
6248
  __publicField(this, "publicKey", "");
@@ -5971,7 +6255,7 @@ class CardProcessor {
5971
6255
  __publicField(this, "httpInvoker");
5972
6256
  this.log = log;
5973
6257
  this.debug = config2.debug;
5974
- this.environment = config2.environment || Environment.DEVELOPMENT;
6258
+ this.environment = config2.environment || Environment.LOCAL;
5975
6259
  this.url = config2.url;
5976
6260
  this.apiUrl = config2.apiUrl;
5977
6261
  this.publicKey = config2.publicKey;
@@ -5984,7 +6268,7 @@ class CardProcessor {
5984
6268
  addThreeDsProcessor(threeDsProcessor) {
5985
6269
  this.threeDsProcessor = threeDsProcessor;
5986
6270
  }
5987
- addCard(container, providerId, amount, currency, options) {
6271
+ addCard(container, form, providerId, amount, currency, options) {
5988
6272
  this.log("[addCard]", { providerId, amount, currency, options });
5989
6273
  if (options == null ? void 0 : options.threeDSEnabled) {
5990
6274
  validateInput(amount, checkEmpty, "missing or invalid amount option", this.failureCallback);
@@ -5992,14 +6276,16 @@ class CardProcessor {
5992
6276
  this.threeDSEnabled = true;
5993
6277
  }
5994
6278
  this.container = container || document.body;
6279
+ this.form = form;
5995
6280
  this.email = (options == null ? void 0 : options.threeDSEmail) || "";
5996
6281
  renderComponent({
5997
6282
  el: this.container,
5998
- component: Card,
6283
+ component: CardForm,
5999
6284
  props: {
6000
6285
  debug: this.debug,
6001
6286
  apiUrl: this.apiUrl,
6002
6287
  iframeSrc: this.url,
6288
+ form: this.form,
6003
6289
  publicKey: this.publicKey,
6004
6290
  providerId,
6005
6291
  amount,
@@ -6086,7 +6372,7 @@ class CardProcessor {
6086
6372
  return;
6087
6373
  }
6088
6374
  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) => {
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) => {
6090
6376
  this.log("threeDs, postAuthData", postAuthData);
6091
6377
  this.tokenise(postAuthData.threeDSServerTransID);
6092
6378
  }, threeDsData);
@@ -6105,10 +6391,385 @@ class CardProcessor {
6105
6391
  (_b = this.threeDsProcessor) == null ? void 0 : _b.setAmount(amount);
6106
6392
  }
6107
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
+ }
6108
6768
  class Payfurl {
6109
6769
  constructor() {
6770
+ __publicField(this, "container", null);
6110
6771
  __publicField(this, "form", null);
6111
- __publicField(this, "environment", Environment.DEVELOPMENT);
6772
+ __publicField(this, "environment", Environment.LOCAL);
6112
6773
  __publicField(this, "debug", false);
6113
6774
  __publicField(this, "config", getConfig(Environment.PRODUCTION));
6114
6775
  __publicField(this, "publicKey", "");
@@ -6116,6 +6777,7 @@ class Payfurl {
6116
6777
  __publicField(this, "threeDsProcessor", null);
6117
6778
  __publicField(this, "paypalProcessor", null);
6118
6779
  __publicField(this, "cardProcessor", null);
6780
+ __publicField(this, "payToProcessor", null);
6119
6781
  __publicField(this, "userOnSuccess", null);
6120
6782
  __publicField(this, "userOnFailure", null);
6121
6783
  }
@@ -6137,6 +6799,8 @@ class Payfurl {
6137
6799
  if (data.token) {
6138
6800
  this._setToken(data.token);
6139
6801
  setTimeout(() => {
6802
+ var _a2;
6803
+ (_a2 = this.form) == null ? void 0 : _a2.submit();
6140
6804
  }, 500);
6141
6805
  }
6142
6806
  (_a = this.userOnSuccess) == null ? void 0 : _a.call(this, { token: data.token });
@@ -6181,6 +6845,27 @@ class Payfurl {
6181
6845
  }
6182
6846
  });
6183
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
+ });
6184
6869
  this.loadCss();
6185
6870
  return this;
6186
6871
  }
@@ -6198,6 +6883,7 @@ class Payfurl {
6198
6883
  }
6199
6884
  _initForm(container) {
6200
6885
  var _a;
6886
+ this.container = container;
6201
6887
  this.form = ((_a = container == null ? void 0 : container.parentElement) == null ? void 0 : _a.closest("form")) || null;
6202
6888
  if (!this.form)
6203
6889
  return;
@@ -6216,17 +6902,8 @@ class Payfurl {
6216
6902
  input.value = token;
6217
6903
  }
6218
6904
  _submitForm(event) {
6219
- this.log("form submitted");
6220
6905
  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;
6228
- }
6229
- window.postMessage({ status: "submit-card-form" }, "*");
6906
+ window.postMessage({ status: "submit-form" }, "*");
6230
6907
  }
6231
6908
  addCard(iframeParentId, providerId, options) {
6232
6909
  var _a;
@@ -6235,7 +6912,7 @@ class Payfurl {
6235
6912
  }
6236
6913
  const container = document.getElementById(iframeParentId) || document.body;
6237
6914
  this._initForm(container);
6238
- (_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);
6239
6916
  return this;
6240
6917
  }
6241
6918
  addCardLeastCost(iframeParentId, amount, currency, options) {
@@ -6245,17 +6922,17 @@ class Payfurl {
6245
6922
  }
6246
6923
  const container = document.getElementById(iframeParentId) || document.body;
6247
6924
  this._initForm(container);
6248
- (_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);
6249
6926
  return this;
6250
6927
  }
6251
6928
  _addDropIn(dropinParentId, amount, currency, options) {
6252
- this.log("[addDropIn]", { dropinParentId, options, amount, currency });
6929
+ this.log("[addDropIn]", { dropinParentId, amount, currency, options });
6253
6930
  const container = document.getElementById(dropinParentId) || document.body;
6254
6931
  this._initForm(container);
6255
- const paymentMethodsCallback = (hasCardProviders, required3dsProvider, paypalProviderId) => {
6932
+ const paymentMethodsCallback = (hasCardProviders, required3dsProvider, paypalProviderId, payToProviderId) => {
6256
6933
  var _a;
6257
- this.log("[paymentMethodsCallback]", { hasCardProviders, required3dsProvider, paypalProviderId });
6258
- const showTabs = hasCardProviders && paypalProviderId;
6934
+ this.log("[paymentMethodsCallback]", { hasCardProviders, required3dsProvider, paypalProviderId, payToProviderId });
6935
+ const showTabs = hasCardProviders && paypalProviderId || hasCardProviders && payToProviderId || paypalProviderId && payToProviderId;
6259
6936
  const cardOptions = required3dsProvider ? {
6260
6937
  threeDSEnabled: true,
6261
6938
  threeDsProviderId: required3dsProvider,
@@ -6265,53 +6942,88 @@ class Payfurl {
6265
6942
  threeDsProviderId: "",
6266
6943
  threeDSEmail: (options == null ? void 0 : options.threeDSEmail) || ""
6267
6944
  };
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
6945
  const paypalOptions = {
6274
6946
  hideShipping: false,
6275
6947
  paypalButtonStyle: null,
6276
6948
  paypalEnablePayIn4: false,
6277
6949
  transfer: null
6278
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
+ }
6279
6960
  if (!showTabs && paypalProviderId) {
6280
6961
  this.addPaypal(dropinParentId, amount, currency, paypalProviderId, paypalOptions);
6281
6962
  return;
6282
6963
  }
6964
+ if (!showTabs && payToProviderId) {
6965
+ this.addPayTo(dropinParentId, amount, payToProviderId, payToOptions);
6966
+ return;
6967
+ }
6283
6968
  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
- }
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);
6296
7010
  },
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
- }
7011
+ activate: () => {
7012
+ window.postMessage({ status: "activate", component: "payto" }, "*");
7013
+ window.postMessage({ status: "deactivate", component: "card" }, "*");
7014
+ window.postMessage({ status: "deactivate", component: "paypal" }, "*");
6304
7015
  }
6305
- ]
7016
+ });
6306
7017
  }
7018
+ }
7019
+ renderComponent({
7020
+ el: document.getElementById(dropinParentId),
7021
+ component: Combined,
7022
+ props: { elements }
6307
7023
  });
6308
7024
  }
6309
7025
  };
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
- }
7026
+ this.getPaymentOptions(amount, currency, (options == null ? void 0 : options.paypalProviderId) || "", (options == null ? void 0 : options.payToProviderId) || "", paymentMethodsCallback);
6315
7027
  return this;
6316
7028
  }
6317
7029
  addDropIn(dropinParentId, amount, currency, options) {
@@ -6325,7 +7037,17 @@ class Payfurl {
6325
7037
  var _a;
6326
7038
  const container = document.getElementById(parentId) || document.body;
6327
7039
  this._initForm(container);
6328
- (_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);
6329
7051
  return this;
6330
7052
  }
6331
7053
  addThreeDsWithFullParameters(parentId, cardNumber, cardExpiry, cardHolderName, email, amount, currency) {
@@ -6335,27 +7057,26 @@ class Payfurl {
6335
7057
  (_a = this.threeDsProcessor) == null ? void 0 : _a.addThreeDsWithFullParameters(container, cardNumber, cardExpiry, cardHolderName, email, amount, currency);
6336
7058
  return this;
6337
7059
  }
6338
- getPaymentOptions(amount, currency, overridePaypalProviderId, callback) {
7060
+ getPaymentOptions(amount, currency, overridePaypalProviderId, overridePayToProviderId, callback) {
6339
7061
  var _a;
6340
7062
  this.log("getPaymentOptions", {
6341
7063
  amount,
6342
7064
  currency,
6343
- overridePaypalProviderId
7065
+ overridePaypalProviderId,
7066
+ overridePayToProviderId
6344
7067
  });
6345
7068
  const url = this.config.apiUrl + "/info/providers?amount=" + amount + "&currency=" + currency;
6346
7069
  const failureHandler = (httpStatus, body) => {
7070
+ this.showErrorMessage("Unable to configure SDK");
6347
7071
  throw new Error2("failed to configure, error: " + body);
6348
7072
  };
6349
7073
  const successHandler = (httpStatus, body) => {
7074
+ var _a2, _b;
6350
7075
  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);
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);
6359
7080
  };
6360
7081
  (_a = this.httpInvoker) == null ? void 0 : _a.invoke(url, "GET", "", successHandler, failureHandler);
6361
7082
  }
@@ -6374,6 +7095,10 @@ class Payfurl {
6374
7095
  onFailure(f) {
6375
7096
  this.userOnFailure = f;
6376
7097
  }
7098
+ showErrorMessage(message) {
7099
+ this.log(message);
7100
+ showError(this.container || document.body, message);
7101
+ }
6377
7102
  }
6378
7103
  var main = new Payfurl();
6379
7104
  export { main as default };