@payfurl/react-plugin 1.5.0 → 1.6.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.
Files changed (27) hide show
  1. package/README.md +11 -0
  2. package/dist/DefaultThreeDsProvider-BS9pznAi-fDl8jKzq.js +248 -0
  3. package/dist/{MetricsGlobalThreeDsProvider-C93ttqbB-SRsVMed4.js → MetricsGlobalThreeDsProvider-C2mH6Z-m-BTiFsRgv.js} +27 -27
  4. package/dist/PayWayAppleButton-BcXMphiU-BwJKfUAJ.js +184 -0
  5. package/dist/{cxpay-DblHb5vN-C-l0lncv.js → cxpay-Bdz9DX5E-9-_yu7t4.js} +1 -1
  6. package/dist/{default-C7f86Fx--2njdEIN4.js → default-CmqRUII8-B6Im_IPh.js} +1 -1
  7. package/dist/{ecentric-B3UohyO_-XSxfe46h.js → ecentric-CZzDL4aQ-BRg09Y8f.js} +26 -23
  8. package/dist/{epna-DwUg2IlB-60mxqUE4.js → epna-A5WIS8Rv-DhjWr-Wx.js} +1 -1
  9. package/dist/{flashbanc-LXs8bahL-z2X9avF_.js → flashbanc-BnKR75SO-BStfAWAb.js} +1 -1
  10. package/dist/{forter-CLFaJUYa-0_gstIhb.js → forter-DtCvNxaz-D5SEPByD.js} +7 -7
  11. package/dist/{gpayments-DoZug3PV-r91JBiIn.js → gpayments-C98_oxi_-D02_MfHY.js} +20 -20
  12. package/dist/index-CqIxTjar.js +12169 -0
  13. package/dist/metrics_global-c4lRSySk-WxebdZ3j.js +7 -0
  14. package/dist/{nmi-BA3ZTdQa-DHWaU-52.js → nmi-CrPg94-y-Bco-VeX9.js} +1 -1
  15. package/dist/{nuvei-DIWsLlLz-Dnx1Hmez.js → nuvei-8V5Z1Bqi-7VHagYOe.js} +31 -32
  16. package/dist/{payabli-DgrTI1Et-aNWdpC9M.js → payabli-CAvI6xn--Nz5dJc0q.js} +1 -1
  17. package/dist/payfurl-react.es.js +1 -1
  18. package/dist/payfurl-react.umd.js +24 -22
  19. package/dist/payglocal-BcbX7wj--Dd68qYZO.js +114 -0
  20. package/dist/{payway_rest-D8-T-ULx-Dt-XGc-v.js → payway_rest-Det6oVYM-BzfFo5sS.js} +1 -1
  21. package/dist/{skybank-BgDLlFXX-BnauHbzw.js → skybank-CldRW65N-BFprFe0k.js} +1 -1
  22. package/package.json +2 -2
  23. package/dist/DefaultThreeDsProvider-bLoDSnkd-CuWxvLku.js +0 -220
  24. package/dist/PayWayAppleButton-BzAwlGS--DB5BVl1o.js +0 -163
  25. package/dist/index-DxOlzt-Z.js +0 -11576
  26. package/dist/metrics_global-BM-ooge--CapUrY7a.js +0 -7
  27. package/dist/payglocal-ezp0MsaZ-CA7TeuKm.js +0 -109
package/README.md CHANGED
@@ -95,6 +95,17 @@ and `OrderInfoType`.
95
95
  What changed in each version of `@payfurl/react-plugin`. Changes to the payment form itself are in the
96
96
  [Client SDK changelog](https://docs.payfurl.com/client_sdk/changelog). This changelog starts with version 1.4.0.
97
97
 
98
+ ### 1.6.0
99
+
100
+ #### Changed
101
+
102
+ - Bundles `@payfurl/client` 4.12.0 (see its changelog). Each payment attempt is recorded with payFURL from its first
103
+ request to its end, PayPal and the checkout payment methods create their checkout when the shopper clicks, and a
104
+ payment page polled for too long stops with `onFailure`.
105
+ - When the component unmounts, the drop-in is removed: its status checks and listeners stop, a payment window it
106
+ opened closes, and `onSuccess` and `onFailure` no longer fire for it.
107
+ - Depends on `@payfurl/client` 4.12.0 or later.
108
+
98
109
  ### 1.5.0
99
110
 
100
111
  #### Added
@@ -0,0 +1,248 @@
1
+ var g = Object.defineProperty;
2
+ var m = (o, e, s) => e in o ? g(o, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : o[e] = s;
3
+ var r = (o, e, s) => m(o, typeof e != "symbol" ? e + "" : e, s);
4
+ import { M as p, N as T, q as I, i as u, v as f, u as v, e as y, a as A, t as M, X as c, Z as w, S as C, r as R, z as U, b, c as P, l as E } from "./index-CqIxTjar.js";
5
+ var $ = { class: "mask" }, L = { class: "wrapper" }, _ = { class: "container" }, k = ["action"], q = ["value"], O = /* @__PURE__ */ v(/* @__PURE__ */ y({
6
+ __name: "ThreeDsChallenge",
7
+ props: {
8
+ threeDSServerTransID: {},
9
+ acsTransID: {},
10
+ formAction: {}
11
+ },
12
+ emits: ["close", "submit"],
13
+ setup(o, { emit: e }) {
14
+ let s = o, t = e, i = U(() => E(s.formAction) ? s.formAction : ""), a = b(null), d = JSON.stringify({
15
+ threeDSServerTransID: s.threeDSServerTransID,
16
+ acsTransID: s.acsTransID,
17
+ messageVersion: "2.2.0",
18
+ messageType: "CReq",
19
+ challengeWindowSize: "01"
20
+ }), D = encodeURI(window.btoa(d).replace(/=*$/, ""));
21
+ return A(() => {
22
+ var n;
23
+ i.value && ((n = a.value) == null || n.submit());
24
+ }), (n, l) => (P(), M("div", $, [c("div", L, [c("div", _, [
25
+ w(C, {
26
+ onClick: l[0] || (l[0] = (F) => t("close")),
27
+ id: "3ds-challenge-close"
28
+ }),
29
+ l[1] || (l[1] = c("iframe", { name: "ThreeDsChallengeIFrame" }, null, -1)),
30
+ c("form", {
31
+ action: i.value,
32
+ target: "ThreeDsChallengeIFrame",
33
+ method: "post",
34
+ ref_key: "form",
35
+ ref: a
36
+ }, [c("input", {
37
+ type: "hidden",
38
+ name: "creq",
39
+ value: R(D)
40
+ }, null, 8, q)], 8, k)
41
+ ])])]));
42
+ }
43
+ }), [["__scopeId", "data-v-07081e85"]]), V = class {
44
+ constructor() {
45
+ r(this, "iframeId", "threeDsIframeMethod");
46
+ r(this, "containerId", "payfurlContainerFormInvoker");
47
+ r(this, "iframe", null);
48
+ r(this, "container", null);
49
+ }
50
+ createIFrame() {
51
+ this.iframe || (this.container = document.createElement("div"), this.container.id = this.containerId, document.body.appendChild(this.container), this.iframe = document.createElement("iframe"), this.iframe.name = this.iframeId, this.iframe.style.display = "none", this.container.appendChild(this.iframe));
52
+ }
53
+ invoke(o, e, s, t, i) {
54
+ var d;
55
+ this.createIFrame();
56
+ let a = document.createElement("form");
57
+ a.action = o, a.target = this.iframeId, a.method = "post", (d = this.container) == null || d.appendChild(a);
58
+ for (let D in s) {
59
+ let n = document.createElement("input");
60
+ n.type = "hidden", n.name = D, n.value = s[D], a.appendChild(n);
61
+ }
62
+ a.submit();
63
+ }
64
+ }, { hideSpinner: S, showSpinner: N } = f(), h, x = (h = class {
65
+ constructor(e, s, t) {
66
+ r(this, "log");
67
+ r(this, "container");
68
+ r(this, "options");
69
+ r(this, "threeDsProcessor", null);
70
+ r(this, "threeDSDestroy", () => {
71
+ });
72
+ r(this, "threeDSServerTransID", "");
73
+ r(this, "threeDSAuthURL", "");
74
+ r(this, "threeDSRequestorTransID", "");
75
+ r(this, "threeDSMonitorURL", "");
76
+ r(this, "internalMessageHandler", this.messageHandler.bind(this));
77
+ r(this, "awaitingMethod", !1);
78
+ r(this, "methodTimer");
79
+ r(this, "onError", (e, s) => {
80
+ this.fail(e, s, "error");
81
+ });
82
+ r(this, "onSuccess", (e, s) => {
83
+ var i, a;
84
+ this.closeChallenge(), S();
85
+ let t = JSON.parse(s);
86
+ ["Y", "A"].includes(t.transStatus) ? (i = this.threeDsProcessor) == null || i.onSuccess(t) : (this.log(`[${this.getType()}]: ${u}`, t), (a = this.threeDsProcessor) == null || a.onError({
87
+ error: u,
88
+ threeDSServerTransID: t.threeDSServerTransID
89
+ }));
90
+ });
91
+ r(this, "onInitAuthSuccess", (e, s) => {
92
+ let t = JSON.parse(s);
93
+ this.log(`[${this.getType()}][onInitAuthSuccess]`, t), this.threeDSRequestorTransID = t.threeDSRequestorTransID, this.threeDSServerTransID = t.threeDSServerTransID, this.threeDSMonitorURL = t.threeDSMonitorURL, this.threeDSAuthURL = t.threeDSAuthURL, t.threeDSMethodURL ? (this.awaitMethod(), this.threeDsMethodInvoke(t.threeDSServerTransID, t.threeDSMethodURL)) : this.onAuth(!1, "");
94
+ });
95
+ r(this, "onDoAuthSuccess", (e, s) => {
96
+ var i;
97
+ let t = JSON.parse(s);
98
+ if (this.log(`[${this.getType()}][onDoAuthSuccess]`, t), !t.transStatus) this.onError(e, "No transStatus specified");
99
+ else switch (t.transStatus) {
100
+ case "C":
101
+ if (!t.acsURL) {
102
+ this.onError(e, "Invalid Challenge Url");
103
+ return;
104
+ }
105
+ this.doChallenge(t.acsURL, t.acsTransID, t.authenticationValue);
106
+ break;
107
+ case "N":
108
+ this.log(`[${this.getType()}][threeDsAuth], 3DS Verification failed, transaction denied`), this.decline("3DS Verification failed, transaction denied");
109
+ break;
110
+ case "U":
111
+ this.log(`[${this.getType()}][threeDsAuth], Unable to perform 3DS verification`), this.decline("Unable to perform 3DS verification");
112
+ break;
113
+ case "R":
114
+ this.log(`[${this.getType()}][threeDsAuth], Unable to perform 3DS verification, rejected at issuer`), this.decline("Unable to perform 3DS verification, rejected at issuer");
115
+ break;
116
+ default:
117
+ this.log(`[${this.getType()}][threeDsAuth], 3DS challenge not required, tranStatus: ${t.transStatus}`), (i = this.threeDsProcessor) == null || i.onSuccess({
118
+ threeDSServerTransID: t.threeDSServerTransID,
119
+ threeDSRequestorTransID: "",
120
+ acsRenderingType: t.acsRenderingType,
121
+ acsTransID: t.acsTransID,
122
+ authenticationType: t.authenticationType,
123
+ authenticationValue: t.authenticationValue,
124
+ challengeCancel: "",
125
+ dsTransID: t.dsTransID,
126
+ eci: t.eci,
127
+ interactionCounter: "",
128
+ messageCategory: "",
129
+ messageExtension: t.messageExtension,
130
+ messageType: t.messageType,
131
+ messageVersion: t.messageVersion,
132
+ transStatus: t.transStatus,
133
+ transStatusReason: t.transStatusReason
134
+ });
135
+ }
136
+ });
137
+ this.log = e, this.container = s, this.options = t;
138
+ }
139
+ getType() {
140
+ return "Default";
141
+ }
142
+ getDomain() {
143
+ return "";
144
+ }
145
+ onPreAuth() {
146
+ this.log(`[${this.getType()}][onPreAuth]`), this.threeDsProcessor && (this.stopAwaitingMethod(), N(), this.threeDsProcessor.onPreAuth(this.onInitAuthSuccess, this.onError), window.addEventListener("message", this.internalMessageHandler));
147
+ }
148
+ onAuth(e, s) {
149
+ var t;
150
+ this.log(`[${this.getType()}][onAuth]`, {
151
+ threeDSAuthURL: this.threeDSAuthURL,
152
+ threeDSRequestorTransID: this.threeDSRequestorTransID,
153
+ threeDSServerTransID: this.threeDSServerTransID,
154
+ isMethodPerformed: e
155
+ }), (t = this.threeDsProcessor) == null || t.onAuth(this.threeDSAuthURL, this.threeDSRequestorTransID, this.threeDSServerTransID, e, s, this.onDoAuthSuccess, this.onError);
156
+ }
157
+ onPostAuth() {
158
+ var e;
159
+ this.log(`[${this.getType()}][onPostAuth]`, { threeDSServerTransID: this.threeDSServerTransID }), (e = this.threeDsProcessor) == null || e.onPostAuth({ threeDSServerTransID: this.threeDSServerTransID }, this.onSuccess, this.onError);
160
+ }
161
+ setThreeDsProcessor(e) {
162
+ this.log(`[${this.getType()}][setThreeDsProcessor]`), this.threeDsProcessor = e;
163
+ }
164
+ messageHandler(e) {
165
+ var s, t;
166
+ (s = e == null ? void 0 : e.data) != null && s.status && ((t = e == null ? void 0 : e.data) == null ? void 0 : t.status) !== "tokenise-card-failure" && (e.data.status === "3ds_method_invocation_complete" ? (e.stopPropagation(), this.invocationComplete(e)) : e.data.status === "3ds_challenge_complete" && (e.stopPropagation(), this.challengeComplete(e)));
167
+ }
168
+ invocationComplete(e) {
169
+ this.awaitingMethod && (this.awaitingMethod = !1, clearTimeout(this.methodTimer), this.log(`[${this.getType()}]: 3Ds Method invocation complete`), this.onAuth(!0, ""));
170
+ }
171
+ stopAwaitingMethod() {
172
+ this.awaitingMethod = !1, clearTimeout(this.methodTimer);
173
+ }
174
+ awaitMethod() {
175
+ this.awaitingMethod = !0, clearTimeout(this.methodTimer), this.methodTimer = setTimeout(() => {
176
+ this.awaitingMethod && (this.awaitingMethod = !1, this.log(`[${this.getType()}]: 3Ds Method did not answer, continuing without it`), this.onAuth(!1, ""));
177
+ }, h.METHOD_TIMEOUT_MS);
178
+ }
179
+ challengeComplete(e) {
180
+ this.log(`[${this.getType()}]: 3Ds Challenge complete`, e.data), this.closeChallenge();
181
+ let s = {};
182
+ try {
183
+ s = JSON.parse(window.atob(e.data.cres));
184
+ } catch {
185
+ this.onError(400, "Unreadable challenge result");
186
+ return;
187
+ }
188
+ this.log(`[${this.getType()}]: cresData`, s), ["Y", "A"].includes(String(s.transStatus)) ? this.onPostAuth() : (this.log(`[${this.getType()}]: Failed 3DS Challenge`, e.data), this.decline("Failed 3DS Challenge"));
189
+ }
190
+ setChallengeFrameVisible(e) {
191
+ var s;
192
+ e && ((s = this.threeDsProcessor) == null || s.challengeShown()), window.self !== window.top && window.parent.postMessage({ status: e ? p : T }, "*");
193
+ }
194
+ doChallenge(e, s, t) {
195
+ this.log(`[${this.getType()}][doChallenge]`), S(), this.setChallengeFrameVisible(!0);
196
+ let { destroy: i } = I({
197
+ el: document.body,
198
+ component: O,
199
+ props: {
200
+ threeDSServerTransID: this.threeDSServerTransID,
201
+ acsTransID: s,
202
+ formAction: e,
203
+ authenticationValue: t
204
+ },
205
+ on: { close: () => {
206
+ var a;
207
+ i(), this.threeDSDestroy = () => {
208
+ }, (a = this.threeDsProcessor) == null || a.onError({
209
+ error: "Challenge cancelled",
210
+ cancelReason: "abandoned"
211
+ });
212
+ } }
213
+ });
214
+ this.threeDSDestroy = i;
215
+ }
216
+ closeChallenge() {
217
+ var e;
218
+ this.stopAwaitingMethod(), (e = this.threeDSDestroy) == null || e.call(this), this.setChallengeFrameVisible(!1), window.removeEventListener("message", this.internalMessageHandler);
219
+ }
220
+ decline(e) {
221
+ this.fail(400, e, "declined");
222
+ }
223
+ fail(e, s, t) {
224
+ var i, a;
225
+ this.closeChallenge(), S(), e === 404 ? (i = this.threeDsProcessor) == null || i.onError({
226
+ error: "This feature is only supported by ActiveServer v1.1.2+",
227
+ cancelReason: t
228
+ }) : (a = this.threeDsProcessor) == null || a.onError({
229
+ error: u,
230
+ body: s,
231
+ cancelReason: t
232
+ });
233
+ }
234
+ threeDsMethodInvoke(e, s) {
235
+ this.log(`[${this.getType()}][threeDsMethodInvoke]`, {
236
+ threeDSServerTransID: e,
237
+ threeDSMethodURL: s
238
+ });
239
+ let t = {
240
+ threeDSServerTransID: e,
241
+ threeDSMethodNotificationURL: this.options.apiUrl + "/3ds/method_invocation"
242
+ }, i = encodeURI(window.btoa(JSON.stringify(t)).replace(/=*$/, ""));
243
+ new V().invoke(s, "POST", { threeDSMethodData: i });
244
+ }
245
+ }, r(h, "METHOD_TIMEOUT_MS", 1e4), h);
246
+ export {
247
+ x as O
248
+ };
@@ -1,9 +1,9 @@
1
- var L = Object.defineProperty;
2
- var _ = (h, s, e) => s in h ? L(h, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[s] = e;
3
- var c = (h, s, e) => _(h, typeof s != "symbol" ? s + "" : s, e);
4
- import { O as x } from "./DefaultThreeDsProvider-bLoDSnkd-CuWxvLku.js";
5
- import { j as d, p as I, W as G, h as N, s as H, Z as F, a as M, k as O, P as k, r as W, Q as Z, X as m, b as j, g as U, c as V, q } from "./index-DxOlzt-Z.js";
6
- var J = { class: "mask" }, Q = { class: "wrapper" }, R = { class: "container" }, X = /* @__PURE__ */ H(/* @__PURE__ */ F({
1
+ var f = Object.defineProperty;
2
+ var _ = (h, s, e) => s in h ? f(h, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[s] = e;
3
+ var g = (h, s, e) => _(h, typeof s != "symbol" ? s + "" : s, e);
4
+ import { O as x } from "./DefaultThreeDsProvider-BS9pznAi-fDl8jKzq.js";
5
+ import { j as d, m as I, q as G, v as N, u as H, e as F, a as M, y as O, L as k, $ as j, t as U, X as m, Z as W, S as $, b as V, c as q } from "./index-CqIxTjar.js";
6
+ var J = { class: "mask" }, R = { class: "wrapper" }, X = { class: "container" }, Z = /* @__PURE__ */ H(/* @__PURE__ */ F({
7
7
  __name: "MetricsGlobalThreeDsChallenge",
8
8
  emits: ["close", "submit"],
9
9
  setup(h, { emit: s }) {
@@ -16,18 +16,18 @@ var J = { class: "mask" }, Q = { class: "wrapper" }, R = { class: "container" },
16
16
  window.addEventListener("message", i);
17
17
  }), O(() => {
18
18
  window.removeEventListener("message", i);
19
- }), (n, r) => k((q(), Z("div", J, [m("div", Q, [m("div", R, [j(U, {
19
+ }), (n, r) => k((q(), U("div", J, [m("div", R, [m("div", X, [W($, {
20
20
  onClick: r[0] || (r[0] = (p) => e("close")),
21
21
  id: "3ds-challenge-close"
22
- }), r[1] || (r[1] = m("div", { id: "ThreeDsChallengeIFrame" }, null, -1))])])], 512)), [[W, t.value]]);
22
+ }), r[1] || (r[1] = m("div", { id: "ThreeDsChallengeIFrame" }, null, -1))])])], 512)), [[j, t.value]]);
23
23
  }
24
- }), [["__scopeId", "data-v-8a0b6dcb"]]), { hideSpinner: l, showSpinner: $ } = N(), u = 5, B = class extends x {
24
+ }), [["__scopeId", "data-v-8a0b6dcb"]]), { hideSpinner: l, showSpinner: z } = N(), u = 5, Q = class extends x {
25
25
  constructor(s, e, t) {
26
26
  var i;
27
27
  super(s, e, t);
28
- c(this, "gateway");
29
- c(this, "threeDS");
30
- c(this, "numAttempts", 0);
28
+ g(this, "gateway");
29
+ g(this, "threeDS");
30
+ g(this, "numAttempts", 0);
31
31
  this.initScript(((i = t.clientParameters) == null ? void 0 : i.PublicKey) || "");
32
32
  }
33
33
  getType() {
@@ -48,31 +48,31 @@ var J = { class: "mask" }, Q = { class: "wrapper" }, R = { class: "container" },
48
48
  onPostAuth() {
49
49
  }
50
50
  startAuth(s) {
51
- var y, w, C, S, b, E, P, v;
51
+ var D, w, S, C, b, E, v, P;
52
52
  this.log(`[${this.getType()}]: startAuth`);
53
- let e = (y = this.threeDsProcessor) == null ? void 0 : y.getPaymentInfo();
53
+ let e = (D = this.threeDsProcessor) == null ? void 0 : D.getPaymentInfo();
54
54
  if (!e) {
55
55
  l(), d(this.container, "Payment information is missing");
56
56
  return;
57
57
  }
58
- $();
59
- let t = (w = this.threeDsProcessor) == null ? void 0 : w.getAddressInfo(), i = e.expiryDate.length === 4 ? e.expiryDate.slice(2, 4) : "", n = e.expiryDate.length === 4 ? e.expiryDate.slice(0, 2) : "", [r = "", p = ""] = ((C = e.cardholder) == null ? void 0 : C.split(/\s+/)) || [], A = ((S = this.threeDsProcessor) == null ? void 0 : S.getCurrency()) || "", f = ((b = this.threeDsProcessor) == null ? void 0 : b.getAmount()) || 0;
58
+ z();
59
+ let t = (w = this.threeDsProcessor) == null ? void 0 : w.getAddressInfo(), i = e.expiryDate.length === 4 ? e.expiryDate.slice(2, 4) : "", n = e.expiryDate.length === 4 ? e.expiryDate.slice(0, 2) : "", [r = "", p = ""] = ((S = e.cardholder) == null ? void 0 : S.split(/\s+/)) || [], A = ((C = this.threeDsProcessor) == null ? void 0 : C.getCurrency()) || "", L = ((b = this.threeDsProcessor) == null ? void 0 : b.getAmount()) || 0;
60
60
  if (!s && (!i || !n)) {
61
61
  l(), d(this.container, "Card expiry date is invalid"), (E = this.threeDsProcessor) == null || E.onError({ error: "Card expiry date is invalid" });
62
62
  return;
63
63
  }
64
- let D = (P = s == null ? void 0 : s.gatewayMetadata) == null ? void 0 : P.billing_id, T = {
64
+ let y = (v = s == null ? void 0 : s.gatewayMetadata) == null ? void 0 : v.billing_id, T = {
65
65
  ...s ? {
66
66
  customerVaultId: s.gatewayTokenId,
67
- ...D ? { billingId: D } : {}
67
+ ...y ? { billingId: y } : {}
68
68
  } : {
69
69
  cardNumber: e.cardNumber,
70
70
  cardExpMonth: i,
71
71
  cardExpYear: String(parseInt(n, 10) + 2e3)
72
72
  },
73
73
  currency: A,
74
- amount: f.toFixed(2),
75
- email: (v = this.threeDsProcessor) == null ? void 0 : v.getEmail(),
74
+ amount: L.toFixed(2),
75
+ email: (P = this.threeDsProcessor) == null ? void 0 : P.getEmail(),
76
76
  phone: t == null ? void 0 : t.phoneNumber,
77
77
  city: t == null ? void 0 : t.city,
78
78
  state: t == null ? void 0 : t.state,
@@ -90,16 +90,16 @@ var J = { class: "mask" }, Q = { class: "wrapper" }, R = { class: "container" },
90
90
  browserScreenWidth: String(screen.width),
91
91
  browserTimeZone: String(Math.round((/* @__PURE__ */ new Date()).getTimezoneOffset() / 60)),
92
92
  userAgent: navigator.userAgent
93
- }, g = this.threeDS.createUI(T);
94
- g.start("#ThreeDsChallengeIFrame"), g.on("challenge", (a) => {
93
+ }, c = this.threeDS.createUI(T);
94
+ c.start("#ThreeDsChallengeIFrame"), c.on("challenge", (a) => {
95
95
  this.log(`[${this.getType()}][onChallenge]`, a), l(), this.showChallenge();
96
- }), g.on("complete", (a) => {
96
+ }), c.on("complete", (a) => {
97
97
  var o;
98
98
  this.log(`[${this.getType()}][onComplete]`, a), this.removeChallenge(), (o = this.threeDsProcessor) == null || o.onSuccess({ externalThreeDsData: a });
99
- }), g.on("failure", (a) => {
99
+ }), c.on("failure", (a) => {
100
100
  var o;
101
101
  this.log(`[${this.getType()}][onFailure]`, a), l(), this.closeChallenge(), (o = this.threeDsProcessor) == null || o.onError({ error: a.message });
102
- }), g.on("error", (a) => {
102
+ }), c.on("error", (a) => {
103
103
  var o;
104
104
  this.log(`[${this.getType()}][error]`, a), l(), this.closeChallenge(), (o = this.threeDsProcessor) == null || o.onError({ error: a.message });
105
105
  });
@@ -119,7 +119,7 @@ var J = { class: "mask" }, Q = { class: "wrapper" }, R = { class: "container" },
119
119
  initChallenge() {
120
120
  let { destroy: s } = G({
121
121
  el: document.body,
122
- component: X,
122
+ component: Z,
123
123
  on: { close: () => {
124
124
  var e;
125
125
  this.closeChallenge(), (e = this.threeDsProcessor) == null || e.onError({ error: "Challenge cancelled" });
@@ -139,5 +139,5 @@ var J = { class: "mask" }, Q = { class: "wrapper" }, R = { class: "container" },
139
139
  }
140
140
  };
141
141
  export {
142
- B as w
142
+ Q as w
143
143
  };
@@ -0,0 +1,184 @@
1
+ var b = Object.defineProperty;
2
+ var g = (t, i, s) => i in t ? b(t, i, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[i] = s;
3
+ var r = (t, i, s) => g(t, typeof i != "symbol" ? i + "" : i, s);
4
+ import { R as A, B as v, F as I, A as P, h as m, p as C, g as k } from "./index-CqIxTjar.js";
5
+ var h = {
6
+ CHECKOUT: "CHECKOUT",
7
+ CHARGE: "CHARGE"
8
+ }, c = (t) => ({
9
+ [h.CHECKOUT]: {
10
+ url: t + "/payment_method/checkout",
11
+ method: "POST"
12
+ },
13
+ [h.CHARGE]: {
14
+ url: t + "/charge/checkout",
15
+ method: "POST"
16
+ }
17
+ }), B = class {
18
+ constructor(t, i, s, a, o, e) {
19
+ r(this, "log");
20
+ r(this, "container");
21
+ r(this, "button", null);
22
+ r(this, "validator", null);
23
+ r(this, "validationError", null);
24
+ r(this, "providerId");
25
+ r(this, "apiUrl");
26
+ r(this, "amount");
27
+ r(this, "currency");
28
+ r(this, "clientParameters");
29
+ r(this, "billingAddress", null);
30
+ r(this, "customer", null);
31
+ r(this, "order", null);
32
+ r(this, "buttonId", "apple-pay-payway-button");
33
+ r(this, "validatorId", "apple-pay-payway-button-validator");
34
+ r(this, "onLoad", () => {
35
+ });
36
+ r(this, "onSuccess");
37
+ r(this, "onFailure");
38
+ r(this, "userOnValidate");
39
+ r(this, "httpInvoker", null);
40
+ this.log = t, this.apiUrl = e.apiUrl, this.container = i || document.body, this.clientParameters = e.clientParameters, this.providerId = e.providerId, this.amount = Number(a), this.currency = o, this.providerId = s, this.onSuccess = e.onSuccess || null, this.onFailure = e.onFailure || null, this.userOnValidate = e.onValidate;
41
+ let n = new A(e.environment, v(e.publicKey));
42
+ this.httpInvoker = new I(e.publicKey, e.version, n), this.init(), setInterval(() => {
43
+ var u;
44
+ this.validator && (((u = this.userOnValidate) == null ? void 0 : u.call(this)) === !1 ? this.validator.style.display = "block" : (this.validator.style.display = "none", this.validationError && (this.validationError.style.display = "none")));
45
+ }, 1e3);
46
+ }
47
+ draw() {
48
+ let t = () => {
49
+ this.onLoad = () => {
50
+ };
51
+ let i = {
52
+ container: this.buttonId,
53
+ publishableApiKey: this.clientParameters.PublishableApiKey,
54
+ principalAmount: this.amount,
55
+ currency: String(this.currency).toLowerCase(),
56
+ buttonMode: "callback"
57
+ };
58
+ this.log("[createPaymentRequestButton]", i), window.payway.createPaymentRequestButton(i, (s, a) => {
59
+ var e;
60
+ this.log("[createPaymentRequestButton]", s, a);
61
+ let o = C();
62
+ s ? (k(this.httpInvoker, this.apiUrl, o, this.providerId, "error", {
63
+ detail: typeof (s == null ? void 0 : s.error) == "string" ? s.error : void 0,
64
+ type: "APPLEPAY"
65
+ }), (e = this.onFailure) == null || e.call(this, s)) : this.checkout(a.singleUseTokenId, o);
66
+ }), this.addValidator();
67
+ };
68
+ window.payway ? t() : this.onLoad = t;
69
+ }
70
+ show() {
71
+ this.button && (this.button.style.display = "block");
72
+ }
73
+ hide() {
74
+ this.button && (this.button.style.display = "none");
75
+ }
76
+ init() {
77
+ let t = document.createElement("div");
78
+ t.id = this.buttonId, t.style.position = "relative", this.container.appendChild(t), this.button = t, this.initScript();
79
+ }
80
+ addValidator() {
81
+ var i;
82
+ if (document.getElementById(this.validatorId)) return;
83
+ let t = document.createElement("div");
84
+ t.id = this.validatorId, t.style.width = "100%", t.style.height = "100%", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.display = "none", (i = this.button) == null || i.appendChild(t), this.validator = t;
85
+ }
86
+ initScript() {
87
+ let t = document.createElement("script");
88
+ t.src = "https://api.payway.com.au/rest/v1/payway.js", t.onerror = () => P("[shopper][applePay]", "PayWay script failed to load", []), t.onload = () => {
89
+ this.onLoad && this.onLoad();
90
+ }, document.head.appendChild(t);
91
+ }
92
+ checkout(t, i) {
93
+ var a, o, e, n, u, p;
94
+ let s = {
95
+ providerId: this.providerId,
96
+ amount: this.amount,
97
+ currency: this.currency,
98
+ reference: (a = this.order) == null ? void 0 : a.orderNumber,
99
+ options: { ProviderToken: t },
100
+ customer: {
101
+ firstName: (o = this.customer) == null ? void 0 : o.firstName,
102
+ lastName: (e = this.customer) == null ? void 0 : e.lastName,
103
+ email: (n = this.customer) == null ? void 0 : n.email,
104
+ phone: (u = this.customer) == null ? void 0 : u.phoneNumber,
105
+ billingAddress: this.billingAddress && {
106
+ name: `${this.billingAddress.firstName} ${this.billingAddress.lastName}`,
107
+ addressLine1: this.billingAddress.streetAddress,
108
+ addressLine2: this.billingAddress.streetAddress2,
109
+ suburb: this.billingAddress.city,
110
+ countryCode: this.billingAddress.country,
111
+ postcode: this.billingAddress.postalCode,
112
+ state: this.billingAddress.state
113
+ } || void 0
114
+ },
115
+ items: this.order && this.order.orderItems.map((l) => ({
116
+ name: l.name,
117
+ reference: l.sku,
118
+ quantity: Number(l.quantity),
119
+ amount: Number(l.unitPrice)
120
+ })) || []
121
+ };
122
+ this.log("[PayWayAppleButton][checkout]", s), (p = this.httpInvoker) == null || p.invoke(c(this.apiUrl)[h.CHECKOUT].url, c(this.apiUrl)[h.CHECKOUT].method, JSON.stringify(s), (l, d) => {
123
+ this.log("[PayWayAppleButton][checkout]: successCheckoutHandler", l, d);
124
+ let y;
125
+ try {
126
+ y = JSON.parse(window.atob(JSON.parse(d).checkoutData)).checkoutId;
127
+ } catch {
128
+ this.fail(d);
129
+ return;
130
+ }
131
+ this.charge(y, i);
132
+ }, (l, d) => {
133
+ this.log("[PayWayAppleButton][checkout]: failureCheckoutHandler", l, d), this.fail(d);
134
+ }, m(i));
135
+ }
136
+ charge(t, i) {
137
+ var s;
138
+ this.log("[PayWayAppleButton][charge]", { checkoutId: t }), (s = this.httpInvoker) == null || s.invoke(c(this.apiUrl)[h.CHARGE].url, c(this.apiUrl)[h.CHARGE].method, JSON.stringify({ checkoutId: t }), (a, o) => {
139
+ var n;
140
+ this.log("[PayWayAppleButton][charge]: successChargeHandler", a, o);
141
+ let e = null;
142
+ try {
143
+ e = JSON.parse(o);
144
+ } catch {
145
+ }
146
+ (n = this.onSuccess) == null || n.call(this, {
147
+ transactionId: e == null ? void 0 : e.chargeId,
148
+ status: e == null ? void 0 : e.status
149
+ });
150
+ }, (a, o) => {
151
+ this.log("[PayWayAppleButton][charge]: failureChargeHandler", a, o), this.fail(o);
152
+ }, m(i));
153
+ }
154
+ fail(t) {
155
+ var s, a;
156
+ let i;
157
+ try {
158
+ i = (s = JSON.parse(t)) == null ? void 0 : s.message;
159
+ } catch {
160
+ }
161
+ (a = this.onFailure) == null || a.call(this, { error: i || "Unable to pay with ApplePay" });
162
+ }
163
+ redraw() {
164
+ this.button && (this.button.innerHTML = "", this.draw());
165
+ }
166
+ setAmount(t) {
167
+ this.log("[PayWayAppleButton][setAmount]", t), this.amount = t, this.redraw();
168
+ }
169
+ setCurrency(t) {
170
+ this.log("[PayWayAppleButton][setCurrency]", t), this.currency = t, this.redraw();
171
+ }
172
+ setCustomerInfo(t) {
173
+ this.log("[PayWayAppleButton][setCustomerInfo]", t), this.customer = { ...t };
174
+ }
175
+ setBillingAddress(t) {
176
+ this.log("[PayWayAppleButton][setBillingAddress]", t), this.billingAddress = { ...t };
177
+ }
178
+ setOrderInfo(t) {
179
+ this.log("[PayWayAppleButton][setOrderInfo]", t), this.order = { ...t };
180
+ }
181
+ };
182
+ export {
183
+ B as PayWayAppleButton
184
+ };
@@ -1,4 +1,4 @@
1
- import { w as n } from "./MetricsGlobalThreeDsProvider-C93ttqbB-SRsVMed4.js";
1
+ import { w as n } from "./MetricsGlobalThreeDsProvider-C2mH6Z-m-BTiFsRgv.js";
2
2
  var r = class extends n {
3
3
  getType() {
4
4
  return "CxPay";
@@ -1,4 +1,4 @@
1
- import { O as n } from "./DefaultThreeDsProvider-bLoDSnkd-CuWxvLku.js";
1
+ import { O as n } from "./DefaultThreeDsProvider-BS9pznAi-fDl8jKzq.js";
2
2
  function f(t, r, e) {
3
3
  return new n(t, r, e);
4
4
  }