@verbb/formie-browser 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/chunks/{api-BYe9YPko.js → api-DqpfkZWL.js} +15 -2
- package/dist/chunks/{bpoint-C0VOftX9.js → bpoint-Dlq34XH1.js} +1 -1
- package/dist/chunks/{calculations-HAZ8wUrT.js → calculations-DERi2xaC.js} +8 -8
- package/dist/chunks/{conditions-BiA_uANV.js → conditions-65kBcFWW.js} +1 -1
- package/dist/chunks/{dist-BaHXfvBO.js → dist-BdUy8m_p.js} +2 -2
- package/dist/chunks/{eway-CS6Y1Yvo.js → eway-D9_m8ooj.js} +1 -1
- package/dist/chunks/{go-cardless-BTPD668l.js → go-cardless-DAT3ZaQf.js} +1 -1
- package/dist/chunks/{mollie-CXgBwvo6.js → mollie-Bibhl67p.js} +1 -1
- package/dist/chunks/{moneris-B6oLu7nj.js → moneris-H2wSqk9h.js} +1 -1
- package/dist/chunks/opayo-CR0DtsLa.js +179 -0
- package/dist/chunks/{paddle-GRlsm5mm.js → paddle-DkvIxQdG.js} +1 -1
- package/dist/chunks/{password-validation-D5AirwUM.js → password-validation-T0vDQPCr.js} +1 -1
- package/dist/chunks/{paypal-CdcZnf6r.js → paypal-CQpAF7Ua.js} +32 -31
- package/dist/chunks/{payway-CfmYOS__.js → payway-CwDkC7YZ.js} +1 -1
- package/dist/chunks/{square-BY--5M-X.js → square-DwdcOI1G.js} +1 -1
- package/dist/chunks/{stripe-uusYjWty.js → stripe-DaoG2FT1.js} +1 -1
- package/dist/chunks/{text-limit-nSATKyhp.js → text-limit-Bn18WrPU.js} +1 -1
- package/dist/css/theme/fields/_check-radio.css +3 -1
- package/dist/css/theme/integrations/_opayo.css +9 -0
- package/dist/index.js +16 -16
- package/dist/js/modules/payments/factories.d.ts +5 -1
- package/dist/js/modules/payments/factories.d.ts.map +1 -1
- package/dist/js/modules/payments/opayo.d.ts +17 -2
- package/dist/js/modules/payments/opayo.d.ts.map +1 -1
- package/dist/js/modules/payments/paypal.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/css/theme/fields/_check-radio.css +3 -1
- package/src/css/theme/integrations/_opayo.css +9 -0
- package/src/js/modules/payments/factories.ts +27 -2
- package/src/js/modules/payments/opayo.ts +256 -69
- package/src/js/modules/payments/paypal.ts +23 -3
- package/dist/chunks/opayo-DPUA5CKr.js +0 -113
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { s as e } from "./event-names-BCI2FLD8.js";
|
|
2
|
-
import { t } from "./api-BYe9YPko.js";
|
|
3
|
-
import { t as n } from "./debug-BV0DvdHx.js";
|
|
4
|
-
import { r } from "./scripts-CbQ7agX3.js";
|
|
5
|
-
//#region src/js/modules/payments/opayo.ts
|
|
6
|
-
var i = "FORMIE_OPAYO_SCRIPT", a = "https://live.opayo.eu.elavon.com/api/v1/js/sagepay.js", o = "https://sandbox.opayo.eu.elavon.com/api/v1/js/sagepay.js", s = n("payments", "opayo"), c = e("opayo", "challenge"), l = "formie:payment:opayo:challenge:response", u = t({
|
|
7
|
-
id: "opayo",
|
|
8
|
-
defaultRequiredInputSuffixes: ["opayoTokenId"],
|
|
9
|
-
load: async (e) => {
|
|
10
|
-
let { provider: t } = e.options;
|
|
11
|
-
return await r("sagepayOwnForm", {
|
|
12
|
-
id: i,
|
|
13
|
-
src: t.useSandbox ? o : a,
|
|
14
|
-
timeoutMs: 1e4
|
|
15
|
-
}), null;
|
|
16
|
-
},
|
|
17
|
-
onBeforeAuthorize: async (e) => {
|
|
18
|
-
let { field: t, services: n, options: r } = e, i = r.provider, a = i.handle || "opayo", o = n.form;
|
|
19
|
-
if (!o?.action) return n.addError("Form action is missing."), s.warn("Missing form action before authorize."), !1;
|
|
20
|
-
let c = window.sagepayOwnForm;
|
|
21
|
-
if (!c) return n.addError("Opayo script failed to load."), s.warn("sagepayOwnForm global not available."), !1;
|
|
22
|
-
let l = t.querySelector("[data-opayo-card=\"cardholder-name\"]")?.value ?? "", u = t.querySelector("[data-opayo-card=\"card-number\"]")?.value ?? "", d = t.querySelector("[data-opayo-card=\"expiry-date\"]")?.value ?? "", f = t.querySelector("[data-opayo-card=\"security-code\"]")?.value ?? "";
|
|
23
|
-
return u = u.replace(/[\s/]/g, ""), d = d.replace(/[\s/]/g, ""), new Promise((e) => {
|
|
24
|
-
let t = new FormData();
|
|
25
|
-
t.append("action", "formie/payment-webhooks/process-callback"), t.append("merchantSessionKey", "true"), t.append("handle", a), t.append("sessionToken", i.sessionToken || ""), fetch(o.action, {
|
|
26
|
-
method: "POST",
|
|
27
|
-
body: t
|
|
28
|
-
}).then(async (t) => {
|
|
29
|
-
if (t.status < 200 || t.status >= 300) {
|
|
30
|
-
n.addError(`${t.status}: ${t.statusText}`), s.warn("Merchant session request failed.", {
|
|
31
|
-
status: t.status,
|
|
32
|
-
statusText: t.statusText
|
|
33
|
-
}), e(!1);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
let r = (await t.json()).merchantSessionKey;
|
|
38
|
-
if (!r) {
|
|
39
|
-
n.addError("Unable to get merchant session."), s.warn("merchantSessionKey missing in callback response."), e(!1);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
c({ merchantSessionKey: r }).tokeniseCardDetails({
|
|
43
|
-
cardDetails: {
|
|
44
|
-
cardholderName: l,
|
|
45
|
-
cardNumber: u,
|
|
46
|
-
expiryDate: d,
|
|
47
|
-
securityCode: f
|
|
48
|
-
},
|
|
49
|
-
onTokenised: (t) => {
|
|
50
|
-
t.success && t.cardIdentifier ? (n.updateInputs("opayoTokenId", t.cardIdentifier), n.updateInputs("opayoSessionKey", r), s.log("Tokenization succeeded.", { hasCardIdentifier: !!t.cardIdentifier }), e(!0)) : (n.addError(t.errors?.[0]?.message || "Tokenization failed."), s.warn("Tokenization failed.", t), e(!1));
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
} catch {
|
|
54
|
-
n.addError("Unable to parse merchant session response."), s.warn("Failed to parse merchant session response."), e(!1);
|
|
55
|
-
}
|
|
56
|
-
}).catch(() => {
|
|
57
|
-
n.addError("Network error. Please try again."), s.warn("Network error requesting merchant session."), e(!1);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
setup: async (e) => {
|
|
62
|
-
let { services: t } = e;
|
|
63
|
-
e.target;
|
|
64
|
-
let n = null, r = !1, i = () => {
|
|
65
|
-
n?.parentNode && n.parentNode.removeChild(n), n = null;
|
|
66
|
-
}, a = t.events.onForm(c, ((e) => {
|
|
67
|
-
let a = e.detail?.data;
|
|
68
|
-
if (!a?.acsUrl || !a?.creq) return;
|
|
69
|
-
r = !1, s.log("Received payment challenge event.", {
|
|
70
|
-
hasAcsUrl: !!a.acsUrl,
|
|
71
|
-
hasCreq: !!a.creq
|
|
72
|
-
});
|
|
73
|
-
let o = t.form?.querySelector("input[name*=\"opayoSessionKey\"]")?.value || "", c = document.createElement("div");
|
|
74
|
-
c.className = "formie-modal", c.id = `formie-opayo-dialog-${Math.random().toString(36).slice(2, 9)}`, c.innerHTML = "\n <div class=\"formie-modal-backdrop\" data-dialog-close></div>\n <div class=\"formie-modal-content\">\n <div class=\"formie-loading formie-loading-large\" style=\"--formie-loading-width: 3rem; --formie-loading-height: 3rem; top: 50%; margin-top: -1.5rem;\"></div>\n <iframe width=\"100%\" height=\"100%\" style=\"width: 100%; height: 100%; position: relative; z-index: 1;\"></iframe>\n </div>\n ";
|
|
75
|
-
let l = c.querySelector("iframe"), u = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), d = a.returnUrl || a.redirectUrl || "", f = `<form action="${u(a.acsUrl)}" method="post">
|
|
76
|
-
<input type="hidden" name="creq" value="${u(a.creq || "")}" />
|
|
77
|
-
<input type="hidden" name="threeDSSessionData" value="${u(a.threeDSSessionData || "")}" />
|
|
78
|
-
<input type="hidden" name="MD" value="${u(o)}" />
|
|
79
|
-
<input type="hidden" name="TermUrl" value="${u(d)}" />
|
|
80
|
-
<input type="hidden" name="ThreeDSNotificationURL" value="${u(d)}" />
|
|
81
|
-
</form><script>document.forms[0].submit();<\/script>`;
|
|
82
|
-
i(), document.body.appendChild(c), n = c, l?.contentWindow && (l.contentWindow.document.open(), l.contentWindow.document.write(f), l.contentWindow.document.close());
|
|
83
|
-
})), o = (e) => {
|
|
84
|
-
if (e.data?.message === l) {
|
|
85
|
-
if (!n) {
|
|
86
|
-
s.log("Ignoring 3DS response without active dialog.");
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (r) {
|
|
90
|
-
s.warn("Ignoring duplicate 3DS response while processing.");
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (r = !0, s.log("Received payment challenge response message.", e.data?.value), i(), t.removeError(), e.data?.value?.error) {
|
|
94
|
-
t.addError(e.data.value.error.message), t.releaseSubmitLoading(), r = !1;
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
t.updateInputs("opayo3DSComplete", e.data.value?.transactionId ?? ""), t.triggerSubmit();
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
return window.addEventListener("message", o), { destroy: () => {
|
|
101
|
-
a(), window.removeEventListener("message", o), i(), r = !1;
|
|
102
|
-
} };
|
|
103
|
-
},
|
|
104
|
-
onAfterSubmit: async ({ services: e }) => {
|
|
105
|
-
e.updateInputs([
|
|
106
|
-
"opayoTokenId",
|
|
107
|
-
"opayoSessionKey",
|
|
108
|
-
"opayo3DSComplete"
|
|
109
|
-
], "");
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
//#endregion
|
|
113
|
-
export { u as opayoModule };
|