@puzzle-ui/payment-providers 0.0.0-stage → 0.17.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.
- package/README.md +28 -2
- package/ai/instructions.md +10 -0
- package/ai/manifest.json +8 -0
- package/dist/LICENSE +21 -0
- package/dist/adyen.cjs +226 -0
- package/dist/adyen.cjs.map +1 -0
- package/dist/adyen.d.cts +10 -0
- package/dist/adyen.d.ts +10 -0
- package/dist/adyen.js +225 -0
- package/dist/adyen.js.map +1 -0
- package/dist/http-BJTHkHOr.d.cts +10 -0
- package/dist/http-BJTHkHOr.d.ts +10 -0
- package/dist/http-DxPMQ2xk.cjs +113 -0
- package/dist/http-DxPMQ2xk.cjs.map +1 -0
- package/dist/http-Pinf6Gsa.js +66 -0
- package/dist/http-Pinf6Gsa.js.map +1 -0
- package/dist/index.cjs +15 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +7 -0
- package/dist/mollie.cjs +194 -0
- package/dist/mollie.cjs.map +1 -0
- package/dist/mollie.d.cts +9 -0
- package/dist/mollie.d.ts +9 -0
- package/dist/mollie.js +193 -0
- package/dist/mollie.js.map +1 -0
- package/dist/paypal.cjs +207 -0
- package/dist/paypal.cjs.map +1 -0
- package/dist/paypal.d.cts +10 -0
- package/dist/paypal.d.ts +10 -0
- package/dist/paypal.js +206 -0
- package/dist/paypal.js.map +1 -0
- package/dist/signatures-AHsLlFRl.js +35 -0
- package/dist/signatures-AHsLlFRl.js.map +1 -0
- package/dist/signatures-F-65qEDl.cjs +46 -0
- package/dist/signatures-F-65qEDl.cjs.map +1 -0
- package/dist/stripe.cjs +191 -0
- package/dist/stripe.cjs.map +1 -0
- package/dist/stripe.d.cts +10 -0
- package/dist/stripe.d.ts +10 -0
- package/dist/stripe.js +190 -0
- package/dist/stripe.js.map +1 -0
- package/package.json +97 -4
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
let _puzzle_ui_commerce = require("@puzzle-ui/commerce");
|
|
2
|
+
// src/http.ts
|
|
3
|
+
var ProviderHttpError = class extends Error {
|
|
4
|
+
status;
|
|
5
|
+
providerCode;
|
|
6
|
+
details;
|
|
7
|
+
constructor(status, message, providerCode, details) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "ProviderHttpError";
|
|
10
|
+
this.status = status;
|
|
11
|
+
this.providerCode = providerCode;
|
|
12
|
+
this.details = details;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const createProviderError = (error, fallback = "unknown") => {
|
|
16
|
+
if (error instanceof _puzzle_ui_commerce.PaymentError) return error;
|
|
17
|
+
if (error instanceof ProviderHttpError) return new _puzzle_ui_commerce.PaymentError({
|
|
18
|
+
code: error.status === 401 || error.status === 403 ? "authentication" : error.status === 408 || error.status === 429 || error.status >= 500 ? "network" : fallback,
|
|
19
|
+
message: error.message,
|
|
20
|
+
providerCode: error.providerCode,
|
|
21
|
+
details: error.details,
|
|
22
|
+
retryable: error.status === 408 || error.status === 429 || error.status >= 500
|
|
23
|
+
});
|
|
24
|
+
return new _puzzle_ui_commerce.PaymentError({
|
|
25
|
+
code: fallback,
|
|
26
|
+
message: error instanceof Error ? error.message : "Payment provider request failed.",
|
|
27
|
+
retryable: fallback === "network" || fallback === "timeout"
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const readJson = async (response) => {
|
|
31
|
+
const text = await response.text();
|
|
32
|
+
if (!text) return {};
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(text);
|
|
35
|
+
} catch {
|
|
36
|
+
return { raw: text };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
40
|
+
const requestJson = async (fetcher, url, init) => {
|
|
41
|
+
const response = await fetcher(url, init);
|
|
42
|
+
const body = record(await readJson(response));
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
const error = record(body.error);
|
|
45
|
+
const details = {};
|
|
46
|
+
for (const [key, value] of Object.entries(body)) if (typeof value === "string") details[key] = value;
|
|
47
|
+
throw new ProviderHttpError(response.status, typeof error.message === "string" ? error.message : typeof body.message === "string" ? body.message : `Payment provider request failed with status ${response.status}.`, typeof error.code === "string" ? error.code : typeof body.code === "string" ? body.code : void 0, details);
|
|
48
|
+
}
|
|
49
|
+
return body;
|
|
50
|
+
};
|
|
51
|
+
const jsonHeaders = (headers = {}) => ({
|
|
52
|
+
Accept: "application/json",
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
...headers
|
|
55
|
+
});
|
|
56
|
+
const asString = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
57
|
+
const requireString = (value, label) => {
|
|
58
|
+
const result = asString(value);
|
|
59
|
+
if (!result) throw new ProviderHttpError(502, `Provider response omitted ${label}.`);
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
const now = () => /* @__PURE__ */ new Date();
|
|
63
|
+
const encodeBasicAuth = (username, password = "") => `Basic ${btoa(`${username}:${password}`)}`;
|
|
64
|
+
Object.defineProperty(exports, "ProviderHttpError", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function() {
|
|
67
|
+
return ProviderHttpError;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(exports, "asString", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function() {
|
|
73
|
+
return asString;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(exports, "createProviderError", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function() {
|
|
79
|
+
return createProviderError;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(exports, "encodeBasicAuth", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function() {
|
|
85
|
+
return encodeBasicAuth;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, "jsonHeaders", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function() {
|
|
91
|
+
return jsonHeaders;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(exports, "now", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function() {
|
|
97
|
+
return now;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(exports, "requestJson", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function() {
|
|
103
|
+
return requestJson;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(exports, "requireString", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function() {
|
|
109
|
+
return requireString;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=http-DxPMQ2xk.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-DxPMQ2xk.cjs","names":["PaymentError"],"sources":["../src/http.ts"],"sourcesContent":["import {\n PaymentError,\n type NormalizedPaymentError,\n} from \"@puzzle-ui/commerce\";\n\nexport type ProviderFetcher = (\n input: RequestInfo | URL,\n init?: RequestInit,\n) => Promise<Response>;\n\nexport class ProviderHttpError extends Error {\n readonly status: number;\n readonly providerCode?: string;\n readonly details?: Readonly<Record<string, string>>;\n\n constructor(\n status: number,\n message: string,\n providerCode?: string,\n details?: Readonly<Record<string, string>>,\n ) {\n super(message);\n this.name = \"ProviderHttpError\";\n this.status = status;\n this.providerCode = providerCode;\n this.details = details;\n }\n}\n\nexport const createProviderError = (\n error: unknown,\n fallback: NormalizedPaymentError[\"code\"] = \"unknown\",\n): PaymentError => {\n if (error instanceof PaymentError) return error;\n if (error instanceof ProviderHttpError) {\n return new PaymentError({\n code:\n error.status === 401 || error.status === 403\n ? \"authentication\"\n : error.status === 408 || error.status === 429 || error.status >= 500\n ? \"network\"\n : fallback,\n message: error.message,\n providerCode: error.providerCode,\n details: error.details,\n retryable: error.status === 408 || error.status === 429 || error.status >= 500,\n });\n }\n return new PaymentError({\n code: fallback,\n message: error instanceof Error ? error.message : \"Payment provider request failed.\",\n retryable: fallback === \"network\" || fallback === \"timeout\",\n });\n};\n\nconst readJson = async (response: Response): Promise<unknown> => {\n const text = await response.text();\n if (!text) return {};\n try {\n return JSON.parse(text);\n } catch {\n return { raw: text };\n }\n};\n\nconst record = (value: unknown): Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? value as Record<string, unknown>\n : {};\n\nexport const requestJson = async (\n fetcher: ProviderFetcher,\n url: string,\n init: RequestInit,\n): Promise<Record<string, unknown>> => {\n const response = await fetcher(url, init);\n const body = record(await readJson(response));\n if (!response.ok) {\n const error = record(body.error);\n const details: Record<string, string> = {};\n for (const [key, value] of Object.entries(body)) {\n if (typeof value === \"string\") details[key] = value;\n }\n throw new ProviderHttpError(\n response.status,\n typeof error.message === \"string\"\n ? error.message\n : typeof body.message === \"string\"\n ? body.message\n : `Payment provider request failed with status ${response.status}.`,\n typeof error.code === \"string\"\n ? error.code\n : typeof body.code === \"string\"\n ? body.code\n : undefined,\n details,\n );\n }\n return body;\n};\n\nexport const jsonHeaders = (headers: HeadersInit = {}): HeadersInit => ({\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n ...headers,\n});\n\nexport const asString = (value: unknown): string | undefined =>\n typeof value === \"string\" && value.length > 0 ? value : undefined;\n\nexport const requireString = (value: unknown, label: string): string => {\n const result = asString(value);\n if (!result) throw new ProviderHttpError(502, `Provider response omitted ${label}.`);\n return result;\n};\n\nexport const now = () => new Date();\n\nexport const encodeBasicAuth = (username: string, password = \"\") =>\n `Basic ${btoa(`${username}:${password}`)}`;\n"],"mappings":";;AAUA,IAAa,oBAAb,cAAuC,MAAM;CAC3C;CACA;CACA;CAEA,YACE,QACA,SACA,cACA,SACA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,eAAe;EACpB,KAAK,UAAU;CACjB;AACF;AAEA,MAAa,u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S,OAAO,IACrE,OAAO,MAAM,SAAS,WAClB,MAAM,OACN,OAAO,KAAK,SAAS,WACnB,KAAK,OACL,KAAA,GACN,OACF;CACF;CACA,OAAO;AACT;AAEA,MAAa,eAAe,UAAuB,CAAC,OAAoB;CACtE,QAAQ;CACR,gBAAgB;CAChB,GAAG;AACL;AAEA,MAAa,YAAY,UACvB,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ,KAAA;AAE1D,MAAa,iBAAiB,OAAgB,UAA0B;CACtE,MAAM,SAAS,SAAS,KAAK;CAC7B,IAAI,CAAC,QAAQ,MAAM,IAAI,kBAAkB,KAAK,6BAA6B,MAAM,EAAE;CACnF,OAAO;AACT;AAEA,MAAa,4BAAY,IAAI,KAAK;AAElC,MAAa,mBAAmB,UAAkB,WAAW,OAC3D,SAAS,KAAK,GAAG,SAAS,GAAG,UAAU"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { PaymentError } from "@puzzle-ui/commerce";
|
|
2
|
+
// src/http.ts
|
|
3
|
+
var ProviderHttpError = class extends Error {
|
|
4
|
+
status;
|
|
5
|
+
providerCode;
|
|
6
|
+
details;
|
|
7
|
+
constructor(status, message, providerCode, details) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "ProviderHttpError";
|
|
10
|
+
this.status = status;
|
|
11
|
+
this.providerCode = providerCode;
|
|
12
|
+
this.details = details;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const createProviderError = (error, fallback = "unknown") => {
|
|
16
|
+
if (error instanceof PaymentError) return error;
|
|
17
|
+
if (error instanceof ProviderHttpError) return new PaymentError({
|
|
18
|
+
code: error.status === 401 || error.status === 403 ? "authentication" : error.status === 408 || error.status === 429 || error.status >= 500 ? "network" : fallback,
|
|
19
|
+
message: error.message,
|
|
20
|
+
providerCode: error.providerCode,
|
|
21
|
+
details: error.details,
|
|
22
|
+
retryable: error.status === 408 || error.status === 429 || error.status >= 500
|
|
23
|
+
});
|
|
24
|
+
return new PaymentError({
|
|
25
|
+
code: fallback,
|
|
26
|
+
message: error instanceof Error ? error.message : "Payment provider request failed.",
|
|
27
|
+
retryable: fallback === "network" || fallback === "timeout"
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const readJson = async (response) => {
|
|
31
|
+
const text = await response.text();
|
|
32
|
+
if (!text) return {};
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(text);
|
|
35
|
+
} catch {
|
|
36
|
+
return { raw: text };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const record = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
40
|
+
const requestJson = async (fetcher, url, init) => {
|
|
41
|
+
const response = await fetcher(url, init);
|
|
42
|
+
const body = record(await readJson(response));
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
const error = record(body.error);
|
|
45
|
+
const details = {};
|
|
46
|
+
for (const [key, value] of Object.entries(body)) if (typeof value === "string") details[key] = value;
|
|
47
|
+
throw new ProviderHttpError(response.status, typeof error.message === "string" ? error.message : typeof body.message === "string" ? body.message : `Payment provider request failed with status ${response.status}.`, typeof error.code === "string" ? error.code : typeof body.code === "string" ? body.code : void 0, details);
|
|
48
|
+
}
|
|
49
|
+
return body;
|
|
50
|
+
};
|
|
51
|
+
const jsonHeaders = (headers = {}) => ({
|
|
52
|
+
Accept: "application/json",
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
...headers
|
|
55
|
+
});
|
|
56
|
+
const asString = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
57
|
+
const requireString = (value, label) => {
|
|
58
|
+
const result = asString(value);
|
|
59
|
+
if (!result) throw new ProviderHttpError(502, `Provider response omitted ${label}.`);
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
const now = () => /* @__PURE__ */ new Date();
|
|
63
|
+
const encodeBasicAuth = (username, password = "") => `Basic ${btoa(`${username}:${password}`)}`;
|
|
64
|
+
export { jsonHeaders as a, requireString as c, encodeBasicAuth as i, asString as n, now as o, createProviderError as r, requestJson as s, ProviderHttpError as t };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=http-Pinf6Gsa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-Pinf6Gsa.js","names":[],"sources":["../src/http.ts"],"sourcesContent":["import {\n PaymentError,\n type NormalizedPaymentError,\n} from \"@puzzle-ui/commerce\";\n\nexport type ProviderFetcher = (\n input: RequestInfo | URL,\n init?: RequestInit,\n) => Promise<Response>;\n\nexport class ProviderHttpError extends Error {\n readonly status: number;\n readonly providerCode?: string;\n readonly details?: Readonly<Record<string, string>>;\n\n constructor(\n status: number,\n message: string,\n providerCode?: string,\n details?: Readonly<Record<string, string>>,\n ) {\n super(message);\n this.name = \"ProviderHttpError\";\n this.status = status;\n this.providerCode = providerCode;\n this.details = details;\n }\n}\n\nexport const createProviderError = (\n error: unknown,\n fallback: NormalizedPaymentError[\"code\"] = \"unknown\",\n): PaymentError => {\n if (error instanceof PaymentError) return error;\n if (error instanceof ProviderHttpError) {\n return new PaymentError({\n code:\n error.status === 401 || error.status === 403\n ? \"authentication\"\n : error.status === 408 || error.status === 429 || error.status >= 500\n ? \"network\"\n : fallback,\n message: error.message,\n providerCode: error.providerCode,\n details: error.details,\n retryable: error.status === 408 || error.status === 429 || error.status >= 500,\n });\n }\n return new PaymentError({\n code: fallback,\n message: error instanceof Error ? error.message : \"Payment provider request failed.\",\n retryable: fallback === \"network\" || fallback === \"timeout\",\n });\n};\n\nconst readJson = async (response: Response): Promise<unknown> => {\n const text = await response.text();\n if (!text) return {};\n try {\n return JSON.parse(text);\n } catch {\n return { raw: text };\n }\n};\n\nconst record = (value: unknown): Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? value as Record<string, unknown>\n : {};\n\nexport const requestJson = async (\n fetcher: ProviderFetcher,\n url: string,\n init: RequestInit,\n): Promise<Record<string, unknown>> => {\n const response = await fetcher(url, init);\n const body = record(await readJson(response));\n if (!response.ok) {\n const error = record(body.error);\n const details: Record<string, string> = {};\n for (const [key, value] of Object.entries(body)) {\n if (typeof value === \"string\") details[key] = value;\n }\n throw new ProviderHttpError(\n response.status,\n typeof error.message === \"string\"\n ? error.message\n : typeof body.message === \"string\"\n ? body.message\n : `Payment provider request failed with status ${response.status}.`,\n typeof error.code === \"string\"\n ? error.code\n : typeof body.code === \"string\"\n ? body.code\n : undefined,\n details,\n );\n }\n return body;\n};\n\nexport const jsonHeaders = (headers: HeadersInit = {}): HeadersInit => ({\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n ...headers,\n});\n\nexport const asString = (value: unknown): string | undefined =>\n typeof value === \"string\" && value.length > 0 ? value : undefined;\n\nexport const requireString = (value: unknown, label: string): string => {\n const result = asString(value);\n if (!result) throw new ProviderHttpError(502, `Provider response omitted ${label}.`);\n return result;\n};\n\nexport const now = () => new Date();\n\nexport const encodeBasicAuth = (username: string, password = \"\") =>\n `Basic ${btoa(`${username}:${password}`)}`;\n"],"mappings":";;AAUA,IAAa,oBAAb,cAAuC,MAAM;CAC3C;CACA;CACA;CAEA,YACE,QACA,SACA,cACA,SACA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,eAAe;EACpB,KAAK,UAAU;CACjB;AACF;AAEA,MAAa,uBACX,OACA,WAA2C,cAC1B;CACjB,IAAI,iBAAiB,cAAc,OAAO;CAC1C,IAAI,iBAAiB,mBACnB,OAAO,IAAI,aAAa;EACtB,MACE,MAAM,WAAW,OAAO,MAAM,WAAW,MACrC,mBACA,MAAM,WAAW,OAAO,MAAM,WAAW,OAAO,MAAM,UAAU,MAC9D,YACA;EACR,SAAS,MAAM;EACf,cAAc,MAAM;EACpB,SAAS,MAAM;EACf,WAAW,MAAM,WAAW,OAAO,MAAM,WAAW,OAAO,MAAM,UAAU;CAC7E,CAAC;CAEH,OAAO,IAAI,aAAa;EACtB,MAAM;EACN,SAAS,iBAAiB,QAAQ,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AAEA,MAAa,4BAAY,IAAI,KAAK;AAElC,MAAa,mBAAmB,UAAkB,WAAW,OAC3D,SAAS,KAAK,GAAG,SAAS,GAAG,UAAU"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_stripe = require("./stripe.cjs");
|
|
3
|
+
const require_mollie = require("./mollie.cjs");
|
|
4
|
+
const require_paypal = require("./paypal.cjs");
|
|
5
|
+
const require_adyen = require("./adyen.cjs");
|
|
6
|
+
const require_http = require("./http-DxPMQ2xk.cjs");
|
|
7
|
+
const require_signatures = require("./signatures-F-65qEDl.cjs");
|
|
8
|
+
exports.ProviderHttpError = require_http.ProviderHttpError;
|
|
9
|
+
exports.createAdyenAdapter = require_adyen.createAdyenAdapter;
|
|
10
|
+
exports.createMollieAdapter = require_mollie.createMollieAdapter;
|
|
11
|
+
exports.createPayPalAdapter = require_paypal.createPayPalAdapter;
|
|
12
|
+
exports.createProviderError = require_http.createProviderError;
|
|
13
|
+
exports.createStripeAdapter = require_stripe.createStripeAdapter;
|
|
14
|
+
exports.verifyHmacSha256 = require_signatures.verifyHmacSha256;
|
|
15
|
+
exports.verifyStripeSignature = require_signatures.verifyStripeSignature;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StripeAdapterOptions, createStripeAdapter } from "./stripe.cjs";
|
|
2
|
+
import { MollieAdapterOptions, createMollieAdapter } from "./mollie.cjs";
|
|
3
|
+
import { PayPalAdapterOptions, createPayPalAdapter } from "./paypal.cjs";
|
|
4
|
+
import { AdyenAdapterOptions, createAdyenAdapter } from "./adyen.cjs";
|
|
5
|
+
import { n as ProviderHttpError, r as createProviderError, t as ProviderFetcher } from "./http-BJTHkHOr.cjs";
|
|
6
|
+
export declare const verifyHmacSha256: ({ payload, signature, secret, encoding }: {
|
|
7
|
+
payload: string;
|
|
8
|
+
signature: string;
|
|
9
|
+
secret: string;
|
|
10
|
+
encoding?: "hex" | "base64";
|
|
11
|
+
}) => Promise<boolean>;
|
|
12
|
+
export declare const verifyStripeSignature: ({ payload, signature, secret, toleranceSeconds, nowSeconds }: {
|
|
13
|
+
payload: string;
|
|
14
|
+
signature: string;
|
|
15
|
+
secret: string;
|
|
16
|
+
toleranceSeconds?: number;
|
|
17
|
+
nowSeconds?: number;
|
|
18
|
+
}) => Promise<boolean>;
|
|
19
|
+
export { type AdyenAdapterOptions, type MollieAdapterOptions, type PayPalAdapterOptions, type ProviderFetcher, ProviderHttpError, type StripeAdapterOptions, createAdyenAdapter, createMollieAdapter, createPayPalAdapter, createProviderError, createStripeAdapter };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StripeAdapterOptions, createStripeAdapter } from "./stripe.js";
|
|
2
|
+
import { MollieAdapterOptions, createMollieAdapter } from "./mollie.js";
|
|
3
|
+
import { PayPalAdapterOptions, createPayPalAdapter } from "./paypal.js";
|
|
4
|
+
import { AdyenAdapterOptions, createAdyenAdapter } from "./adyen.js";
|
|
5
|
+
import { n as ProviderHttpError, r as createProviderError, t as ProviderFetcher } from "./http-BJTHkHOr.js";
|
|
6
|
+
export declare const verifyHmacSha256: ({ payload, signature, secret, encoding }: {
|
|
7
|
+
payload: string;
|
|
8
|
+
signature: string;
|
|
9
|
+
secret: string;
|
|
10
|
+
encoding?: "hex" | "base64";
|
|
11
|
+
}) => Promise<boolean>;
|
|
12
|
+
export declare const verifyStripeSignature: ({ payload, signature, secret, toleranceSeconds, nowSeconds }: {
|
|
13
|
+
payload: string;
|
|
14
|
+
signature: string;
|
|
15
|
+
secret: string;
|
|
16
|
+
toleranceSeconds?: number;
|
|
17
|
+
nowSeconds?: number;
|
|
18
|
+
}) => Promise<boolean>;
|
|
19
|
+
export { type AdyenAdapterOptions, type MollieAdapterOptions, type PayPalAdapterOptions, type ProviderFetcher, ProviderHttpError, type StripeAdapterOptions, createAdyenAdapter, createMollieAdapter, createPayPalAdapter, createProviderError, createStripeAdapter };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createStripeAdapter } from "./stripe.js";
|
|
2
|
+
import { createMollieAdapter } from "./mollie.js";
|
|
3
|
+
import { createPayPalAdapter } from "./paypal.js";
|
|
4
|
+
import { createAdyenAdapter } from "./adyen.js";
|
|
5
|
+
import { r as createProviderError, t as ProviderHttpError } from "./http-Pinf6Gsa.js";
|
|
6
|
+
import { n as verifyStripeSignature, t as verifyHmacSha256 } from "./signatures-AHsLlFRl.js";
|
|
7
|
+
export { ProviderHttpError, createAdyenAdapter, createMollieAdapter, createPayPalAdapter, createProviderError, createStripeAdapter, verifyHmacSha256, verifyStripeSignature };
|
package/dist/mollie.cjs
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_http = require("./http-DxPMQ2xk.cjs");
|
|
3
|
+
const require_signatures = require("./signatures-F-65qEDl.cjs");
|
|
4
|
+
let _puzzle_ui_commerce = require("@puzzle-ui/commerce");
|
|
5
|
+
// src/mollie.ts
|
|
6
|
+
const provider = "mollie";
|
|
7
|
+
const providerAmount = (value) => (0, _puzzle_ui_commerce.toMajorUnits)(value).toFixed((0, _puzzle_ui_commerce.getCurrencyMinorUnit)(value.currency, { allowUnknownCurrencies: true }));
|
|
8
|
+
const moneyFromMollie = (value, fallbackCurrency) => {
|
|
9
|
+
const amount = value;
|
|
10
|
+
const currency = String(amount?.currency ?? fallbackCurrency).toUpperCase();
|
|
11
|
+
const major = Number(amount?.value);
|
|
12
|
+
if (!Number.isFinite(major)) throw new Error("Mollie response omitted a valid amount.");
|
|
13
|
+
return (0, _puzzle_ui_commerce.fromMajorUnits)(major, currency);
|
|
14
|
+
};
|
|
15
|
+
const paymentFromMollie = (value, fallback) => {
|
|
16
|
+
const status = String(value.status ?? "open");
|
|
17
|
+
const normalized = status === "paid" || status === "paid_out" ? "succeeded" : status === "authorized" ? "authorized" : status === "pending" || status === "open" ? "processing" : status === "canceled" || status === "expired" ? "cancelled" : status === "failed" ? "failed" : "pending";
|
|
18
|
+
const amount = moneyFromMollie(value.amount, fallback.amount.currency);
|
|
19
|
+
return {
|
|
20
|
+
id: fallback.id,
|
|
21
|
+
orderId: fallback.orderId,
|
|
22
|
+
amount,
|
|
23
|
+
status: normalized,
|
|
24
|
+
provider,
|
|
25
|
+
providerPaymentId: require_http.requireString(value.id, "payment ID"),
|
|
26
|
+
capturedAmount: normalized === "succeeded" ? amount : void 0,
|
|
27
|
+
failure: normalized === "failed" ? {
|
|
28
|
+
code: "declined",
|
|
29
|
+
message: "Mollie payment failed.",
|
|
30
|
+
providerCode: require_http.asString(value.failureReason),
|
|
31
|
+
retryable: false,
|
|
32
|
+
decline: true
|
|
33
|
+
} : void 0,
|
|
34
|
+
createdAt: value.createdAt ? new Date(String(value.createdAt)) : require_http.now(),
|
|
35
|
+
updatedAt: require_http.now()
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const createMollieAdapter = (options) => {
|
|
39
|
+
if (!options.apiKey.trim()) throw new TypeError("Mollie API key is required.");
|
|
40
|
+
const fetcher = options.fetcher ?? fetch;
|
|
41
|
+
const baseUrl = options.apiBaseUrl ?? "https://api.mollie.com";
|
|
42
|
+
const request = async (path, init = {}) => {
|
|
43
|
+
try {
|
|
44
|
+
return await require_http.requestJson(fetcher, `${baseUrl}${path}`, {
|
|
45
|
+
...init,
|
|
46
|
+
headers: {
|
|
47
|
+
...require_http.jsonHeaders({ Authorization: `Bearer ${options.apiKey}` }),
|
|
48
|
+
...init.headers
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw require_http.createProviderError(error);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
id: provider,
|
|
57
|
+
name: "Mollie",
|
|
58
|
+
capabilities: {
|
|
59
|
+
payments: true,
|
|
60
|
+
refunds: true,
|
|
61
|
+
partialRefund: true,
|
|
62
|
+
recurring: true,
|
|
63
|
+
hostedCheckout: true,
|
|
64
|
+
delayedPaymentMethods: true,
|
|
65
|
+
webhooks: true,
|
|
66
|
+
idempotency: true
|
|
67
|
+
},
|
|
68
|
+
createPayment: async (input, context) => {
|
|
69
|
+
const payment = await request("/v2/payments", {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: { "Idempotency-Key": context?.idempotencyKey ?? input.paymentId },
|
|
72
|
+
body: JSON.stringify({
|
|
73
|
+
amount: {
|
|
74
|
+
currency: input.amount.currency,
|
|
75
|
+
value: providerAmount(input.amount)
|
|
76
|
+
},
|
|
77
|
+
description: `Order ${input.orderId}`,
|
|
78
|
+
redirectUrl: input.returnUrl,
|
|
79
|
+
metadata: {
|
|
80
|
+
order_id: input.orderId,
|
|
81
|
+
payment_id: input.paymentId
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
return paymentFromMollie(payment, {
|
|
86
|
+
id: input.paymentId,
|
|
87
|
+
orderId: input.orderId,
|
|
88
|
+
amount: input.amount
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
getPayment: async (providerPaymentId) => {
|
|
92
|
+
const payment = await request(`/v2/payments/${encodeURIComponent(providerPaymentId)}`);
|
|
93
|
+
return paymentFromMollie(payment, {
|
|
94
|
+
id: providerPaymentId,
|
|
95
|
+
orderId: String(payment.metadata?.order_id ?? ""),
|
|
96
|
+
amount: moneyFromMollie(payment.amount, "EUR")
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
refund: async ({ payment, refund, context }) => {
|
|
100
|
+
const result = await request(`/v2/payments/${encodeURIComponent(require_http.requireString(payment.providerPaymentId, "provider payment ID"))}/refunds`, {
|
|
101
|
+
method: "POST",
|
|
102
|
+
headers: { "Idempotency-Key": context?.idempotencyKey ?? refund.id },
|
|
103
|
+
body: JSON.stringify({
|
|
104
|
+
amount: {
|
|
105
|
+
currency: refund.amount.currency,
|
|
106
|
+
value: providerAmount(refund.amount)
|
|
107
|
+
},
|
|
108
|
+
description: refund.reason
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
...refund,
|
|
113
|
+
providerRefundId: require_http.requireString(result.id, "refund ID"),
|
|
114
|
+
status: result.status === "refunded" ? "succeeded" : result.status === "failed" ? "failed" : "pending",
|
|
115
|
+
updatedAt: require_http.now()
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
createCheckoutSession: async (input) => {
|
|
119
|
+
const payment = await request("/v2/payments", {
|
|
120
|
+
method: "POST",
|
|
121
|
+
body: JSON.stringify({
|
|
122
|
+
amount: {
|
|
123
|
+
currency: input.amount.currency,
|
|
124
|
+
value: providerAmount(input.amount)
|
|
125
|
+
},
|
|
126
|
+
description: `Order ${input.orderId}`,
|
|
127
|
+
redirectUrl: input.returnUrl,
|
|
128
|
+
metadata: {
|
|
129
|
+
order_id: input.orderId,
|
|
130
|
+
payment_id: input.paymentId
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
const checkout = payment._links?.checkout;
|
|
135
|
+
return {
|
|
136
|
+
id: require_http.requireString(payment.id, "payment ID"),
|
|
137
|
+
provider,
|
|
138
|
+
paymentId: input.paymentId,
|
|
139
|
+
url: require_http.asString(checkout?.href)
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
getSupportedPaymentMethods: async () => [
|
|
143
|
+
{
|
|
144
|
+
id: "ideal",
|
|
145
|
+
type: "bank",
|
|
146
|
+
label: "iDEAL",
|
|
147
|
+
provider
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: "bancontact",
|
|
151
|
+
type: "bank",
|
|
152
|
+
label: "Bancontact",
|
|
153
|
+
provider
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: "card",
|
|
157
|
+
type: "card",
|
|
158
|
+
label: "Card",
|
|
159
|
+
provider
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
verifyWebhook: async (payload, signature, secret) => {
|
|
163
|
+
const body = typeof payload === "string" ? payload : new TextDecoder().decode(payload);
|
|
164
|
+
if (secret) return require_signatures.verifyHmacSha256({
|
|
165
|
+
payload: body,
|
|
166
|
+
signature,
|
|
167
|
+
secret,
|
|
168
|
+
encoding: options.webhookSignatureEncoding ?? "base64"
|
|
169
|
+
});
|
|
170
|
+
try {
|
|
171
|
+
const parsed = JSON.parse(body);
|
|
172
|
+
const id = require_http.asString(parsed.id);
|
|
173
|
+
if (!id) return false;
|
|
174
|
+
await request(`/v2/payments/${encodeURIComponent(id)}`);
|
|
175
|
+
return true;
|
|
176
|
+
} catch {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
parseWebhook: (payload) => {
|
|
181
|
+
const event = payload;
|
|
182
|
+
return {
|
|
183
|
+
id: require_http.requireString(event.id, "webhook payment ID"),
|
|
184
|
+
type: `payment.${String(event.status ?? "updated")}`,
|
|
185
|
+
paymentId: require_http.asString(event.id),
|
|
186
|
+
data: event,
|
|
187
|
+
occurredAt: require_http.now()
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
exports.createMollieAdapter = createMollieAdapter;
|
|
193
|
+
|
|
194
|
+
//# sourceMappingURL=mollie.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mollie.cjs","names":["toMajorUnits","getCurrencyMinorUnit","fromMajorUnits","requireString","asString","now","requestJson","jsonHeaders","createProviderError","verifyHmacSha256"],"sources":["../src/mollie.ts"],"sourcesContent":["import {\n createMoney,\n getCurrencyMinorUnit,\n fromMajorUnits,\n toMajorUnits,\n type CreateCheckoutSessionRequest,\n type PaymentProviderAdapter,\n type PaymentAttempt,\n type ProviderWebhookEvent,\n type RefundPaymentRequest,\n} from \"@puzzle-ui/commerce\";\nimport {\n asString,\n createProviderError,\n jsonHeaders,\n now,\n requestJson,\n requireString,\n type ProviderFetcher,\n} from \"./http\";\nimport { verifyHmacSha256 } from \"./signatures\";\n\nexport type MollieAdapterOptions = {\n readonly apiKey: string;\n readonly apiBaseUrl?: string;\n readonly fetcher?: ProviderFetcher;\n readonly webhookSignatureEncoding?: \"hex\" | \"base64\";\n};\n\nconst provider = \"mollie\";\n\nconst providerAmount = (value: ReturnType<typeof createMoney>) =>\n toMajorUnits(value).toFixed(\n getCurrencyMinorUnit(value.currency, { allowUnknownCurrencies: true }),\n );\n\nconst moneyFromMollie = (value: unknown, fallbackCurrency: string) => {\n const amount = value as Record<string, unknown> | undefined;\n const currency = String(amount?.currency ?? fallbackCurrency).toUpperCase();\n const major = Number(amount?.value);\n if (!Number.isFinite(major)) {\n throw new Error(\"Mollie response omitted a valid amount.\");\n }\n return fromMajorUnits(major, currency);\n};\n\nconst paymentFromMollie = (\n value: Record<string, unknown>,\n fallback: Pick<PaymentAttempt, \"id\" | \"orderId\" | \"amount\">,\n): PaymentAttempt => {\n const status = String(value.status ?? \"open\");\n const normalized: PaymentAttempt[\"status\"] =\n status === \"paid\" || status === \"paid_out\"\n ? \"succeeded\"\n : status === \"authorized\"\n ? \"authorized\"\n : status === \"pending\" || status === \"open\"\n ? \"processing\"\n : status === \"canceled\" || status === \"expired\"\n ? \"cancelled\"\n : status === \"failed\"\n ? \"failed\"\n : \"pending\";\n const amount = moneyFromMollie(value.amount, fallback.amount.currency);\n return {\n id: fallback.id,\n orderId: fallback.orderId,\n amount,\n status: normalized,\n provider,\n providerPaymentId: requireString(value.id, \"payment ID\"),\n capturedAmount: normalized === \"succeeded\" ? amount : undefined,\n failure:\n normalized === \"failed\"\n ? {\n code: \"declined\",\n message: \"Mollie payment failed.\",\n providerCode: asString(value.failureReason),\n retryable: false,\n decline: true,\n }\n : undefined,\n createdAt: value.createdAt ? new Date(String(value.createdAt)) : now(),\n updatedAt: now(),\n };\n};\n\nexport const createMollieAdapter = (\n options: MollieAdapterOptions,\n): PaymentProviderAdapter => {\n if (!options.apiKey.trim()) throw new TypeError(\"Mollie API key is required.\");\n const fetcher = options.fetcher ?? fetch;\n const baseUrl = options.apiBaseUrl ?? \"https://api.mollie.com\";\n const request = async (path: string, init: RequestInit = {}) => {\n try {\n return await requestJson(fetcher, `${baseUrl}${path}`, {\n ...init,\n headers: {\n ...jsonHeaders({ Authorization: `Bearer ${options.apiKey}` }),\n ...init.headers,\n },\n });\n } catch (error) {\n throw createProviderError(error);\n }\n };\n\n return {\n id: provider,\n name: \"Mollie\",\n capabilities: {\n payments: true,\n refunds: true,\n partialRefund: true,\n recurring: true,\n hostedCheckout: true,\n delayedPaymentMethods: true,\n webhooks: true,\n idempotency: true,\n },\n createPayment: async (input, context) => {\n const payment = await request(\"/v2/payments\", {\n method: \"POST\",\n headers: {\n \"Idempotency-Key\": context?.idempotencyKey ?? input.paymentId,\n },\n body: JSON.stringify({\n amount: {\n currency: input.amount.currency,\n value: providerAmount(input.amount),\n },\n description: `Order ${input.orderId}`,\n redirectUrl: input.returnUrl,\n metadata: { order_id: input.orderId, payment_id: input.paymentId },\n }),\n });\n return paymentFromMollie(payment, {\n id: input.paymentId,\n orderId: input.orderId,\n amount: input.amount,\n });\n },\n getPayment: async (providerPaymentId) => {\n const payment = await request(`/v2/payments/${encodeURIComponent(providerPaymentId)}`);\n return paymentFromMollie(payment, {\n id: providerPaymentId,\n orderId: String(\n (payment.metadata as Record<string, unknown> | undefined)?.order_id ?? \"\",\n ),\n amount: moneyFromMollie(payment.amount, \"EUR\"),\n });\n },\n refund: async ({ payment, refund, context }: RefundPaymentRequest) => {\n const result = await request(\n `/v2/payments/${encodeURIComponent(requireString(payment.providerPaymentId, \"provider payment ID\"))}/refunds`,\n {\n method: \"POST\",\n headers: {\n \"Idempotency-Key\": context?.idempotencyKey ?? refund.id,\n },\n body: JSON.stringify({\n amount: {\n currency: refund.amount.currency,\n value: providerAmount(refund.amount),\n },\n description: refund.reason,\n }),\n },\n );\n return {\n ...refund,\n providerRefundId: requireString(result.id, \"refund ID\"),\n status:\n result.status === \"refunded\"\n ? \"succeeded\"\n : result.status === \"failed\"\n ? \"failed\"\n : \"pending\",\n updatedAt: now(),\n };\n },\n createCheckoutSession: async (input: CreateCheckoutSessionRequest) => {\n const payment = await request(\"/v2/payments\", {\n method: \"POST\",\n body: JSON.stringify({\n amount: {\n currency: input.amount.currency,\n value: providerAmount(input.amount),\n },\n description: `Order ${input.orderId}`,\n redirectUrl: input.returnUrl,\n metadata: { order_id: input.orderId, payment_id: input.paymentId },\n }),\n });\n const checkout = (payment._links as Record<string, unknown> | undefined)?.checkout as\n | Record<string, unknown>\n | undefined;\n return {\n id: requireString(payment.id, \"payment ID\"),\n provider,\n paymentId: input.paymentId,\n url: asString(checkout?.href),\n };\n },\n getSupportedPaymentMethods: async () => [\n { id: \"ideal\", type: \"bank\", label: \"iDEAL\", provider },\n { id: \"bancontact\", type: \"bank\", label: \"Bancontact\", provider },\n { id: \"card\", type: \"card\", label: \"Card\", provider },\n ],\n verifyWebhook: async (payload, signature, secret) => {\n const body = typeof payload === \"string\" ? payload : new TextDecoder().decode(payload);\n if (secret) {\n return verifyHmacSha256({\n payload: body,\n signature,\n secret,\n encoding: options.webhookSignatureEncoding ?? \"base64\",\n });\n }\n try {\n const parsed = JSON.parse(body) as Record<string, unknown>;\n const id = asString(parsed.id);\n if (!id) return false;\n await request(`/v2/payments/${encodeURIComponent(id)}`);\n return true;\n } catch {\n return false;\n }\n },\n parseWebhook: (payload): ProviderWebhookEvent => {\n const event = payload as Record<string, unknown>;\n return {\n id: requireString(event.id, \"webhook payment ID\"),\n type: `payment.${String(event.status ?? \"updated\")}`,\n paymentId: asString(event.id),\n data: event,\n occurredAt: now(),\n };\n },\n };\n};\n"],"mappings":";;;;;AA6BA,MAAM,WAAW;AAEjB,MAAM,kBAAkB,WAAA,GACtBA,oBAAAA,aAAAA,CAAa,KAAK,CAAC,CAAC,SAAA,GAClBC,oBAAAA,qBAAAA,CAAqB,MAAM,UAAU,EAA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AAS,OAAO,EAAE;IAC7B,IAAI,CAAC,IAAI,OAAO;IAChB,MAAM,QAAQ,gBAAgB,mBAAmB,EAAE,GAAG;IACtD,OAAO;GACT,QAAQ;IACN,OAAO;GACT;EACF;EACA,eAAe,YAAkC;GAC/C,MAAM,QAAQ;GACd,OAAO;IACL,IAAID,aAAAA,cAAc,MAAM,IAAI,oBAAoB;IAChD,MAAM,WAAW,OAAO,MAAM,UAAU,SAAS;IACjD,WAAWC,aAAAA,SAAS,MAAM,EAAE;IAC5B,MAAM;IACN,YAAYC,aAAAA,IAAI;GAClB;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { t as ProviderFetcher } from "./http-BJTHkHOr.cjs";
|
|
2
|
+
import { PaymentProviderAdapter } from "@puzzle-ui/commerce";
|
|
3
|
+
export type MollieAdapterOptions = {
|
|
4
|
+
readonly apiKey: string;
|
|
5
|
+
readonly apiBaseUrl?: string;
|
|
6
|
+
readonly fetcher?: ProviderFetcher;
|
|
7
|
+
readonly webhookSignatureEncoding?: "hex" | "base64";
|
|
8
|
+
};
|
|
9
|
+
export declare const createMollieAdapter: (options: MollieAdapterOptions) => PaymentProviderAdapter;
|
package/dist/mollie.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { t as ProviderFetcher } from "./http-BJTHkHOr.js";
|
|
2
|
+
import { PaymentProviderAdapter } from "@puzzle-ui/commerce";
|
|
3
|
+
export type MollieAdapterOptions = {
|
|
4
|
+
readonly apiKey: string;
|
|
5
|
+
readonly apiBaseUrl?: string;
|
|
6
|
+
readonly fetcher?: ProviderFetcher;
|
|
7
|
+
readonly webhookSignatureEncoding?: "hex" | "base64";
|
|
8
|
+
};
|
|
9
|
+
export declare const createMollieAdapter: (options: MollieAdapterOptions) => PaymentProviderAdapter;
|