kassza 0.11.0 → 0.13.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 +376 -111
- package/agents/README.md +20 -5
- package/agents/api.md +165 -2
- package/agents/pitfalls.md +16 -3
- package/agents/recipes.md +215 -45
- package/agents/skills/kassza/SKILL.md +11 -8
- package/dist/cli.cjs +552 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +552 -0
- package/dist/client-6MkeuFqD.d.ts +268 -0
- package/dist/client-B5FryKxJ.d.cts +268 -0
- package/dist/client-C-PdfL_P.cjs +1275 -0
- package/dist/client-CfaS1-Jx.js +1228 -0
- package/dist/context-BxQlIlug.d.ts +425 -0
- package/dist/context-DXNbTPwz.d.cts +425 -0
- package/dist/create-once-Cz621l8r.js +330 -0
- package/dist/create-once-DgMtKKcG.cjs +395 -0
- package/dist/crypto-Dpn4FHQ6.cjs +65 -0
- package/dist/crypto-usDg8L2K.js +36 -0
- package/dist/data-link/index.cjs +232 -0
- package/dist/data-link/index.d.cts +79 -0
- package/dist/data-link/index.d.ts +79 -0
- package/dist/data-link/index.js +224 -0
- package/dist/{dates-DtHzwNU6.d.cts → dates-9zvESP0i.d.cts} +2 -1
- package/dist/{dates-DtHzwNU6.d.ts → dates-9zvESP0i.d.ts} +2 -1
- package/dist/{dates-PPxH0n5H.cjs → dates-CPgBodkP.cjs} +44 -1
- package/dist/{dates-D2XebOIg.js → dates-CXyj7Azy.js} +39 -2
- package/dist/delegation/index.cjs +396 -0
- package/dist/delegation/index.d.cts +100 -0
- package/dist/delegation/index.d.ts +100 -0
- package/dist/delegation/index.js +378 -0
- package/dist/{errors-DapdV5DK.js → errors-DLrb0g64.js} +122 -5
- package/dist/{errors-B0QJhUW1.cjs → errors-DxeuTslP.cjs} +127 -4
- package/dist/get-Byc9T5WO.d.cts +151 -0
- package/dist/get-Byc9T5WO.d.ts +151 -0
- package/dist/get-Csm2n0rZ.cjs +445 -0
- package/dist/get-DT3JEgQ6.js +380 -0
- package/dist/index.cjs +21 -1410
- package/dist/index.d.cts +20 -3
- package/dist/index.d.ts +20 -3
- package/dist/index.js +8 -1409
- package/dist/ipn/index.cjs +1 -1
- package/dist/ipn/index.js +1 -1
- package/dist/issue-AGRohSm7.cjs +914 -0
- package/dist/issue-DtSLpVdJ.js +777 -0
- package/dist/json-4y4E2xxS.cjs +61 -0
- package/dist/json-B70TwoX1.d.cts +4 -0
- package/dist/json-B70TwoX1.d.ts +4 -0
- package/dist/json-DjnqnaJK.js +32 -0
- package/dist/mcp/index.cjs +10 -0
- package/dist/mcp/index.d.cts +71 -0
- package/dist/mcp/index.d.ts +71 -0
- package/dist/mcp/index.js +2 -0
- package/dist/money/index.cjs +12 -10
- package/dist/money/index.js +3 -1
- package/dist/{money-DkiGukAw.cjs → money-BxytJW6f.cjs} +42 -177
- package/dist/{money-C9j7nBNP.js → money-t7uy1n91.js} +29 -110
- package/dist/nav/index.cjs +1046 -0
- package/dist/nav/index.d.cts +247 -0
- package/dist/nav/index.d.ts +247 -0
- package/dist/nav/index.js +1012 -0
- package/dist/nav-BEwcX7-N.cjs +203 -0
- package/dist/nav-CK1WgYo7.js +156 -0
- package/dist/parse-BJj-aqKy.cjs +380 -0
- package/dist/parse-C608ehqM.js +291 -0
- package/dist/payments/barion.cjs +208 -0
- package/dist/payments/barion.d.cts +28 -0
- package/dist/payments/barion.d.ts +28 -0
- package/dist/payments/barion.js +199 -0
- package/dist/payments/index.cjs +16 -0
- package/dist/payments/index.d.cts +31 -0
- package/dist/payments/index.d.ts +31 -0
- package/dist/payments/index.js +3 -0
- package/dist/payments/paypal.cjs +351 -0
- package/dist/payments/paypal.d.cts +59 -0
- package/dist/payments/paypal.d.ts +59 -0
- package/dist/payments/paypal.js +337 -0
- package/dist/payments/revolut.cjs +261 -0
- package/dist/payments/revolut.d.cts +48 -0
- package/dist/payments/revolut.d.ts +48 -0
- package/dist/payments/revolut.js +249 -0
- package/dist/payments/simplepay.cjs +313 -0
- package/dist/payments/simplepay.d.cts +86 -0
- package/dist/payments/simplepay.d.ts +86 -0
- package/dist/payments/simplepay.js +299 -0
- package/dist/payments/stripe.cjs +315 -0
- package/dist/payments/stripe.d.cts +49 -0
- package/dist/payments/stripe.d.ts +49 -0
- package/dist/payments/stripe.js +303 -0
- package/dist/reports/index.cjs +103 -0
- package/dist/reports/index.d.cts +70 -0
- package/dist/reports/index.d.ts +70 -0
- package/dist/reports/index.js +94 -0
- package/dist/request-body-CH6ZGOrq.cjs +34 -0
- package/dist/request-body-uZHMRlQr.js +29 -0
- package/dist/rounding-BLyHjjI5.js +20 -0
- package/dist/rounding-TxoWy2ww.cjs +37 -0
- package/dist/serialize-BXOww1Uq.cjs +286 -0
- package/dist/serialize-DSE_o9RK.js +215 -0
- package/dist/server-C6PoNkdD.cjs +1557 -0
- package/dist/server-Cd8HB661.js +1504 -0
- package/dist/storage/fs.cjs +1 -1
- package/dist/storage/fs.js +1 -1
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.d.cts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js +2 -2
- package/dist/tax-number-BYFkBp4A.cjs +141 -0
- package/dist/tax-number-BdqKsxNR.js +76 -0
- package/dist/testing/index.cjs +1656 -84
- package/dist/testing/index.d.cts +203 -3
- package/dist/testing/index.d.ts +203 -3
- package/dist/testing/index.js +1653 -83
- package/dist/types-BVeR7KyU.d.cts +56 -0
- package/dist/types-BVeR7KyU.d.ts +56 -0
- package/dist/types-DH8QoNZK.d.cts +135 -0
- package/dist/types-k--zHf4l.d.ts +135 -0
- package/dist/validators/index.cjs +14 -88
- package/dist/validators/index.js +1 -75
- package/dist/vat-g35srbNG.cjs +116 -0
- package/dist/vat-v_dcWCto.js +81 -0
- package/dist/webhook-81giRMdQ.cjs +223 -0
- package/dist/webhook-CpCMHhn2.d.ts +6 -0
- package/dist/webhook-CpMJuP6c.d.cts +6 -0
- package/dist/webhook-CrEGohbg.js +152 -0
- package/llms.txt +4 -4
- package/package.json +148 -2
- package/dist/client-B9kbKKBf.d.cts +0 -748
- package/dist/client-zv4enyq7.d.ts +0 -748
- package/dist/create-5YkUcJSe.js +0 -957
- package/dist/create-DZsl3Z4m.cjs +0 -1178
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { i as encodeUtf8, n as bytesToBase64 } from "../binary-D0M9U2MD.js";
|
|
2
|
+
import { r as roundMoney } from "../rounding-BLyHjjI5.js";
|
|
3
|
+
import { a as readRawBody, d as normalizeCurrency, f as parseDecimalAmount, i as plainResponse, o as PaymentProviderError, r as parseJsonObject, s as WebhookVerificationError, t as respondToWebhook } from "../webhook-CrEGohbg.js";
|
|
4
|
+
import { a as text, i as records, n as path, r as record, t as numeric } from "../json-DjnqnaJK.js";
|
|
5
|
+
//#region src/payments/paypal.ts
|
|
6
|
+
const PAYPAL_LIVE_API_URL = "https://api-m.paypal.com";
|
|
7
|
+
const PAYPAL_SANDBOX_API_URL = "https://api-m.sandbox.paypal.com";
|
|
8
|
+
const PAYPAL_METHOD = "PayPal";
|
|
9
|
+
const PAYPAL_SHIPPING_ITEM_NAME = "Szállítási díj";
|
|
10
|
+
const PAYPAL_HANDLING_ITEM_NAME = "Kezelési díj";
|
|
11
|
+
const PAYPAL_INSURANCE_ITEM_NAME = "Biztosítás";
|
|
12
|
+
const TOKEN_REFRESH_MARGIN_MS = 6e4;
|
|
13
|
+
const AMOUNT_TOLERANCE = .005;
|
|
14
|
+
const UNAUTHORIZED = 401;
|
|
15
|
+
const TRANSMISSION_HEADERS = {
|
|
16
|
+
authAlgo: "paypal-auth-algo",
|
|
17
|
+
certUrl: "paypal-cert-url",
|
|
18
|
+
transmissionId: "paypal-transmission-id",
|
|
19
|
+
transmissionSig: "paypal-transmission-sig",
|
|
20
|
+
transmissionTime: "paypal-transmission-time"
|
|
21
|
+
};
|
|
22
|
+
function apiBase(options) {
|
|
23
|
+
return (options.apiUrl ?? (options.sandbox ? "https://api-m.sandbox.paypal.com" : "https://api-m.paypal.com")).replace(/\/+$/, "");
|
|
24
|
+
}
|
|
25
|
+
async function readJson(response, what) {
|
|
26
|
+
const json = record(await response.json().catch(() => void 0));
|
|
27
|
+
if (!response.ok || !json) {
|
|
28
|
+
const detail = text(json?.message) ?? text(json?.error_description) ?? text(json?.name);
|
|
29
|
+
throw new PaymentProviderError("paypal", `A PayPal ${what} nem sikerült (HTTP ${response.status})${detail ? `: ${detail}` : ""}.`, response.status);
|
|
30
|
+
}
|
|
31
|
+
return json;
|
|
32
|
+
}
|
|
33
|
+
function payPalApi(options) {
|
|
34
|
+
const clientId = options.clientId?.trim();
|
|
35
|
+
const clientSecret = options.clientSecret?.trim();
|
|
36
|
+
if (!clientId || !clientSecret) throw new TypeError("Add meg a PayPal REST alkalmazás clientId és clientSecret adatát.");
|
|
37
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
38
|
+
const base = apiBase(options);
|
|
39
|
+
const now = options.now ?? Date.now;
|
|
40
|
+
let cached;
|
|
41
|
+
async function fetchOrThrow(url, init, what) {
|
|
42
|
+
try {
|
|
43
|
+
return await fetchImpl(url, init);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw new PaymentProviderError("paypal", `A PayPal ${what} nem sikerült.`, void 0, error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function token() {
|
|
49
|
+
if (cached && cached.expiresAt > now()) return cached.value;
|
|
50
|
+
const credentials = bytesToBase64(encodeUtf8(`${clientId}:${clientSecret}`));
|
|
51
|
+
const json = await readJson(await fetchOrThrow(`${base}/v1/oauth2/token`, {
|
|
52
|
+
method: "POST",
|
|
53
|
+
headers: {
|
|
54
|
+
authorization: `Basic ${credentials}`,
|
|
55
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
56
|
+
accept: "application/json"
|
|
57
|
+
},
|
|
58
|
+
body: "grant_type=client_credentials"
|
|
59
|
+
}, "hozzáférési token kérése"), "hozzáférési token kérése");
|
|
60
|
+
const value = text(json.access_token);
|
|
61
|
+
if (!value) throw new PaymentProviderError("paypal", "A PayPal token válaszából hiányzik az access_token.");
|
|
62
|
+
const lifetimeMs = (numeric(json.expires_in) ?? 0) * 1e3;
|
|
63
|
+
cached = {
|
|
64
|
+
value,
|
|
65
|
+
expiresAt: now() + Math.max(0, lifetimeMs - TOKEN_REFRESH_MARGIN_MS)
|
|
66
|
+
};
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
async function send(method, pathname, body) {
|
|
70
|
+
const what = `${method} ${pathname} hívás`;
|
|
71
|
+
const attempt = async () => fetchOrThrow(`${base}${pathname}`, {
|
|
72
|
+
method,
|
|
73
|
+
headers: {
|
|
74
|
+
authorization: `Bearer ${await token()}`,
|
|
75
|
+
accept: "application/json",
|
|
76
|
+
...body === void 0 ? {} : { "content-type": "application/json" }
|
|
77
|
+
},
|
|
78
|
+
...body === void 0 ? {} : { body }
|
|
79
|
+
}, what);
|
|
80
|
+
let response = await attempt();
|
|
81
|
+
if (response.status === UNAUTHORIZED) {
|
|
82
|
+
cached = void 0;
|
|
83
|
+
response = await attempt();
|
|
84
|
+
}
|
|
85
|
+
return readJson(response, what);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
get: (pathname) => send("GET", pathname),
|
|
89
|
+
post: (pathname, body) => send("POST", pathname, body)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function payPalTransmission(headers) {
|
|
93
|
+
const authAlgo = headers.get(TRANSMISSION_HEADERS.authAlgo)?.trim();
|
|
94
|
+
const certUrl = headers.get(TRANSMISSION_HEADERS.certUrl)?.trim();
|
|
95
|
+
const transmissionId = headers.get(TRANSMISSION_HEADERS.transmissionId)?.trim();
|
|
96
|
+
const transmissionSig = headers.get(TRANSMISSION_HEADERS.transmissionSig)?.trim();
|
|
97
|
+
const transmissionTime = headers.get(TRANSMISSION_HEADERS.transmissionTime)?.trim();
|
|
98
|
+
if (!authAlgo || !certUrl || !transmissionId || !transmissionSig || !transmissionTime) return;
|
|
99
|
+
return {
|
|
100
|
+
authAlgo,
|
|
101
|
+
certUrl,
|
|
102
|
+
transmissionId,
|
|
103
|
+
transmissionSig,
|
|
104
|
+
transmissionTime
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async function verifyPayPalWebhook(payload, headers, webhookId, api) {
|
|
108
|
+
const transmission = payPalTransmission(headers);
|
|
109
|
+
if (!transmission) throw new WebhookVerificationError("paypal", "missing_signature", "Hiányoznak a PayPal webhook PAYPAL-TRANSMISSION-* és PAYPAL-AUTH-ALGO fejlécei.");
|
|
110
|
+
parseJsonObject("paypal", payload);
|
|
111
|
+
const body = [
|
|
112
|
+
`{"auth_algo":${JSON.stringify(transmission.authAlgo)}`,
|
|
113
|
+
`"cert_url":${JSON.stringify(transmission.certUrl)}`,
|
|
114
|
+
`"transmission_id":${JSON.stringify(transmission.transmissionId)}`,
|
|
115
|
+
`"transmission_sig":${JSON.stringify(transmission.transmissionSig)}`,
|
|
116
|
+
`"transmission_time":${JSON.stringify(transmission.transmissionTime)}`,
|
|
117
|
+
`"webhook_id":${JSON.stringify(webhookId)}`,
|
|
118
|
+
`"webhook_event":${payload.trim()}}`
|
|
119
|
+
].join(",");
|
|
120
|
+
const result = await api.post("/v1/notifications/verify-webhook-signature", body);
|
|
121
|
+
if (text(result.verification_status) !== "SUCCESS") throw new WebhookVerificationError("paypal", "invalid_signature", "A PayPal szerint a webhook aláírása érvénytelen.");
|
|
122
|
+
}
|
|
123
|
+
function parsePayPalEvent(payload) {
|
|
124
|
+
const json = parseJsonObject("paypal", payload);
|
|
125
|
+
const id = text(json.id);
|
|
126
|
+
const eventType = text(json.event_type);
|
|
127
|
+
const resource = record(json.resource);
|
|
128
|
+
if (!id || !eventType || !resource) throw new WebhookVerificationError("paypal", "invalid_payload", "A PayPal eseményből hiányzik az id, az event_type vagy a resource.");
|
|
129
|
+
return {
|
|
130
|
+
id,
|
|
131
|
+
eventType,
|
|
132
|
+
resourceType: text(json.resource_type),
|
|
133
|
+
createTime: text(json.create_time),
|
|
134
|
+
resource,
|
|
135
|
+
raw: json
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function moneyValue(value) {
|
|
139
|
+
const amount = text(record(value)?.value);
|
|
140
|
+
return amount === void 0 ? void 0 : parseDecimalAmount(amount);
|
|
141
|
+
}
|
|
142
|
+
function moneyOf(value) {
|
|
143
|
+
const amount = moneyValue(value);
|
|
144
|
+
const currency = text(record(value)?.currency_code);
|
|
145
|
+
if (amount === void 0 || !currency) return void 0;
|
|
146
|
+
return {
|
|
147
|
+
value: amount,
|
|
148
|
+
currency: normalizeCurrency(currency)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function payPalCaptureIdOfRefund(refund) {
|
|
152
|
+
const up = records(refund.links).find((link) => text(link.rel) === "up");
|
|
153
|
+
const href = text(up?.href);
|
|
154
|
+
if (!href) return void 0;
|
|
155
|
+
const match = /\/captures\/([^/?#]+)/.exec(href);
|
|
156
|
+
return match?.[1] ? decodeURIComponent(match[1]) : void 0;
|
|
157
|
+
}
|
|
158
|
+
function payPalOrderIdOfCapture(capture) {
|
|
159
|
+
return text(path(capture, "supplementary_data", "related_ids", "order_id"));
|
|
160
|
+
}
|
|
161
|
+
function addressOf(address) {
|
|
162
|
+
if (!address) return void 0;
|
|
163
|
+
return {
|
|
164
|
+
country: text(address.country_code),
|
|
165
|
+
zip: text(address.postal_code),
|
|
166
|
+
city: text(address.admin_area_2),
|
|
167
|
+
line1: text(address.address_line_1),
|
|
168
|
+
line2: text(address.address_line_2)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function personName(name, country) {
|
|
172
|
+
const full = text(name?.full_name);
|
|
173
|
+
if (full) return full;
|
|
174
|
+
const given = text(name?.given_name);
|
|
175
|
+
const surname = text(name?.surname);
|
|
176
|
+
const joined = (country === "HU" ? [surname, given] : [given, surname]).filter(Boolean).join(" ");
|
|
177
|
+
return joined === "" ? void 0 : joined;
|
|
178
|
+
}
|
|
179
|
+
function customerOf(order) {
|
|
180
|
+
if (!order) return void 0;
|
|
181
|
+
const payer = record(order.payer);
|
|
182
|
+
const shipping = record(records(order.purchase_units)[0]?.shipping);
|
|
183
|
+
const payerAddress = addressOf(record(payer?.address));
|
|
184
|
+
const shippingAddress = addressOf(record(shipping?.address));
|
|
185
|
+
const address = payerAddress?.line1 ? payerAddress : shippingAddress ?? payerAddress;
|
|
186
|
+
const name = personName(record(payer?.name), address?.country) ?? text(path(shipping, "name", "full_name"));
|
|
187
|
+
const email = text(payer?.email_address);
|
|
188
|
+
if (!name && !email && !address) return void 0;
|
|
189
|
+
return {
|
|
190
|
+
name,
|
|
191
|
+
email,
|
|
192
|
+
phone: text(path(payer, "phone", "phone_number", "national_number")),
|
|
193
|
+
address
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function sameCurrency(values, currency) {
|
|
197
|
+
return values.every((value) => {
|
|
198
|
+
const code = text(record(value)?.currency_code);
|
|
199
|
+
return code === void 0 || normalizeCurrency(code) === currency;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function extraItem(value, name) {
|
|
203
|
+
const amount = moneyValue(value) ?? 0;
|
|
204
|
+
return amount > 0 ? [{
|
|
205
|
+
name,
|
|
206
|
+
quantity: 1,
|
|
207
|
+
totalGross: amount
|
|
208
|
+
}] : [];
|
|
209
|
+
}
|
|
210
|
+
function itemsOf(order, currency) {
|
|
211
|
+
const units = records(order?.purchase_units);
|
|
212
|
+
const unit = units[0];
|
|
213
|
+
if (!unit || units.length !== 1 || !currency) return void 0;
|
|
214
|
+
const breakdown = record(path(unit, "amount", "breakdown"));
|
|
215
|
+
const discount = (moneyValue(breakdown?.discount) ?? 0) + (moneyValue(breakdown?.shipping_discount) ?? 0);
|
|
216
|
+
const items = records(unit.items);
|
|
217
|
+
if (discount > 0 || items.length === 0) return void 0;
|
|
218
|
+
if ((moneyValue(breakdown?.tax_total) ?? 0) > 0 && !items.every((item) => record(item.tax))) return void 0;
|
|
219
|
+
if (!sameCurrency([
|
|
220
|
+
...items.flatMap((item) => [item.unit_amount, item.tax]),
|
|
221
|
+
breakdown?.shipping,
|
|
222
|
+
breakdown?.handling,
|
|
223
|
+
breakdown?.insurance
|
|
224
|
+
], currency)) return void 0;
|
|
225
|
+
return [
|
|
226
|
+
...items.map((item) => {
|
|
227
|
+
const quantity = numeric(item.quantity) ?? 1;
|
|
228
|
+
const unitGross = (moneyValue(item.unit_amount) ?? 0) + (moneyValue(item.tax) ?? 0);
|
|
229
|
+
return {
|
|
230
|
+
name: text(item.name) ?? "Tétel",
|
|
231
|
+
quantity,
|
|
232
|
+
totalGross: roundMoney(unitGross * quantity, 2),
|
|
233
|
+
sku: text(item.sku)
|
|
234
|
+
};
|
|
235
|
+
}),
|
|
236
|
+
...extraItem(breakdown?.shipping, PAYPAL_SHIPPING_ITEM_NAME),
|
|
237
|
+
...extraItem(breakdown?.handling, PAYPAL_HANDLING_ITEM_NAME),
|
|
238
|
+
...extraItem(breakdown?.insurance, PAYPAL_INSURANCE_ITEM_NAME)
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
function orderRefOf(resource, order) {
|
|
242
|
+
const unit = records(order?.purchase_units)[0];
|
|
243
|
+
return text(resource.custom_id) ?? text(resource.invoice_id) ?? text(unit?.custom_id) ?? text(unit?.invoice_id) ?? text(unit?.reference_id);
|
|
244
|
+
}
|
|
245
|
+
function fromCapture(event, kind, options) {
|
|
246
|
+
const capture = event.resource;
|
|
247
|
+
const id = text(capture.id);
|
|
248
|
+
if (!id) throw new PaymentProviderError("paypal", "A PayPal capture eseményből hiányzik az id.");
|
|
249
|
+
const amount = moneyOf(capture.amount);
|
|
250
|
+
const status = text(capture.status);
|
|
251
|
+
return {
|
|
252
|
+
provider: "paypal",
|
|
253
|
+
kind: kind === "paid" && status !== void 0 && status !== "COMPLETED" ? "other" : kind,
|
|
254
|
+
id,
|
|
255
|
+
eventId: event.id,
|
|
256
|
+
eventType: event.eventType,
|
|
257
|
+
orderRef: orderRefOf(capture, options.order),
|
|
258
|
+
amount,
|
|
259
|
+
paidAt: text(capture.create_time) ?? event.createTime,
|
|
260
|
+
method: options.method ?? "PayPal",
|
|
261
|
+
customer: customerOf(options.order),
|
|
262
|
+
items: kind === "paid" ? itemsOf(options.order, amount?.currency) : void 0,
|
|
263
|
+
raw: event.raw
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
function refundKind(refund, capture) {
|
|
267
|
+
if (text(refund.status) !== "COMPLETED") return "other";
|
|
268
|
+
const refunded = moneyValue(refund.amount);
|
|
269
|
+
const captured = moneyValue(capture?.amount);
|
|
270
|
+
if (refunded === void 0 || captured === void 0) return "partially-refunded";
|
|
271
|
+
return Math.abs(refunded - captured) <= AMOUNT_TOLERANCE ? "refunded" : "partially-refunded";
|
|
272
|
+
}
|
|
273
|
+
function fromRefund(event, options) {
|
|
274
|
+
const refund = event.resource;
|
|
275
|
+
const captureId = payPalCaptureIdOfRefund(refund);
|
|
276
|
+
if (!captureId) throw new PaymentProviderError("paypal", "A PayPal visszatérítésből nem olvasható ki az eredeti capture azonosítója.");
|
|
277
|
+
const capture = options.capture && text(options.capture.id) === captureId ? options.capture : void 0;
|
|
278
|
+
return {
|
|
279
|
+
provider: "paypal",
|
|
280
|
+
kind: refundKind(refund, capture),
|
|
281
|
+
id: captureId,
|
|
282
|
+
eventId: event.id,
|
|
283
|
+
eventType: event.eventType,
|
|
284
|
+
orderRef: orderRefOf(refund, void 0) ?? (capture ? orderRefOf(capture, void 0) : void 0),
|
|
285
|
+
amount: moneyOf(capture?.amount),
|
|
286
|
+
refundedAmount: moneyOf(path(refund, "seller_payable_breakdown", "total_refunded_amount")) ?? moneyOf(refund.amount),
|
|
287
|
+
paidAt: text(refund.create_time) ?? event.createTime,
|
|
288
|
+
method: options.method ?? "PayPal",
|
|
289
|
+
raw: event.raw
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function payPalPaymentEvent(event, options = {}) {
|
|
293
|
+
switch (event.eventType) {
|
|
294
|
+
case "PAYMENT.CAPTURE.COMPLETED": return fromCapture(event, "paid", options);
|
|
295
|
+
case "PAYMENT.CAPTURE.DENIED":
|
|
296
|
+
case "PAYMENT.CAPTURE.DECLINED": return fromCapture(event, "failed", options);
|
|
297
|
+
case "PAYMENT.CAPTURE.PENDING": return fromCapture(event, "other", options);
|
|
298
|
+
case "PAYMENT.CAPTURE.REFUNDED": return fromRefund(event, options);
|
|
299
|
+
default: return;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
async function loadExtras(event, api, options) {
|
|
303
|
+
if (event.eventType === "PAYMENT.CAPTURE.REFUNDED") {
|
|
304
|
+
const captureId = payPalCaptureIdOfRefund(event.resource);
|
|
305
|
+
if (!captureId) return {};
|
|
306
|
+
return { capture: await api.get(`/v2/payments/captures/${encodeURIComponent(captureId)}`) };
|
|
307
|
+
}
|
|
308
|
+
if (event.eventType !== "PAYMENT.CAPTURE.COMPLETED" || options.fetchOrder === false) return {};
|
|
309
|
+
const orderId = payPalOrderIdOfCapture(event.resource);
|
|
310
|
+
if (!orderId) return {};
|
|
311
|
+
return { order: await api.get(`/v2/checkout/orders/${encodeURIComponent(orderId)}`) };
|
|
312
|
+
}
|
|
313
|
+
function payPalWebhook(options) {
|
|
314
|
+
const webhookId = options.webhookId?.trim();
|
|
315
|
+
if (!webhookId) throw new TypeError("Add meg a PayPal webhook azonosítóját (webhookId).");
|
|
316
|
+
const api = payPalApi({
|
|
317
|
+
clientId: options.clientId,
|
|
318
|
+
clientSecret: options.clientSecret,
|
|
319
|
+
sandbox: options.sandbox,
|
|
320
|
+
apiUrl: options.apiUrl,
|
|
321
|
+
fetch: options.fetch
|
|
322
|
+
});
|
|
323
|
+
return (request) => respondToWebhook(options, async () => {
|
|
324
|
+
const payload = await readRawBody(request, "paypal", options.maxBodyBytes);
|
|
325
|
+
await verifyPayPalWebhook(payload, request.headers, webhookId, api);
|
|
326
|
+
const event = parsePayPalEvent(payload);
|
|
327
|
+
const extras = await loadExtras(event, api, options);
|
|
328
|
+
const payment = payPalPaymentEvent(event, {
|
|
329
|
+
method: options.method,
|
|
330
|
+
...extras
|
|
331
|
+
});
|
|
332
|
+
if (payment) await options.onPayment(payment);
|
|
333
|
+
return plainResponse(200, "OK");
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
//#endregion
|
|
337
|
+
export { PAYPAL_HANDLING_ITEM_NAME, PAYPAL_INSURANCE_ITEM_NAME, PAYPAL_LIVE_API_URL, PAYPAL_METHOD, PAYPAL_SANDBOX_API_URL, PAYPAL_SHIPPING_ITEM_NAME, parsePayPalEvent, payPalApi, payPalCaptureIdOfRefund, payPalOrderIdOfCapture, payPalPaymentEvent, payPalTransmission, payPalWebhook, verifyPayPalWebhook };
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_crypto = require("../crypto-Dpn4FHQ6.cjs");
|
|
3
|
+
const require_webhook = require("../webhook-81giRMdQ.cjs");
|
|
4
|
+
const require_json = require("../json-4y4E2xxS.cjs");
|
|
5
|
+
//#region src/payments/revolut.ts
|
|
6
|
+
const REVOLUT_LIVE_API_URL = "https://merchant.revolut.com";
|
|
7
|
+
const REVOLUT_SANDBOX_API_URL = "https://sandbox-merchant.revolut.com";
|
|
8
|
+
const REVOLUT_API_VERSION = "2026-08-17";
|
|
9
|
+
const REVOLUT_DEFAULT_TOLERANCE_MS = 3e5;
|
|
10
|
+
const REVOLUT_CARD_METHOD = "bankkártya";
|
|
11
|
+
const REVOLUT_ACCOUNT_METHOD = "Revolut Pay";
|
|
12
|
+
const REVOLUT_DIRECT_DEBIT_METHOD = "csoportos beszedés";
|
|
13
|
+
const SIGNATURE_VERSION = "v1";
|
|
14
|
+
const ORDER_EVENTS = /* @__PURE__ */ new Set(["ORDER_COMPLETED"]);
|
|
15
|
+
const FAILED_EVENTS = /* @__PURE__ */ new Set([
|
|
16
|
+
"ORDER_CANCELLED",
|
|
17
|
+
"ORDER_FAILED",
|
|
18
|
+
"ORDER_PAYMENT_DECLINED",
|
|
19
|
+
"ORDER_PAYMENT_FAILED"
|
|
20
|
+
]);
|
|
21
|
+
const OTHER_EVENTS = /* @__PURE__ */ new Set(["ORDER_AUTHORISED"]);
|
|
22
|
+
const SALE_ORDER_TYPES = /* @__PURE__ */ new Set(["payment", "payment_request"]);
|
|
23
|
+
function secretsOf(secret) {
|
|
24
|
+
const list = (typeof secret === "string" ? [secret] : [...secret]).map((value) => value.trim());
|
|
25
|
+
if (list.length === 0 || list.some((value) => value === "")) throw new TypeError("Add meg a Revolut webhook aláíró titkát (wsk_...).");
|
|
26
|
+
return list;
|
|
27
|
+
}
|
|
28
|
+
function signaturesOf(header) {
|
|
29
|
+
return header.split(",").map((part) => part.trim()).filter((part) => part.startsWith(`${SIGNATURE_VERSION}=`));
|
|
30
|
+
}
|
|
31
|
+
async function verifyRevolutSignature(payload, signatureHeader, timestampHeader, secret, options = {}) {
|
|
32
|
+
const secrets = secretsOf(secret);
|
|
33
|
+
const signatures = signatureHeader ? signaturesOf(signatureHeader) : [];
|
|
34
|
+
const timestamp = timestampHeader?.trim();
|
|
35
|
+
if (signatures.length === 0 || !timestamp) throw new require_webhook.WebhookVerificationError("revolut", "missing_signature", "Hiányzik a Revolut-Signature vagy a Revolut-Request-Timestamp fejléc.");
|
|
36
|
+
if (!/^\d+$/.test(timestamp)) throw new require_webhook.WebhookVerificationError("revolut", "invalid_signature", "A Revolut-Request-Timestamp fejléc nem ezredmásodperces UNIX időbélyeg.");
|
|
37
|
+
const tolerance = options.toleranceMs ?? 3e5;
|
|
38
|
+
const now = options.now?.() ?? Date.now();
|
|
39
|
+
if (tolerance > 0 && Math.abs(now - Number(timestamp)) > tolerance) throw new require_webhook.WebhookVerificationError("revolut", "timestamp_out_of_range", `A Revolut esemény időbélyege több mint ${Math.round(tolerance / 1e3)} másodperccel eltér.`);
|
|
40
|
+
const message = `${SIGNATURE_VERSION}.${timestamp}.${payload}`;
|
|
41
|
+
for (const key of secrets) {
|
|
42
|
+
const expected = `${SIGNATURE_VERSION}=${await require_crypto.hmacHex("SHA-256", key, message)}`;
|
|
43
|
+
if (signatures.some((signature) => require_crypto.timingSafeEqual(signature, expected))) return;
|
|
44
|
+
}
|
|
45
|
+
throw new require_webhook.WebhookVerificationError("revolut", "invalid_signature", "A Revolut aláírás nem egyezik.");
|
|
46
|
+
}
|
|
47
|
+
function parseRevolutEvent(payload) {
|
|
48
|
+
const json = require_webhook.parseJsonObject("revolut", payload);
|
|
49
|
+
const event = require_json.text(json.event);
|
|
50
|
+
if (!event) throw new require_webhook.WebhookVerificationError("revolut", "invalid_payload", "A Revolut eseményből hiányzik az event mező.");
|
|
51
|
+
return {
|
|
52
|
+
event,
|
|
53
|
+
orderId: require_json.text(json.order_id),
|
|
54
|
+
merchantOrderRef: require_json.text(json.merchant_order_ext_ref),
|
|
55
|
+
raw: json
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function apiBase(options) {
|
|
59
|
+
return (options.apiUrl ?? (options.sandbox ? "https://sandbox-merchant.revolut.com" : "https://merchant.revolut.com")).replace(/\/+$/, "");
|
|
60
|
+
}
|
|
61
|
+
async function fetchRevolutOrder(orderId, options) {
|
|
62
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
63
|
+
let response;
|
|
64
|
+
try {
|
|
65
|
+
response = await fetchImpl(`${apiBase(options)}/api/orders/${encodeURIComponent(orderId)}`, { headers: {
|
|
66
|
+
authorization: `Bearer ${options.apiKey}`,
|
|
67
|
+
"revolut-api-version": options.apiVersion ?? "2026-08-17",
|
|
68
|
+
accept: "application/json"
|
|
69
|
+
} });
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw new require_webhook.PaymentProviderError("revolut", "A Revolut rendelés lekérése nem sikerült.", void 0, error);
|
|
72
|
+
}
|
|
73
|
+
if (!response.ok) throw new require_webhook.PaymentProviderError("revolut", `A Revolut rendelés lekérése nem sikerült (HTTP ${response.status}).`, response.status);
|
|
74
|
+
const order = require_json.record(await response.json().catch(() => void 0));
|
|
75
|
+
if (!order || require_json.text(order.id) === void 0) throw new require_webhook.PaymentProviderError("revolut", "A Revolut rendelés válasza nem értelmezhető.");
|
|
76
|
+
return order;
|
|
77
|
+
}
|
|
78
|
+
function amountOf(order, key) {
|
|
79
|
+
const minor = require_json.numeric(order[key]);
|
|
80
|
+
const currency = require_json.text(order.currency);
|
|
81
|
+
if (minor === void 0 || !currency) return void 0;
|
|
82
|
+
return {
|
|
83
|
+
value: require_webhook.fromMinorUnits(minor, currency, "iso4217"),
|
|
84
|
+
currency: require_webhook.normalizeCurrency(currency)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function addressOf(address) {
|
|
88
|
+
if (!address) return void 0;
|
|
89
|
+
return {
|
|
90
|
+
country: require_json.text(address.country_code),
|
|
91
|
+
zip: require_json.text(address.postcode),
|
|
92
|
+
city: require_json.text(address.city),
|
|
93
|
+
line1: require_json.text(address.street_line_1),
|
|
94
|
+
line2: require_json.text(address.street_line_2)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function completedPayment(order) {
|
|
98
|
+
const payments = require_json.records(order.payments);
|
|
99
|
+
return payments.find((payment) => ["completed", "captured"].includes(require_json.text(payment.state) ?? "")) ?? payments.at(-1);
|
|
100
|
+
}
|
|
101
|
+
function customerOf(order) {
|
|
102
|
+
const customer = require_json.record(order.customer);
|
|
103
|
+
const payment = completedPayment(order);
|
|
104
|
+
const shipping = require_json.record(order.shipping);
|
|
105
|
+
const contact = require_json.record(shipping?.contact);
|
|
106
|
+
const address = addressOf(require_json.record(payment?.billing_address)) ?? addressOf(require_json.record(shipping?.address));
|
|
107
|
+
const name = require_json.text(customer?.full_name) ?? require_json.text(contact?.name);
|
|
108
|
+
const email = require_json.text(customer?.email) ?? require_json.text(contact?.email);
|
|
109
|
+
if (!name && !email && !address) return void 0;
|
|
110
|
+
return {
|
|
111
|
+
name,
|
|
112
|
+
email,
|
|
113
|
+
phone: require_json.text(customer?.phone) ?? require_json.text(contact?.phone),
|
|
114
|
+
address
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function itemsOf(order) {
|
|
118
|
+
const currency = require_json.text(order.currency);
|
|
119
|
+
if (!currency) return void 0;
|
|
120
|
+
const items = require_json.records(order.line_items).map((item) => {
|
|
121
|
+
const total = require_json.numeric(item.total_amount);
|
|
122
|
+
if (total === void 0) throw new require_webhook.PaymentProviderError("revolut", "A Revolut tételből hiányzik a total_amount.");
|
|
123
|
+
return {
|
|
124
|
+
name: require_json.text(item.name) ?? "Tétel",
|
|
125
|
+
quantity: require_json.numeric(require_json.path(item, "quantity", "value")) ?? 1,
|
|
126
|
+
totalGross: require_webhook.fromMinorUnits(total, currency, "iso4217"),
|
|
127
|
+
unit: require_json.text(require_json.path(item, "quantity", "unit")),
|
|
128
|
+
sku: require_json.text(item.external_id)
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
return items.length > 0 ? items : void 0;
|
|
132
|
+
}
|
|
133
|
+
function methodOf(order, configured) {
|
|
134
|
+
if (configured) return configured;
|
|
135
|
+
const type = require_json.text(require_json.path(completedPayment(order), "payment_method", "type"));
|
|
136
|
+
if (type === "revolut_pay_account" || type === "revolut_pay") return REVOLUT_ACCOUNT_METHOD;
|
|
137
|
+
if (type === "sepa_direct_debit") return REVOLUT_DIRECT_DEBIT_METHOD;
|
|
138
|
+
return REVOLUT_CARD_METHOD;
|
|
139
|
+
}
|
|
140
|
+
function orderRefOf(order, event) {
|
|
141
|
+
return require_json.text(require_json.path(order, "merchant_order_data", "reference")) ?? event.merchantOrderRef;
|
|
142
|
+
}
|
|
143
|
+
function eventBase(event, kind, id, method) {
|
|
144
|
+
return {
|
|
145
|
+
provider: "revolut",
|
|
146
|
+
kind,
|
|
147
|
+
id,
|
|
148
|
+
eventId: `${event.event}:${event.orderId ?? id}`,
|
|
149
|
+
eventType: event.event,
|
|
150
|
+
method,
|
|
151
|
+
raw: event.raw
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function fromSaleOrder(event, order, options) {
|
|
155
|
+
const id = require_json.text(order.id) ?? event.orderId ?? "";
|
|
156
|
+
assertCompleted(order);
|
|
157
|
+
return {
|
|
158
|
+
...eventBase(event, "paid", id, methodOf(order, options.method)),
|
|
159
|
+
orderRef: orderRefOf(order, event),
|
|
160
|
+
amount: amountOf(order, "amount"),
|
|
161
|
+
paidAt: require_json.text(order.updated_at),
|
|
162
|
+
customer: customerOf(order),
|
|
163
|
+
items: itemsOf(order)
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function assertCompleted(order) {
|
|
167
|
+
const state = require_json.text(order.state);
|
|
168
|
+
if (state !== "completed") throw new require_webhook.PaymentProviderError("revolut", `A(z) ${require_json.text(order.id) ?? "?"} Revolut rendelés állapota ${state ?? "ismeretlen"}, nem completed; a webhook újraküldésekor újra megnézzük.`);
|
|
169
|
+
}
|
|
170
|
+
function refundKind(refund, original) {
|
|
171
|
+
const refundAmount = require_json.numeric(refund.amount);
|
|
172
|
+
const originalAmount = require_json.numeric(original.amount);
|
|
173
|
+
const refundedTotal = require_json.numeric(original.refunded_amount);
|
|
174
|
+
return refundAmount !== void 0 && refundAmount === originalAmount && refundedTotal === refundAmount ? "refunded" : "partially-refunded";
|
|
175
|
+
}
|
|
176
|
+
function fromRefundOrder(event, refund, options) {
|
|
177
|
+
const original = options.originalOrder;
|
|
178
|
+
const originalId = require_json.text(refund.related_order_id);
|
|
179
|
+
if (!original || !originalId || require_json.text(original.id) !== originalId) throw new require_webhook.PaymentProviderError("revolut", "A Revolut visszatérítéshez nem található az eredeti rendelés.");
|
|
180
|
+
assertCompleted(refund);
|
|
181
|
+
return {
|
|
182
|
+
...eventBase(event, refundKind(refund, original), originalId, methodOf(original, options.method)),
|
|
183
|
+
orderRef: orderRefOf(original, event),
|
|
184
|
+
amount: amountOf(original, "amount"),
|
|
185
|
+
refundedAmount: amountOf(original, "refunded_amount") ?? amountOf(refund, "amount"),
|
|
186
|
+
paidAt: require_json.text(refund.updated_at),
|
|
187
|
+
customer: customerOf(original)
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function revolutPaymentEvent(event, options = {}) {
|
|
191
|
+
const orderId = event.orderId;
|
|
192
|
+
if (!orderId) return void 0;
|
|
193
|
+
if (FAILED_EVENTS.has(event.event)) return {
|
|
194
|
+
...eventBase(event, "failed", orderId, options.method ?? "bankkártya"),
|
|
195
|
+
orderRef: event.merchantOrderRef
|
|
196
|
+
};
|
|
197
|
+
if (OTHER_EVENTS.has(event.event)) return {
|
|
198
|
+
...eventBase(event, "other", orderId, options.method ?? "bankkártya"),
|
|
199
|
+
orderRef: event.merchantOrderRef
|
|
200
|
+
};
|
|
201
|
+
if (!ORDER_EVENTS.has(event.event)) return void 0;
|
|
202
|
+
const order = options.order;
|
|
203
|
+
if (!order || require_json.text(order.id) !== orderId) throw new require_webhook.PaymentProviderError("revolut", `A(z) ${event.event} eseményhez le kell kérni a(z) ${orderId} rendelést.`);
|
|
204
|
+
const type = require_json.text(order.type) ?? "payment";
|
|
205
|
+
if (type === "refund") return fromRefundOrder(event, order, options);
|
|
206
|
+
if (SALE_ORDER_TYPES.has(type)) return fromSaleOrder(event, order, options);
|
|
207
|
+
return {
|
|
208
|
+
...eventBase(event, "other", orderId, methodOf(order, options.method)),
|
|
209
|
+
orderRef: orderRefOf(order, event)
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
async function loadOrders(event, api) {
|
|
213
|
+
if (!event.orderId || !ORDER_EVENTS.has(event.event)) return {};
|
|
214
|
+
const order = await fetchRevolutOrder(event.orderId, api);
|
|
215
|
+
const relatedId = require_json.text(order.type) === "refund" ? require_json.text(order.related_order_id) : void 0;
|
|
216
|
+
if (!relatedId) return { order };
|
|
217
|
+
return {
|
|
218
|
+
order,
|
|
219
|
+
originalOrder: await fetchRevolutOrder(relatedId, api)
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function revolutWebhook(options) {
|
|
223
|
+
secretsOf(options.secret);
|
|
224
|
+
const apiKey = options.apiKey?.trim();
|
|
225
|
+
if (!apiKey) throw new TypeError("Add meg a Revolut titkos API-kulcsot (apiKey): a webhook csak a rendelés azonosítóját küldi.");
|
|
226
|
+
const api = {
|
|
227
|
+
apiKey,
|
|
228
|
+
sandbox: options.sandbox,
|
|
229
|
+
apiUrl: options.apiUrl,
|
|
230
|
+
apiVersion: options.apiVersion,
|
|
231
|
+
fetch: options.fetch
|
|
232
|
+
};
|
|
233
|
+
return (request) => require_webhook.respondToWebhook(options, async () => {
|
|
234
|
+
const payload = await require_webhook.readRawBody(request, "revolut", options.maxBodyBytes);
|
|
235
|
+
await verifyRevolutSignature(payload, request.headers.get("revolut-signature"), request.headers.get("revolut-request-timestamp"), options.secret, {
|
|
236
|
+
toleranceMs: options.toleranceMs,
|
|
237
|
+
now: options.now
|
|
238
|
+
});
|
|
239
|
+
const event = parseRevolutEvent(payload);
|
|
240
|
+
const orders = await loadOrders(event, api);
|
|
241
|
+
const payment = revolutPaymentEvent(event, {
|
|
242
|
+
method: options.method,
|
|
243
|
+
...orders
|
|
244
|
+
});
|
|
245
|
+
if (payment) await options.onPayment(payment);
|
|
246
|
+
return new Response(null, { status: 204 });
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
exports.REVOLUT_ACCOUNT_METHOD = REVOLUT_ACCOUNT_METHOD;
|
|
251
|
+
exports.REVOLUT_API_VERSION = REVOLUT_API_VERSION;
|
|
252
|
+
exports.REVOLUT_CARD_METHOD = REVOLUT_CARD_METHOD;
|
|
253
|
+
exports.REVOLUT_DEFAULT_TOLERANCE_MS = REVOLUT_DEFAULT_TOLERANCE_MS;
|
|
254
|
+
exports.REVOLUT_DIRECT_DEBIT_METHOD = REVOLUT_DIRECT_DEBIT_METHOD;
|
|
255
|
+
exports.REVOLUT_LIVE_API_URL = REVOLUT_LIVE_API_URL;
|
|
256
|
+
exports.REVOLUT_SANDBOX_API_URL = REVOLUT_SANDBOX_API_URL;
|
|
257
|
+
exports.fetchRevolutOrder = fetchRevolutOrder;
|
|
258
|
+
exports.parseRevolutEvent = parseRevolutEvent;
|
|
259
|
+
exports.revolutPaymentEvent = revolutPaymentEvent;
|
|
260
|
+
exports.revolutWebhook = revolutWebhook;
|
|
261
|
+
exports.verifyRevolutSignature = verifyRevolutSignature;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { i as PaymentEvent, l as PaymentWebhookBaseOptions } from "../types-BVeR7KyU.cjs";
|
|
2
|
+
import { t as JsonRecord } from "../json-B70TwoX1.cjs";
|
|
3
|
+
import { t as WebhookHandler } from "../webhook-CpMJuP6c.cjs";
|
|
4
|
+
//#region src/payments/revolut.d.ts
|
|
5
|
+
export declare const REVOLUT_LIVE_API_URL = "https://merchant.revolut.com";
|
|
6
|
+
export declare const REVOLUT_SANDBOX_API_URL = "https://sandbox-merchant.revolut.com";
|
|
7
|
+
export declare const REVOLUT_API_VERSION = "2026-08-17";
|
|
8
|
+
export declare const REVOLUT_DEFAULT_TOLERANCE_MS = 3e5;
|
|
9
|
+
export declare const REVOLUT_CARD_METHOD = "bankkártya";
|
|
10
|
+
export declare const REVOLUT_ACCOUNT_METHOD = "Revolut Pay";
|
|
11
|
+
export declare const REVOLUT_DIRECT_DEBIT_METHOD = "csoportos beszedés";
|
|
12
|
+
export interface VerifyRevolutSignatureOptions {
|
|
13
|
+
readonly toleranceMs?: number | undefined;
|
|
14
|
+
readonly now?: (() => number) | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare function verifyRevolutSignature(payload: string, signatureHeader: string | null | undefined, timestampHeader: string | null | undefined, secret: string | readonly string[], options?: VerifyRevolutSignatureOptions): Promise<void>;
|
|
17
|
+
export interface RevolutEvent {
|
|
18
|
+
readonly event: string;
|
|
19
|
+
readonly orderId?: string | undefined;
|
|
20
|
+
readonly merchantOrderRef?: string | undefined;
|
|
21
|
+
readonly raw: JsonRecord;
|
|
22
|
+
}
|
|
23
|
+
export declare function parseRevolutEvent(payload: string): RevolutEvent;
|
|
24
|
+
export interface RevolutApiOptions {
|
|
25
|
+
readonly apiKey: string;
|
|
26
|
+
readonly sandbox?: boolean | undefined;
|
|
27
|
+
readonly apiUrl?: string | undefined;
|
|
28
|
+
readonly apiVersion?: string | undefined;
|
|
29
|
+
readonly fetch?: typeof globalThis.fetch | undefined;
|
|
30
|
+
}
|
|
31
|
+
export declare function fetchRevolutOrder(orderId: string, options: RevolutApiOptions): Promise<JsonRecord>;
|
|
32
|
+
export interface RevolutPaymentOptions {
|
|
33
|
+
readonly method?: string | undefined;
|
|
34
|
+
readonly order?: JsonRecord | undefined;
|
|
35
|
+
readonly originalOrder?: JsonRecord | undefined;
|
|
36
|
+
}
|
|
37
|
+
export declare function revolutPaymentEvent(event: RevolutEvent, options?: RevolutPaymentOptions): PaymentEvent | undefined;
|
|
38
|
+
export interface RevolutWebhookOptions extends PaymentWebhookBaseOptions {
|
|
39
|
+
readonly secret: string | readonly string[];
|
|
40
|
+
readonly apiKey: string;
|
|
41
|
+
readonly sandbox?: boolean | undefined;
|
|
42
|
+
readonly apiUrl?: string | undefined;
|
|
43
|
+
readonly apiVersion?: string | undefined;
|
|
44
|
+
readonly toleranceMs?: number | undefined;
|
|
45
|
+
readonly now?: (() => number) | undefined;
|
|
46
|
+
}
|
|
47
|
+
export declare function revolutWebhook(options: RevolutWebhookOptions): WebhookHandler;
|
|
48
|
+
//#endregion
|