kassza 0.13.0 → 0.14.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.en.md +48 -0
- package/README.md +152 -22
- package/agents/README.md +6 -1
- package/agents/api.md +64 -12
- package/agents/pitfalls.md +12 -1
- package/agents/recipes.md +67 -8
- package/agents/skills/kassza/SKILL.md +3 -0
- package/agents/skills/migrate-from-szamlazz-js/SKILL.md +39 -0
- package/dist/batch/index.cjs +346 -0
- package/dist/batch/index.d.cts +91 -0
- package/dist/batch/index.d.ts +91 -0
- package/dist/batch/index.js +339 -0
- package/dist/cli.cjs +105 -14
- package/dist/cli.js +104 -13
- package/dist/{client-C-PdfL_P.cjs → client-CLFvJCVW.cjs} +358 -181
- package/dist/{client-CfaS1-Jx.js → client-Cvf-hTz_.js} +311 -152
- package/dist/{client-6MkeuFqD.d.ts → client-DeWWQ-RZ.d.ts} +99 -26
- package/dist/{client-B5FryKxJ.d.cts → client-SVZu25MB.d.cts} +99 -26
- package/dist/{context-DXNbTPwz.d.cts → context-CFNKzStE.d.cts} +82 -58
- package/dist/{context-BxQlIlug.d.ts → context-kb33TgzE.d.ts} +82 -58
- package/dist/cookie-stores/index.cjs +21 -150
- package/dist/cookie-stores/index.d.cts +4 -63
- package/dist/cookie-stores/index.d.ts +4 -63
- package/dist/cookie-stores/index.js +3 -144
- package/dist/create-CflXrPip.js +204 -0
- package/dist/create-CvUvLUaT.cjs +257 -0
- package/dist/{create-once-DgMtKKcG.cjs → create-once-9yxR_Er_.cjs} +285 -33
- package/dist/create-once-Bh6fOWkW.d.cts +20 -0
- package/dist/{create-once-Cz621l8r.js → create-once-Ca2gMk1h.js} +250 -34
- package/dist/create-once-VKp0tVow.d.ts +20 -0
- package/dist/data-link/index.cjs +4 -4
- package/dist/data-link/index.d.cts +2 -52
- package/dist/data-link/index.d.ts +2 -52
- package/dist/data-link/index.js +4 -4
- package/dist/delegation/index.cjs +4 -4
- package/dist/delegation/index.d.cts +2 -2
- package/dist/delegation/index.d.ts +2 -2
- package/dist/delegation/index.js +4 -4
- package/dist/{errors-DLrb0g64.js → errors-DtN4g5Z9.js} +9 -1
- package/dist/{errors-DxeuTslP.cjs → errors-EE96_6D_.cjs} +20 -0
- package/dist/{get-Csm2n0rZ.cjs → get-BdMTseh4.cjs} +9 -183
- package/dist/{get-DT3JEgQ6.js → get-CZEShCcj.js} +4 -124
- package/dist/index-BhUPY_EH.d.cts +109 -0
- package/dist/index-BqGgQ4t3.d.ts +109 -0
- package/dist/{index-CYAGCdKJ.d.cts → index-C-7yWV7L.d.cts} +24 -1
- package/dist/{index-CYAGCdKJ.d.ts → index-C-7yWV7L.d.ts} +24 -1
- package/dist/index.cjs +19 -5
- package/dist/index.d.cts +10 -20
- package/dist/index.d.ts +10 -20
- package/dist/index.js +6 -6
- package/dist/ipn/index.cjs +26 -5
- package/dist/ipn/index.d.cts +12 -1
- package/dist/ipn/index.d.ts +12 -1
- package/dist/ipn/index.js +26 -6
- package/dist/{issue-AGRohSm7.cjs → issue-Bin4tKD_.cjs} +416 -342
- package/dist/{issue-DtSLpVdJ.js → issue-DMA1Nbr1.js} +394 -266
- package/dist/journal/index.cjs +454 -0
- package/dist/journal/index.d.cts +18 -0
- package/dist/journal/index.d.ts +18 -0
- package/dist/journal/index.js +445 -0
- package/dist/journal-DvI81Kt7.d.cts +114 -0
- package/dist/journal-Y9qrIB8G.d.ts +114 -0
- package/dist/mcp/index.cjs +1 -1
- package/dist/mcp/index.d.cts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/money/index.cjs +2 -1
- package/dist/money/index.d.cts +2 -2
- package/dist/money/index.d.ts +2 -2
- package/dist/money/index.js +2 -2
- package/dist/{money-t7uy1n91.js → money-Cw457SD6.js} +95 -3
- package/dist/{money-BxytJW6f.cjs → money-K9j0wPit.cjs} +99 -1
- package/dist/nav/index.cjs +2 -2
- package/dist/nav/index.d.cts +1 -1
- package/dist/nav/index.d.ts +1 -1
- package/dist/nav/index.js +2 -2
- package/dist/{nav-BEwcX7-N.cjs → nav-BNbc8U0R.cjs} +1 -1
- package/dist/{nav-CK1WgYo7.js → nav-BcCerwWS.js} +1 -1
- package/dist/node/index.cjs +124 -0
- package/dist/node/index.d.cts +35 -0
- package/dist/node/index.d.ts +35 -0
- package/dist/node/index.js +120 -0
- package/dist/observe/index.cjs +311 -0
- package/dist/observe/index.d.cts +53 -0
- package/dist/observe/index.d.ts +53 -0
- package/dist/observe/index.js +303 -0
- package/dist/once-BN_3B5OF.cjs +103 -0
- package/dist/once-CqqZxsXG.js +74 -0
- package/dist/{parse-C608ehqM.js → parse-Cr7yQ3_z.js} +2 -2
- package/dist/{parse-BJj-aqKy.cjs → parse-DOA2XQ3e.cjs} +2 -2
- package/dist/payments/barion.cjs +26 -2
- package/dist/payments/barion.d.cts +2 -2
- package/dist/payments/barion.d.ts +2 -2
- package/dist/payments/barion.js +26 -2
- package/dist/payments/index.cjs +7 -2
- package/dist/payments/index.d.cts +4 -4
- package/dist/payments/index.d.ts +4 -4
- package/dist/payments/index.js +3 -3
- package/dist/payments/paypal.cjs +16 -2
- package/dist/payments/paypal.d.cts +2 -2
- package/dist/payments/paypal.d.ts +2 -2
- package/dist/payments/paypal.js +16 -2
- package/dist/payments/revolut.cjs +16 -2
- package/dist/payments/revolut.d.cts +2 -2
- package/dist/payments/revolut.d.ts +2 -2
- package/dist/payments/revolut.js +16 -2
- package/dist/payments/simplepay.cjs +36 -4
- package/dist/payments/simplepay.d.cts +2 -2
- package/dist/payments/simplepay.d.ts +2 -2
- package/dist/payments/simplepay.js +36 -4
- package/dist/payments/stripe.cjs +19 -2
- package/dist/payments/stripe.d.cts +2 -2
- package/dist/payments/stripe.d.ts +2 -2
- package/dist/payments/stripe.js +19 -2
- package/dist/push-BXj0Sf0Z.d.ts +52 -0
- package/dist/push-D4nNbCNV.d.cts +52 -0
- package/dist/reference-B5TATqb5.js +124 -0
- package/dist/reference-BIdYMK0t.cjs +183 -0
- package/dist/reports/index.cjs +1 -1
- package/dist/reports/index.d.cts +1 -1
- package/dist/reports/index.d.ts +1 -1
- package/dist/reports/index.js +1 -1
- package/dist/{serialize-DSE_o9RK.js → serialize-B2eFh3D-.js} +5 -1
- package/dist/{serialize-BXOww1Uq.cjs → serialize-CquIsxA-.cjs} +5 -1
- package/dist/{server-Cd8HB661.js → server-BrJUbXs7.js} +8 -7
- package/dist/{server-C6PoNkdD.cjs → server-Dw9j8Mnd.cjs} +17 -16
- package/dist/session-Ckl5eJhV.d.ts +7 -0
- package/dist/{session-CKOuE6Jc.cjs → session-DeM5vjvC.cjs} +69 -13
- package/dist/{session-rMKaJcmq.js → session-SaEEXu2N.js} +58 -14
- package/dist/session-YbChChx7.d.cts +7 -0
- package/dist/storage/fs.cjs +1 -1
- package/dist/storage/fs.js +1 -1
- package/dist/storage/index.cjs +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/store-C1rHd9DB.d.cts +19 -0
- package/dist/store-C1rHd9DB.d.ts +19 -0
- package/dist/stores/index.cjs +24 -0
- package/dist/stores/index.d.cts +4 -0
- package/dist/stores/index.d.ts +4 -0
- package/dist/stores/index.js +3 -0
- package/dist/stores-BNrS0dWl.cjs +506 -0
- package/dist/stores-DhjGBrl_.js +441 -0
- package/dist/testing/index.cjs +28 -16
- package/dist/testing/index.d.cts +6 -3
- package/dist/testing/index.d.ts +6 -3
- package/dist/testing/index.js +26 -14
- package/dist/{types-BVeR7KyU.d.ts → types-B1A8mUIE.d.cts} +13 -1
- package/dist/{types-BVeR7KyU.d.cts → types-ByAEvGsZ.d.ts} +13 -1
- package/dist/{types-k--zHf4l.d.ts → types-D1zDOH_F.d.ts} +1 -1
- package/dist/{types-DH8QoNZK.d.cts → types-lnKkQdot.d.cts} +1 -1
- package/dist/warnings-B3DXnveC.d.cts +31 -0
- package/dist/warnings-B3DXnveC.d.ts +31 -0
- package/dist/warnings-DeIw5RFj.cjs +20 -0
- package/dist/warnings-DwTl5J-2.js +15 -0
- package/dist/{webhook-CrEGohbg.js → webhook-CQVShAfI.js} +44 -1
- package/dist/{webhook-81giRMdQ.cjs → webhook-Ckj-_hPD.cjs} +67 -0
- package/dist/webhook-CmdhGiH5.d.cts +11 -0
- package/dist/webhook-D6lEejob.d.ts +11 -0
- package/llms.txt +4 -3
- package/package.json +92 -4
- package/dist/session-Dm_45x8K.d.cts +0 -11
- package/dist/session-Dm_45x8K.d.ts +0 -11
- package/dist/webhook-CpCMHhn2.d.ts +0 -6
- package/dist/webhook-CpMJuP6c.d.cts +0 -6
package/dist/payments/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as buyerFromCustomer,
|
|
2
|
-
import { a as PaymentEventKind, c as PaymentProvider, i as PaymentEvent, l as
|
|
3
|
-
import {
|
|
1
|
+
import { A as IssuedRefundCorrection, C as PaymentDocumentItem, D as issueForPayment, E as buyerFromCustomer, F as RefundProposalLine, I as correctionExternalId, M as PartialRefundMode, N as RefundItemsContext, O as paymentOrderNumber, P as RefundItemsResolver, S as IssuedReversal, T as SkippedPayment, b as IssuedInvoice, j as IssuedRefundProposal, k as IssuedCorrection, v as IssueForPaymentOptions, w as PaymentDocumentsApi, x as IssuedReceipt, y as IssuedDocument } from "../client-DeWWQ-RZ.js";
|
|
2
|
+
import { a as PaymentEventKind, c as PaymentProvider, i as PaymentEvent, l as PaymentRefund, n as PaymentAmount, o as PaymentHandler, r as PaymentCustomer, s as PaymentLineItem, t as PaymentAddress, u as PaymentWebhookBaseOptions } from "../types-ByAEvGsZ.js";
|
|
3
|
+
import { a as respondToWebhook, i as deliverPayment, n as WEBHOOK_DEDUPE_KEY_PREFIX, o as webhookDedupeKey, r as WebhookHandler, t as DEFAULT_DEDUPE_TTL_SECONDS } from "../webhook-D6lEejob.js";
|
|
4
4
|
//#region src/payments/amounts.d.ts
|
|
5
5
|
type MinorUnitConvention = "iso4217" | "stripe";
|
|
6
6
|
export declare function currencyExponent(currency: string, convention: MinorUnitConvention): number;
|
|
@@ -28,4 +28,4 @@ export declare class PaymentProviderError extends Error {
|
|
|
28
28
|
}
|
|
29
29
|
export declare function isWebhookVerificationError(error: unknown): error is WebhookVerificationError;
|
|
30
30
|
//#endregion
|
|
31
|
-
export { type IssueForPaymentOptions, type IssuedDocument, type IssuedInvoice, type IssuedReceipt, type IssuedReversal, type MinorUnitConvention, type PaymentAddress, type PaymentAmount, type PaymentCustomer, type PaymentDocumentItem, type PaymentDocumentsApi, type PaymentEvent, type PaymentEventKind, type PaymentHandler, type PaymentLineItem, type PaymentProvider, type PaymentWebhookBaseOptions, type SkippedPayment, type WebhookHandler, type WebhookVerificationReason, buyerFromCustomer, issueForPayment, paymentOrderNumber, respondToWebhook };
|
|
31
|
+
export { DEFAULT_DEDUPE_TTL_SECONDS, type IssueForPaymentOptions, type IssuedCorrection, type IssuedDocument, type IssuedInvoice, type IssuedReceipt, type IssuedRefundCorrection, type IssuedRefundProposal, type IssuedReversal, type MinorUnitConvention, type PartialRefundMode, type PaymentAddress, type PaymentAmount, type PaymentCustomer, type PaymentDocumentItem, type PaymentDocumentsApi, type PaymentEvent, type PaymentEventKind, type PaymentHandler, type PaymentLineItem, type PaymentProvider, type PaymentRefund, type PaymentWebhookBaseOptions, type RefundItemsContext, type RefundItemsResolver, type RefundProposalLine, type SkippedPayment, WEBHOOK_DEDUPE_KEY_PREFIX, type WebhookHandler, type WebhookVerificationReason, buyerFromCustomer, correctionExternalId, deliverPayment, issueForPayment, paymentOrderNumber, respondToWebhook, webhookDedupeKey };
|
package/dist/payments/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as issueForPayment, r as paymentOrderNumber, t as buyerFromCustomer } from "../issue-
|
|
2
|
-
import { a as
|
|
3
|
-
export { DEFAULT_MAX_WEBHOOK_BYTES, PaymentProviderError, WebhookVerificationError, buyerFromCustomer, currencyExponent, fromMinorUnits, isWebhookVerificationError, issueForPayment, normalizeCurrency, parseDecimalAmount, paymentOrderNumber, readRawBody, respondToWebhook };
|
|
1
|
+
import { i as correctionExternalId, n as issueForPayment, r as paymentOrderNumber, t as buyerFromCustomer } from "../issue-DMA1Nbr1.js";
|
|
2
|
+
import { a as webhookDedupeKey, d as WebhookVerificationError, f as isWebhookVerificationError, g as parseDecimalAmount, h as normalizeCurrency, i as respondToWebhook, l as readRawBody, m as fromMinorUnits, n as WEBHOOK_DEDUPE_KEY_PREFIX, o as DEFAULT_MAX_WEBHOOK_BYTES, p as currencyExponent, r as deliverPayment, t as DEFAULT_DEDUPE_TTL_SECONDS, u as PaymentProviderError } from "../webhook-CQVShAfI.js";
|
|
3
|
+
export { DEFAULT_DEDUPE_TTL_SECONDS, DEFAULT_MAX_WEBHOOK_BYTES, PaymentProviderError, WEBHOOK_DEDUPE_KEY_PREFIX, WebhookVerificationError, buyerFromCustomer, correctionExternalId, currencyExponent, deliverPayment, fromMinorUnits, isWebhookVerificationError, issueForPayment, normalizeCurrency, parseDecimalAmount, paymentOrderNumber, readRawBody, respondToWebhook, webhookDedupeKey };
|
package/dist/payments/paypal.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_binary = require("../binary-B89HM03_.cjs");
|
|
3
3
|
const require_rounding = require("../rounding-TxoWy2ww.cjs");
|
|
4
|
-
const require_webhook = require("../webhook-
|
|
4
|
+
const require_webhook = require("../webhook-Ckj-_hPD.cjs");
|
|
5
5
|
const require_json = require("../json-4y4E2xxS.cjs");
|
|
6
6
|
//#region src/payments/paypal.ts
|
|
7
7
|
const PAYPAL_LIVE_API_URL = "https://api-m.paypal.com";
|
|
@@ -271,6 +271,19 @@ function refundKind(refund, capture) {
|
|
|
271
271
|
if (refunded === void 0 || captured === void 0) return "partially-refunded";
|
|
272
272
|
return Math.abs(refunded - captured) <= AMOUNT_TOLERANCE ? "refunded" : "partially-refunded";
|
|
273
273
|
}
|
|
274
|
+
function payPalRefunds(refund) {
|
|
275
|
+
const id = require_json.text(refund.id);
|
|
276
|
+
const amount = moneyOf(refund.amount);
|
|
277
|
+
if (!id || !amount || amount.value <= 0 || require_json.text(refund.status) !== "COMPLETED") return void 0;
|
|
278
|
+
const total = moneyOf(require_json.path(refund, "seller_payable_breakdown", "total_refunded_amount"));
|
|
279
|
+
const before = total && total.currency === amount.currency ? require_rounding.roundMoney(total.value - amount.value, 2) : void 0;
|
|
280
|
+
return [{
|
|
281
|
+
id,
|
|
282
|
+
amount,
|
|
283
|
+
refundedBefore: before !== void 0 && before >= 0 ? before : void 0,
|
|
284
|
+
createdAt: require_json.text(refund.create_time)
|
|
285
|
+
}];
|
|
286
|
+
}
|
|
274
287
|
function fromRefund(event, options) {
|
|
275
288
|
const refund = event.resource;
|
|
276
289
|
const captureId = payPalCaptureIdOfRefund(refund);
|
|
@@ -285,6 +298,7 @@ function fromRefund(event, options) {
|
|
|
285
298
|
orderRef: orderRefOf(refund, void 0) ?? (capture ? orderRefOf(capture, void 0) : void 0),
|
|
286
299
|
amount: moneyOf(capture?.amount),
|
|
287
300
|
refundedAmount: moneyOf(require_json.path(refund, "seller_payable_breakdown", "total_refunded_amount")) ?? moneyOf(refund.amount),
|
|
301
|
+
refunds: payPalRefunds(refund),
|
|
288
302
|
paidAt: require_json.text(refund.create_time) ?? event.createTime,
|
|
289
303
|
method: options.method ?? "PayPal",
|
|
290
304
|
raw: event.raw
|
|
@@ -330,7 +344,7 @@ function payPalWebhook(options) {
|
|
|
330
344
|
method: options.method,
|
|
331
345
|
...extras
|
|
332
346
|
});
|
|
333
|
-
if (payment) await
|
|
347
|
+
if (payment) await require_webhook.deliverPayment(options, payment);
|
|
334
348
|
return require_webhook.plainResponse(200, "OK");
|
|
335
349
|
});
|
|
336
350
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as PaymentEvent,
|
|
1
|
+
import { i as PaymentEvent, u as PaymentWebhookBaseOptions } from "../types-B1A8mUIE.cjs";
|
|
2
2
|
import { t as JsonRecord } from "../json-B70TwoX1.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { r as WebhookHandler } from "../webhook-CmdhGiH5.cjs";
|
|
4
4
|
//#region src/payments/paypal.d.ts
|
|
5
5
|
export declare const PAYPAL_LIVE_API_URL = "https://api-m.paypal.com";
|
|
6
6
|
export declare const PAYPAL_SANDBOX_API_URL = "https://api-m.sandbox.paypal.com";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as PaymentEvent,
|
|
1
|
+
import { i as PaymentEvent, u as PaymentWebhookBaseOptions } from "../types-ByAEvGsZ.js";
|
|
2
2
|
import { t as JsonRecord } from "../json-B70TwoX1.js";
|
|
3
|
-
import {
|
|
3
|
+
import { r as WebhookHandler } from "../webhook-D6lEejob.js";
|
|
4
4
|
//#region src/payments/paypal.d.ts
|
|
5
5
|
export declare const PAYPAL_LIVE_API_URL = "https://api-m.paypal.com";
|
|
6
6
|
export declare const PAYPAL_SANDBOX_API_URL = "https://api-m.sandbox.paypal.com";
|
package/dist/payments/paypal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as encodeUtf8, n as bytesToBase64 } from "../binary-D0M9U2MD.js";
|
|
2
2
|
import { r as roundMoney } from "../rounding-BLyHjjI5.js";
|
|
3
|
-
import {
|
|
3
|
+
import { c as plainResponse, d as WebhookVerificationError, g as parseDecimalAmount, h as normalizeCurrency, i as respondToWebhook, l as readRawBody, r as deliverPayment, s as parseJsonObject, u as PaymentProviderError } from "../webhook-CQVShAfI.js";
|
|
4
4
|
import { a as text, i as records, n as path, r as record, t as numeric } from "../json-DjnqnaJK.js";
|
|
5
5
|
//#region src/payments/paypal.ts
|
|
6
6
|
const PAYPAL_LIVE_API_URL = "https://api-m.paypal.com";
|
|
@@ -270,6 +270,19 @@ function refundKind(refund, capture) {
|
|
|
270
270
|
if (refunded === void 0 || captured === void 0) return "partially-refunded";
|
|
271
271
|
return Math.abs(refunded - captured) <= AMOUNT_TOLERANCE ? "refunded" : "partially-refunded";
|
|
272
272
|
}
|
|
273
|
+
function payPalRefunds(refund) {
|
|
274
|
+
const id = text(refund.id);
|
|
275
|
+
const amount = moneyOf(refund.amount);
|
|
276
|
+
if (!id || !amount || amount.value <= 0 || text(refund.status) !== "COMPLETED") return void 0;
|
|
277
|
+
const total = moneyOf(path(refund, "seller_payable_breakdown", "total_refunded_amount"));
|
|
278
|
+
const before = total && total.currency === amount.currency ? roundMoney(total.value - amount.value, 2) : void 0;
|
|
279
|
+
return [{
|
|
280
|
+
id,
|
|
281
|
+
amount,
|
|
282
|
+
refundedBefore: before !== void 0 && before >= 0 ? before : void 0,
|
|
283
|
+
createdAt: text(refund.create_time)
|
|
284
|
+
}];
|
|
285
|
+
}
|
|
273
286
|
function fromRefund(event, options) {
|
|
274
287
|
const refund = event.resource;
|
|
275
288
|
const captureId = payPalCaptureIdOfRefund(refund);
|
|
@@ -284,6 +297,7 @@ function fromRefund(event, options) {
|
|
|
284
297
|
orderRef: orderRefOf(refund, void 0) ?? (capture ? orderRefOf(capture, void 0) : void 0),
|
|
285
298
|
amount: moneyOf(capture?.amount),
|
|
286
299
|
refundedAmount: moneyOf(path(refund, "seller_payable_breakdown", "total_refunded_amount")) ?? moneyOf(refund.amount),
|
|
300
|
+
refunds: payPalRefunds(refund),
|
|
287
301
|
paidAt: text(refund.create_time) ?? event.createTime,
|
|
288
302
|
method: options.method ?? "PayPal",
|
|
289
303
|
raw: event.raw
|
|
@@ -329,7 +343,7 @@ function payPalWebhook(options) {
|
|
|
329
343
|
method: options.method,
|
|
330
344
|
...extras
|
|
331
345
|
});
|
|
332
|
-
if (payment) await options
|
|
346
|
+
if (payment) await deliverPayment(options, payment);
|
|
333
347
|
return plainResponse(200, "OK");
|
|
334
348
|
});
|
|
335
349
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_crypto = require("../crypto-Dpn4FHQ6.cjs");
|
|
3
|
-
const require_webhook = require("../webhook-
|
|
3
|
+
const require_webhook = require("../webhook-Ckj-_hPD.cjs");
|
|
4
4
|
const require_json = require("../json-4y4E2xxS.cjs");
|
|
5
5
|
//#region src/payments/revolut.ts
|
|
6
6
|
const REVOLUT_LIVE_API_URL = "https://merchant.revolut.com";
|
|
@@ -173,6 +173,19 @@ function refundKind(refund, original) {
|
|
|
173
173
|
const refundedTotal = require_json.numeric(original.refunded_amount);
|
|
174
174
|
return refundAmount !== void 0 && refundAmount === originalAmount && refundedTotal === refundAmount ? "refunded" : "partially-refunded";
|
|
175
175
|
}
|
|
176
|
+
function revolutRefunds(refund, original) {
|
|
177
|
+
const id = require_json.text(refund.id);
|
|
178
|
+
const amount = amountOf(refund, "amount");
|
|
179
|
+
if (!id || !amount || amount.value <= 0) return void 0;
|
|
180
|
+
const total = amountOf(original, "refunded_amount");
|
|
181
|
+
const before = total && total.currency === amount.currency ? Math.round((total.value - amount.value) * 100) / 100 : void 0;
|
|
182
|
+
return [{
|
|
183
|
+
id,
|
|
184
|
+
amount,
|
|
185
|
+
refundedBefore: before !== void 0 && before >= 0 ? before : void 0,
|
|
186
|
+
createdAt: require_json.text(refund.updated_at) ?? require_json.text(refund.created_at)
|
|
187
|
+
}];
|
|
188
|
+
}
|
|
176
189
|
function fromRefundOrder(event, refund, options) {
|
|
177
190
|
const original = options.originalOrder;
|
|
178
191
|
const originalId = require_json.text(refund.related_order_id);
|
|
@@ -183,6 +196,7 @@ function fromRefundOrder(event, refund, options) {
|
|
|
183
196
|
orderRef: orderRefOf(original, event),
|
|
184
197
|
amount: amountOf(original, "amount"),
|
|
185
198
|
refundedAmount: amountOf(original, "refunded_amount") ?? amountOf(refund, "amount"),
|
|
199
|
+
refunds: revolutRefunds(refund, original),
|
|
186
200
|
paidAt: require_json.text(refund.updated_at),
|
|
187
201
|
customer: customerOf(original)
|
|
188
202
|
};
|
|
@@ -242,7 +256,7 @@ function revolutWebhook(options) {
|
|
|
242
256
|
method: options.method,
|
|
243
257
|
...orders
|
|
244
258
|
});
|
|
245
|
-
if (payment) await
|
|
259
|
+
if (payment) await require_webhook.deliverPayment(options, payment);
|
|
246
260
|
return new Response(null, { status: 204 });
|
|
247
261
|
});
|
|
248
262
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as PaymentEvent,
|
|
1
|
+
import { i as PaymentEvent, u as PaymentWebhookBaseOptions } from "../types-B1A8mUIE.cjs";
|
|
2
2
|
import { t as JsonRecord } from "../json-B70TwoX1.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { r as WebhookHandler } from "../webhook-CmdhGiH5.cjs";
|
|
4
4
|
//#region src/payments/revolut.d.ts
|
|
5
5
|
export declare const REVOLUT_LIVE_API_URL = "https://merchant.revolut.com";
|
|
6
6
|
export declare const REVOLUT_SANDBOX_API_URL = "https://sandbox-merchant.revolut.com";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as PaymentEvent,
|
|
1
|
+
import { i as PaymentEvent, u as PaymentWebhookBaseOptions } from "../types-ByAEvGsZ.js";
|
|
2
2
|
import { t as JsonRecord } from "../json-B70TwoX1.js";
|
|
3
|
-
import {
|
|
3
|
+
import { r as WebhookHandler } from "../webhook-D6lEejob.js";
|
|
4
4
|
//#region src/payments/revolut.d.ts
|
|
5
5
|
export declare const REVOLUT_LIVE_API_URL = "https://merchant.revolut.com";
|
|
6
6
|
export declare const REVOLUT_SANDBOX_API_URL = "https://sandbox-merchant.revolut.com";
|
package/dist/payments/revolut.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as timingSafeEqual, i as hmacHex } from "../crypto-usDg8L2K.js";
|
|
2
|
-
import {
|
|
2
|
+
import { d as WebhookVerificationError, h as normalizeCurrency, i as respondToWebhook, l as readRawBody, m as fromMinorUnits, r as deliverPayment, s as parseJsonObject, u as PaymentProviderError } from "../webhook-CQVShAfI.js";
|
|
3
3
|
import { a as text, i as records, n as path, r as record, t as numeric } from "../json-DjnqnaJK.js";
|
|
4
4
|
//#region src/payments/revolut.ts
|
|
5
5
|
const REVOLUT_LIVE_API_URL = "https://merchant.revolut.com";
|
|
@@ -172,6 +172,19 @@ function refundKind(refund, original) {
|
|
|
172
172
|
const refundedTotal = numeric(original.refunded_amount);
|
|
173
173
|
return refundAmount !== void 0 && refundAmount === originalAmount && refundedTotal === refundAmount ? "refunded" : "partially-refunded";
|
|
174
174
|
}
|
|
175
|
+
function revolutRefunds(refund, original) {
|
|
176
|
+
const id = text(refund.id);
|
|
177
|
+
const amount = amountOf(refund, "amount");
|
|
178
|
+
if (!id || !amount || amount.value <= 0) return void 0;
|
|
179
|
+
const total = amountOf(original, "refunded_amount");
|
|
180
|
+
const before = total && total.currency === amount.currency ? Math.round((total.value - amount.value) * 100) / 100 : void 0;
|
|
181
|
+
return [{
|
|
182
|
+
id,
|
|
183
|
+
amount,
|
|
184
|
+
refundedBefore: before !== void 0 && before >= 0 ? before : void 0,
|
|
185
|
+
createdAt: text(refund.updated_at) ?? text(refund.created_at)
|
|
186
|
+
}];
|
|
187
|
+
}
|
|
175
188
|
function fromRefundOrder(event, refund, options) {
|
|
176
189
|
const original = options.originalOrder;
|
|
177
190
|
const originalId = text(refund.related_order_id);
|
|
@@ -182,6 +195,7 @@ function fromRefundOrder(event, refund, options) {
|
|
|
182
195
|
orderRef: orderRefOf(original, event),
|
|
183
196
|
amount: amountOf(original, "amount"),
|
|
184
197
|
refundedAmount: amountOf(original, "refunded_amount") ?? amountOf(refund, "amount"),
|
|
198
|
+
refunds: revolutRefunds(refund, original),
|
|
185
199
|
paidAt: text(refund.updated_at),
|
|
186
200
|
customer: customerOf(original)
|
|
187
201
|
};
|
|
@@ -241,7 +255,7 @@ function revolutWebhook(options) {
|
|
|
241
255
|
method: options.method,
|
|
242
256
|
...orders
|
|
243
257
|
});
|
|
244
|
-
if (payment) await options
|
|
258
|
+
if (payment) await deliverPayment(options, payment);
|
|
245
259
|
return new Response(null, { status: 204 });
|
|
246
260
|
});
|
|
247
261
|
}
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_binary = require("../binary-B89HM03_.cjs");
|
|
3
3
|
const require_dates = require("../dates-CPgBodkP.cjs");
|
|
4
4
|
const require_crypto = require("../crypto-Dpn4FHQ6.cjs");
|
|
5
|
-
const require_webhook = require("../webhook-
|
|
5
|
+
const require_webhook = require("../webhook-Ckj-_hPD.cjs");
|
|
6
6
|
const require_json = require("../json-4y4E2xxS.cjs");
|
|
7
7
|
//#region src/payments/simplepay.ts
|
|
8
8
|
const SIMPLEPAY_LIVE_API_URL = "https://secure.simplepay.hu/payment/v2";
|
|
@@ -166,9 +166,12 @@ function methodOf(ipnMethod, configured) {
|
|
|
166
166
|
if (configured) return configured;
|
|
167
167
|
return ipnMethod?.toUpperCase() === "WIRE" ? SIMPLEPAY_WIRE_METHOD : SIMPLEPAY_CARD_METHOD;
|
|
168
168
|
}
|
|
169
|
+
function finishedRefunds(transaction) {
|
|
170
|
+
return transaction.refunds.filter((refund) => refund.status === void 0 || refund.status === "FINISHED");
|
|
171
|
+
}
|
|
169
172
|
function refundKind(transaction) {
|
|
170
173
|
if (!transaction || transaction.total === void 0) return "partially-refunded";
|
|
171
|
-
const finished = transaction
|
|
174
|
+
const finished = finishedRefunds(transaction);
|
|
172
175
|
const refunded = finished.reduce((sum, refund) => sum + refund.total, 0);
|
|
173
176
|
const single = finished.length === 1;
|
|
174
177
|
const complete = Math.abs(refunded - transaction.total) <= AMOUNT_TOLERANCE;
|
|
@@ -194,17 +197,46 @@ function refundedAmountOf(transaction) {
|
|
|
194
197
|
currency: transaction.currency
|
|
195
198
|
};
|
|
196
199
|
}
|
|
200
|
+
function refundsOf(transaction) {
|
|
201
|
+
if (!transaction?.currency) return void 0;
|
|
202
|
+
const currency = transaction.currency;
|
|
203
|
+
const finished = finishedRefunds(transaction);
|
|
204
|
+
if (finished.length === 0 || finished.some((refund) => !refund.transactionId)) return void 0;
|
|
205
|
+
const ordered = [...finished].sort((a, b) => (a.date ?? "").localeCompare(b.date ?? "") || (a.transactionId ?? "").localeCompare(b.transactionId ?? ""));
|
|
206
|
+
let before = 0;
|
|
207
|
+
return ordered.map((refund) => {
|
|
208
|
+
const entry = {
|
|
209
|
+
id: refund.transactionId ?? "",
|
|
210
|
+
amount: {
|
|
211
|
+
value: refund.total,
|
|
212
|
+
currency
|
|
213
|
+
},
|
|
214
|
+
refundedBefore: before,
|
|
215
|
+
createdAt: refund.date
|
|
216
|
+
};
|
|
217
|
+
before = Math.round((before + refund.total) * 100) / 100;
|
|
218
|
+
return entry;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function eventIdOf(ipn, transaction) {
|
|
222
|
+
if (ipn.status !== "REFUND") return `${ipn.transactionId}:${ipn.status}`;
|
|
223
|
+
if (!transaction) return void 0;
|
|
224
|
+
const finished = finishedRefunds(transaction);
|
|
225
|
+
const refunded = finished.reduce((sum, refund) => sum + refund.total, 0);
|
|
226
|
+
return `${ipn.transactionId}:${ipn.status}:${finished.length}:${Math.round(refunded * 100)}`;
|
|
227
|
+
}
|
|
197
228
|
function simplePayPaymentEvent(ipn, options = {}) {
|
|
198
229
|
const transaction = options.transaction;
|
|
199
230
|
return {
|
|
200
231
|
provider: "simplepay",
|
|
201
232
|
kind: kindOf(ipn.status, transaction),
|
|
202
233
|
id: ipn.transactionId,
|
|
203
|
-
eventId:
|
|
234
|
+
eventId: eventIdOf(ipn, transaction),
|
|
204
235
|
eventType: ipn.status,
|
|
205
236
|
orderRef: ipn.orderRef,
|
|
206
237
|
amount: amountOf(transaction),
|
|
207
238
|
refundedAmount: ipn.status === "REFUND" ? refundedAmountOf(transaction) : void 0,
|
|
239
|
+
refunds: ipn.status === "REFUND" ? refundsOf(transaction) : void 0,
|
|
208
240
|
paidAt: ipn.finishDate ?? ipn.paymentDate,
|
|
209
241
|
method: methodOf(ipn.method, options.method),
|
|
210
242
|
customer: transaction?.customer,
|
|
@@ -245,7 +277,7 @@ function simplePayWebhook(options) {
|
|
|
245
277
|
if (!merchant) throw new require_webhook.WebhookVerificationError("simplepay", "verification_failed", `Ismeretlen SimplePay kereskedő: ${ipn.merchant}.`);
|
|
246
278
|
await verifySimplePaySignature(body, request.headers.get("signature"), merchant.secretKey);
|
|
247
279
|
const transaction = options.fetchDetails !== false && needsDetails(ipn.status) ? await requireTransaction(ipn, merchant, options) : void 0;
|
|
248
|
-
await
|
|
280
|
+
await require_webhook.deliverPayment(options, simplePayPaymentEvent(ipn, {
|
|
249
281
|
method: merchant.method ?? options.method,
|
|
250
282
|
transaction
|
|
251
283
|
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as PaymentEvent,
|
|
1
|
+
import { i as PaymentEvent, r as PaymentCustomer, u as PaymentWebhookBaseOptions } from "../types-B1A8mUIE.cjs";
|
|
2
2
|
import { t as JsonRecord } from "../json-B70TwoX1.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { r as WebhookHandler } from "../webhook-CmdhGiH5.cjs";
|
|
4
4
|
//#region src/payments/simplepay.d.ts
|
|
5
5
|
export declare const SIMPLEPAY_LIVE_API_URL = "https://secure.simplepay.hu/payment/v2";
|
|
6
6
|
export declare const SIMPLEPAY_SANDBOX_API_URL = "https://sandbox.simplepay.hu/payment/v2";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as PaymentEvent,
|
|
1
|
+
import { i as PaymentEvent, r as PaymentCustomer, u as PaymentWebhookBaseOptions } from "../types-ByAEvGsZ.js";
|
|
2
2
|
import { t as JsonRecord } from "../json-B70TwoX1.js";
|
|
3
|
-
import {
|
|
3
|
+
import { r as WebhookHandler } from "../webhook-D6lEejob.js";
|
|
4
4
|
//#region src/payments/simplepay.d.ts
|
|
5
5
|
export declare const SIMPLEPAY_LIVE_API_URL = "https://secure.simplepay.hu/payment/v2";
|
|
6
6
|
export declare const SIMPLEPAY_SANDBOX_API_URL = "https://sandbox.simplepay.hu/payment/v2";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as bytesToBase64, r as decodeUtf8, t as base64ToBytes } from "../binary-D0M9U2MD.js";
|
|
2
2
|
import { i as toBudapestTimestamp } from "../dates-CXyj7Azy.js";
|
|
3
3
|
import { a as timingSafeEqual, r as hmac, t as bytesToHex } from "../crypto-usDg8L2K.js";
|
|
4
|
-
import {
|
|
4
|
+
import { d as WebhookVerificationError, h as normalizeCurrency, i as respondToWebhook, l as readRawBody, r as deliverPayment, s as parseJsonObject, u as PaymentProviderError } from "../webhook-CQVShAfI.js";
|
|
5
5
|
import { a as text, i as records, r as record, t as numeric } from "../json-DjnqnaJK.js";
|
|
6
6
|
//#region src/payments/simplepay.ts
|
|
7
7
|
const SIMPLEPAY_LIVE_API_URL = "https://secure.simplepay.hu/payment/v2";
|
|
@@ -165,9 +165,12 @@ function methodOf(ipnMethod, configured) {
|
|
|
165
165
|
if (configured) return configured;
|
|
166
166
|
return ipnMethod?.toUpperCase() === "WIRE" ? SIMPLEPAY_WIRE_METHOD : SIMPLEPAY_CARD_METHOD;
|
|
167
167
|
}
|
|
168
|
+
function finishedRefunds(transaction) {
|
|
169
|
+
return transaction.refunds.filter((refund) => refund.status === void 0 || refund.status === "FINISHED");
|
|
170
|
+
}
|
|
168
171
|
function refundKind(transaction) {
|
|
169
172
|
if (!transaction || transaction.total === void 0) return "partially-refunded";
|
|
170
|
-
const finished = transaction
|
|
173
|
+
const finished = finishedRefunds(transaction);
|
|
171
174
|
const refunded = finished.reduce((sum, refund) => sum + refund.total, 0);
|
|
172
175
|
const single = finished.length === 1;
|
|
173
176
|
const complete = Math.abs(refunded - transaction.total) <= AMOUNT_TOLERANCE;
|
|
@@ -193,17 +196,46 @@ function refundedAmountOf(transaction) {
|
|
|
193
196
|
currency: transaction.currency
|
|
194
197
|
};
|
|
195
198
|
}
|
|
199
|
+
function refundsOf(transaction) {
|
|
200
|
+
if (!transaction?.currency) return void 0;
|
|
201
|
+
const currency = transaction.currency;
|
|
202
|
+
const finished = finishedRefunds(transaction);
|
|
203
|
+
if (finished.length === 0 || finished.some((refund) => !refund.transactionId)) return void 0;
|
|
204
|
+
const ordered = [...finished].sort((a, b) => (a.date ?? "").localeCompare(b.date ?? "") || (a.transactionId ?? "").localeCompare(b.transactionId ?? ""));
|
|
205
|
+
let before = 0;
|
|
206
|
+
return ordered.map((refund) => {
|
|
207
|
+
const entry = {
|
|
208
|
+
id: refund.transactionId ?? "",
|
|
209
|
+
amount: {
|
|
210
|
+
value: refund.total,
|
|
211
|
+
currency
|
|
212
|
+
},
|
|
213
|
+
refundedBefore: before,
|
|
214
|
+
createdAt: refund.date
|
|
215
|
+
};
|
|
216
|
+
before = Math.round((before + refund.total) * 100) / 100;
|
|
217
|
+
return entry;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function eventIdOf(ipn, transaction) {
|
|
221
|
+
if (ipn.status !== "REFUND") return `${ipn.transactionId}:${ipn.status}`;
|
|
222
|
+
if (!transaction) return void 0;
|
|
223
|
+
const finished = finishedRefunds(transaction);
|
|
224
|
+
const refunded = finished.reduce((sum, refund) => sum + refund.total, 0);
|
|
225
|
+
return `${ipn.transactionId}:${ipn.status}:${finished.length}:${Math.round(refunded * 100)}`;
|
|
226
|
+
}
|
|
196
227
|
function simplePayPaymentEvent(ipn, options = {}) {
|
|
197
228
|
const transaction = options.transaction;
|
|
198
229
|
return {
|
|
199
230
|
provider: "simplepay",
|
|
200
231
|
kind: kindOf(ipn.status, transaction),
|
|
201
232
|
id: ipn.transactionId,
|
|
202
|
-
eventId:
|
|
233
|
+
eventId: eventIdOf(ipn, transaction),
|
|
203
234
|
eventType: ipn.status,
|
|
204
235
|
orderRef: ipn.orderRef,
|
|
205
236
|
amount: amountOf(transaction),
|
|
206
237
|
refundedAmount: ipn.status === "REFUND" ? refundedAmountOf(transaction) : void 0,
|
|
238
|
+
refunds: ipn.status === "REFUND" ? refundsOf(transaction) : void 0,
|
|
207
239
|
paidAt: ipn.finishDate ?? ipn.paymentDate,
|
|
208
240
|
method: methodOf(ipn.method, options.method),
|
|
209
241
|
customer: transaction?.customer,
|
|
@@ -244,7 +276,7 @@ function simplePayWebhook(options) {
|
|
|
244
276
|
if (!merchant) throw new WebhookVerificationError("simplepay", "verification_failed", `Ismeretlen SimplePay kereskedő: ${ipn.merchant}.`);
|
|
245
277
|
await verifySimplePaySignature(body, request.headers.get("signature"), merchant.secretKey);
|
|
246
278
|
const transaction = options.fetchDetails !== false && needsDetails(ipn.status) ? await requireTransaction(ipn, merchant, options) : void 0;
|
|
247
|
-
await options
|
|
279
|
+
await deliverPayment(options, simplePayPaymentEvent(ipn, {
|
|
248
280
|
method: merchant.method ?? options.method,
|
|
249
281
|
transaction
|
|
250
282
|
}));
|
package/dist/payments/stripe.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_crypto = require("../crypto-Dpn4FHQ6.cjs");
|
|
3
|
-
const require_webhook = require("../webhook-
|
|
3
|
+
const require_webhook = require("../webhook-Ckj-_hPD.cjs");
|
|
4
4
|
const require_json = require("../json-4y4E2xxS.cjs");
|
|
5
5
|
//#region src/payments/stripe.ts
|
|
6
6
|
const STRIPE_DEFAULT_TOLERANCE_SECONDS = 300;
|
|
@@ -145,6 +145,22 @@ function refundKind(event) {
|
|
|
145
145
|
const previouslyRefunded = require_json.numeric(event.previousAttributes?.amount_refunded) ?? 0;
|
|
146
146
|
return (charge.refunded === true || amount > 0 && refunded >= amount) && previouslyRefunded === 0 ? "refunded" : "partially-refunded";
|
|
147
147
|
}
|
|
148
|
+
function refundsOf(event) {
|
|
149
|
+
const charge = event.object;
|
|
150
|
+
const currency = require_json.text(charge.currency);
|
|
151
|
+
const refunded = require_json.numeric(charge.amount_refunded);
|
|
152
|
+
const previous = require_json.numeric(event.previousAttributes?.amount_refunded);
|
|
153
|
+
if (!currency || refunded === void 0 || previous === void 0 || refunded <= previous) return;
|
|
154
|
+
return [{
|
|
155
|
+
id: event.id,
|
|
156
|
+
amount: {
|
|
157
|
+
value: require_webhook.fromMinorUnits(refunded - previous, currency, "stripe"),
|
|
158
|
+
currency: require_webhook.normalizeCurrency(currency)
|
|
159
|
+
},
|
|
160
|
+
refundedBefore: require_webhook.fromMinorUnits(previous, currency, "stripe"),
|
|
161
|
+
createdAt: paidAtOf(event)
|
|
162
|
+
}];
|
|
163
|
+
}
|
|
148
164
|
function fromRefundedCharge(event, options) {
|
|
149
165
|
const charge = event.object;
|
|
150
166
|
return {
|
|
@@ -156,6 +172,7 @@ function fromRefundedCharge(event, options) {
|
|
|
156
172
|
orderRef: orderRefOf(charge),
|
|
157
173
|
amount: amountOf(charge, "amount"),
|
|
158
174
|
refundedAmount: amountOf(charge, "amount_refunded"),
|
|
175
|
+
refunds: refundsOf(event),
|
|
159
176
|
paidAt: paidAtOf(event),
|
|
160
177
|
method: options.method ?? "bankkártya",
|
|
161
178
|
customer: customerOf(require_json.record(charge.billing_details)),
|
|
@@ -296,7 +313,7 @@ function stripeWebhook(options) {
|
|
|
296
313
|
});
|
|
297
314
|
const event = parseStripeEvent(payload);
|
|
298
315
|
const payment = stripePaymentEvent(event, { method: options.method });
|
|
299
|
-
if (payment) await
|
|
316
|
+
if (payment) await require_webhook.deliverPayment(options, payment, (value) => enrich(value, event, options));
|
|
300
317
|
return require_webhook.plainResponse(200, "OK");
|
|
301
318
|
});
|
|
302
319
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as PaymentEvent,
|
|
1
|
+
import { i as PaymentEvent, s as PaymentLineItem, u as PaymentWebhookBaseOptions } from "../types-B1A8mUIE.cjs";
|
|
2
2
|
import { t as JsonRecord } from "../json-B70TwoX1.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { r as WebhookHandler } from "../webhook-CmdhGiH5.cjs";
|
|
4
4
|
//#region src/payments/stripe.d.ts
|
|
5
5
|
export declare const STRIPE_DEFAULT_TOLERANCE_SECONDS = 300;
|
|
6
6
|
export declare const STRIPE_API_URL = "https://api.stripe.com";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as PaymentEvent,
|
|
1
|
+
import { i as PaymentEvent, s as PaymentLineItem, u as PaymentWebhookBaseOptions } from "../types-ByAEvGsZ.js";
|
|
2
2
|
import { t as JsonRecord } from "../json-B70TwoX1.js";
|
|
3
|
-
import {
|
|
3
|
+
import { r as WebhookHandler } from "../webhook-D6lEejob.js";
|
|
4
4
|
//#region src/payments/stripe.d.ts
|
|
5
5
|
export declare const STRIPE_DEFAULT_TOLERANCE_SECONDS = 300;
|
|
6
6
|
export declare const STRIPE_API_URL = "https://api.stripe.com";
|
package/dist/payments/stripe.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as timingSafeEqual, i as hmacHex } from "../crypto-usDg8L2K.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as plainResponse, d as WebhookVerificationError, h as normalizeCurrency, i as respondToWebhook, l as readRawBody, m as fromMinorUnits, r as deliverPayment, s as parseJsonObject, u as PaymentProviderError } from "../webhook-CQVShAfI.js";
|
|
3
3
|
import { a as text, i as records, n as path, r as record, t as numeric } from "../json-DjnqnaJK.js";
|
|
4
4
|
//#region src/payments/stripe.ts
|
|
5
5
|
const STRIPE_DEFAULT_TOLERANCE_SECONDS = 300;
|
|
@@ -144,6 +144,22 @@ function refundKind(event) {
|
|
|
144
144
|
const previouslyRefunded = numeric(event.previousAttributes?.amount_refunded) ?? 0;
|
|
145
145
|
return (charge.refunded === true || amount > 0 && refunded >= amount) && previouslyRefunded === 0 ? "refunded" : "partially-refunded";
|
|
146
146
|
}
|
|
147
|
+
function refundsOf(event) {
|
|
148
|
+
const charge = event.object;
|
|
149
|
+
const currency = text(charge.currency);
|
|
150
|
+
const refunded = numeric(charge.amount_refunded);
|
|
151
|
+
const previous = numeric(event.previousAttributes?.amount_refunded);
|
|
152
|
+
if (!currency || refunded === void 0 || previous === void 0 || refunded <= previous) return;
|
|
153
|
+
return [{
|
|
154
|
+
id: event.id,
|
|
155
|
+
amount: {
|
|
156
|
+
value: fromMinorUnits(refunded - previous, currency, "stripe"),
|
|
157
|
+
currency: normalizeCurrency(currency)
|
|
158
|
+
},
|
|
159
|
+
refundedBefore: fromMinorUnits(previous, currency, "stripe"),
|
|
160
|
+
createdAt: paidAtOf(event)
|
|
161
|
+
}];
|
|
162
|
+
}
|
|
147
163
|
function fromRefundedCharge(event, options) {
|
|
148
164
|
const charge = event.object;
|
|
149
165
|
return {
|
|
@@ -155,6 +171,7 @@ function fromRefundedCharge(event, options) {
|
|
|
155
171
|
orderRef: orderRefOf(charge),
|
|
156
172
|
amount: amountOf(charge, "amount"),
|
|
157
173
|
refundedAmount: amountOf(charge, "amount_refunded"),
|
|
174
|
+
refunds: refundsOf(event),
|
|
158
175
|
paidAt: paidAtOf(event),
|
|
159
176
|
method: options.method ?? "bankkártya",
|
|
160
177
|
customer: customerOf(record(charge.billing_details)),
|
|
@@ -295,7 +312,7 @@ function stripeWebhook(options) {
|
|
|
295
312
|
});
|
|
296
313
|
const event = parseStripeEvent(payload);
|
|
297
314
|
const payment = stripePaymentEvent(event, { method: options.method });
|
|
298
|
-
if (payment) await options
|
|
315
|
+
if (payment) await deliverPayment(options, payment, (value) => enrich(value, event, options));
|
|
299
316
|
return plainResponse(200, "OK");
|
|
300
317
|
});
|
|
301
318
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { r as Receipt } from "./types-D1zDOH_F.js";
|
|
2
|
+
import { n as InvoiceDetails } from "./get-Byc9T5WO.js";
|
|
3
|
+
//#region src/data-link/push.d.ts
|
|
4
|
+
type DataLinkPushKind = "invoice" | "incoming-invoice" | "bank-transaction" | "receipts";
|
|
5
|
+
type DataLinkErrorReason = "invalid_payload" | "payload_too_large" | "unknown_document" | "missing_key";
|
|
6
|
+
declare class DataLinkError extends Error {
|
|
7
|
+
override readonly name: string;
|
|
8
|
+
readonly reason: DataLinkErrorReason;
|
|
9
|
+
constructor(reason: DataLinkErrorReason, message: string, cause?: unknown);
|
|
10
|
+
}
|
|
11
|
+
interface DataLinkPushBase {
|
|
12
|
+
readonly key: string | undefined;
|
|
13
|
+
readonly raw: string;
|
|
14
|
+
}
|
|
15
|
+
interface DataLinkInvoicePush extends DataLinkPushBase {
|
|
16
|
+
readonly kind: "invoice" | "incoming-invoice";
|
|
17
|
+
readonly id: number;
|
|
18
|
+
readonly invoice: InvoiceDetails;
|
|
19
|
+
readonly deleted: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface DataLinkBankTransactionPartner {
|
|
22
|
+
readonly name?: string | undefined;
|
|
23
|
+
readonly accountNumber?: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
interface DataLinkBankTransaction {
|
|
26
|
+
readonly id: number;
|
|
27
|
+
readonly accountNumber: string;
|
|
28
|
+
readonly valueDate: string;
|
|
29
|
+
readonly direction: "in" | "out";
|
|
30
|
+
readonly type?: string | undefined;
|
|
31
|
+
readonly technical: boolean;
|
|
32
|
+
readonly amount: number;
|
|
33
|
+
readonly currency: string;
|
|
34
|
+
readonly partner?: DataLinkBankTransactionPartner | undefined;
|
|
35
|
+
readonly reference?: string | undefined;
|
|
36
|
+
}
|
|
37
|
+
interface DataLinkBankTransactionPush extends DataLinkPushBase {
|
|
38
|
+
readonly kind: "bank-transaction";
|
|
39
|
+
readonly transaction: DataLinkBankTransaction;
|
|
40
|
+
}
|
|
41
|
+
interface DataLinkArchivedReceipt {
|
|
42
|
+
readonly receipt: Receipt;
|
|
43
|
+
readonly issuerTaxNumber?: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
interface DataLinkReceiptsPush extends DataLinkPushBase {
|
|
46
|
+
readonly kind: "receipts";
|
|
47
|
+
readonly receipts: readonly DataLinkArchivedReceipt[];
|
|
48
|
+
}
|
|
49
|
+
type DataLinkPush = DataLinkInvoicePush | DataLinkBankTransactionPush | DataLinkReceiptsPush;
|
|
50
|
+
declare function parseDataLinkPush(xml: string, key?: string | undefined): DataLinkPush;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { DataLinkError as a, DataLinkPush as c, parseDataLinkPush as d, DataLinkBankTransactionPush as i, DataLinkPushKind as l, DataLinkBankTransaction as n, DataLinkErrorReason as o, DataLinkBankTransactionPartner as r, DataLinkInvoicePush as s, DataLinkArchivedReceipt as t, DataLinkReceiptsPush as u };
|