kassza 0.12.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 +427 -32
- package/agents/README.md +26 -6
- package/agents/api.md +218 -3
- package/agents/pitfalls.md +27 -3
- package/agents/recipes.md +280 -51
- package/agents/skills/kassza/SKILL.md +14 -8
- 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 +643 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +643 -0
- package/dist/client-CLFvJCVW.cjs +1452 -0
- package/dist/{client-CL3fuH6A.js → client-Cvf-hTz_.js} +306 -515
- package/dist/client-DeWWQ-RZ.d.ts +341 -0
- package/dist/client-SVZu25MB.d.cts +341 -0
- package/dist/context-CFNKzStE.d.cts +449 -0
- package/dist/context-kb33TgzE.d.ts +449 -0
- 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-D0pwuenl.cjs → create-once-9yxR_Er_.cjs} +291 -33
- package/dist/create-once-Bh6fOWkW.d.cts +20 -0
- package/dist/{create-once-CqdYmQD8.js → create-once-Ca2gMk1h.js} +250 -34
- package/dist/create-once-VKp0tVow.d.ts +20 -0
- package/dist/{crypto-B8lERvR1.cjs → crypto-Dpn4FHQ6.cjs} +9 -0
- package/dist/{crypto-DK_osBVy.js → crypto-usDg8L2K.js} +4 -1
- package/dist/data-link/index.cjs +232 -0
- package/dist/data-link/index.d.cts +29 -0
- package/dist/data-link/index.d.ts +29 -0
- package/dist/data-link/index.js +224 -0
- package/dist/delegation/index.cjs +35 -34
- package/dist/delegation/index.d.cts +2 -1
- package/dist/delegation/index.d.ts +2 -1
- package/dist/delegation/index.js +4 -3
- package/dist/{errors-DLrb0g64.js → errors-DtN4g5Z9.js} +9 -1
- package/dist/{errors-DxeuTslP.cjs → errors-EE96_6D_.cjs} +20 -0
- package/dist/get-BdMTseh4.cjs +271 -0
- package/dist/get-Byc9T5WO.d.cts +151 -0
- package/dist/get-Byc9T5WO.d.ts +151 -0
- package/dist/get-CZEShCcj.js +260 -0
- 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 +11 -19
- package/dist/index.d.ts +11 -19
- 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-Bin4tKD_.cjs +988 -0
- package/dist/issue-DMA1Nbr1.js +905 -0
- 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 +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 +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-DAA7OwiO.js → money-Cw457SD6.js} +120 -12
- package/dist/{money-DrhGkWHW.cjs → money-K9j0wPit.cjs} +124 -10
- 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-BNbc8U0R.cjs +203 -0
- package/dist/nav-BcCerwWS.js +156 -0
- 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-Cr7yQ3_z.js +291 -0
- package/dist/parse-DOA2XQ3e.cjs +380 -0
- 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 +17 -3
- package/dist/payments/revolut.d.cts +2 -2
- package/dist/payments/revolut.d.ts +2 -2
- package/dist/payments/revolut.js +17 -3
- package/dist/payments/simplepay.cjs +37 -5
- package/dist/payments/simplepay.d.cts +2 -2
- package/dist/payments/simplepay.d.ts +2 -2
- package/dist/payments/simplepay.js +37 -5
- package/dist/payments/stripe.cjs +20 -3
- package/dist/payments/stripe.d.cts +2 -2
- package/dist/payments/stripe.d.ts +2 -2
- package/dist/payments/stripe.js +20 -3
- 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 +11 -164
- package/dist/reports/index.d.cts +1 -1
- package/dist/reports/index.d.ts +1 -1
- package/dist/reports/index.js +1 -154
- package/dist/request-body-CH6ZGOrq.cjs +34 -0
- package/dist/request-body-uZHMRlQr.js +29 -0
- package/dist/serialize-B2eFh3D-.js +219 -0
- package/dist/serialize-CquIsxA-.cjs +290 -0
- package/dist/server-BrJUbXs7.js +1505 -0
- package/dist/server-Dw9j8Mnd.cjs +1558 -0
- 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 +1500 -15
- package/dist/testing/index.d.cts +198 -3
- package/dist/testing/index.d.ts +198 -3
- package/dist/testing/index.js +1498 -15
- package/dist/{types-COf1LAD-.d.ts → types-B1A8mUIE.d.cts} +14 -2
- package/dist/{types-COf1LAD-.d.cts → types-ByAEvGsZ.d.ts} +14 -2
- 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-D4lvtex1.js → webhook-CQVShAfI.js} +47 -26
- package/dist/{webhook-C76bV-4R.cjs → webhook-Ckj-_hPD.cjs} +70 -25
- package/dist/webhook-CmdhGiH5.d.cts +11 -0
- package/dist/webhook-D6lEejob.d.ts +11 -0
- package/llms.txt +6 -5
- package/package.json +134 -4
- package/dist/client-CickRRFr.d.ts +0 -838
- package/dist/client-CsmGIFRS.cjs +0 -1637
- package/dist/client-DvWZoX_E.d.cts +0 -838
- package/dist/issue-BsyYdrIG.cjs +0 -1531
- package/dist/issue-C6Fcjvln.js +0 -1274
- package/dist/session-Dm_45x8K.d.cts +0 -11
- package/dist/session-Dm_45x8K.d.ts +0 -11
- package/dist/webhook-CfaDgcL0.d.cts +0 -6
- package/dist/webhook-q2OzNwd7.d.ts +0 -6
package/dist/payments/barion.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rounding = require("../rounding-TxoWy2ww.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/barion.ts
|
|
6
6
|
const BARION_LIVE_API_URL = "https://api.barion.com";
|
|
@@ -144,6 +144,29 @@ function kindOf(status, paidTotal, refunds) {
|
|
|
144
144
|
if (status && FAILED_STATUSES.has(status)) return "failed";
|
|
145
145
|
return "other";
|
|
146
146
|
}
|
|
147
|
+
function refundsOf(refunds, currency) {
|
|
148
|
+
if (!currency || refunds.length === 0) return void 0;
|
|
149
|
+
const ordered = refunds.map((refund) => ({
|
|
150
|
+
id: require_json.text(refund.TransactionId) ?? require_json.text(refund.POSTransactionId),
|
|
151
|
+
value: Math.abs(require_json.numeric(refund.Total) ?? 0),
|
|
152
|
+
createdAt: require_json.text(refund.TransactionTime)
|
|
153
|
+
})).filter((refund) => Boolean(refund.id)).sort((a, b) => (a.createdAt ?? "").localeCompare(b.createdAt ?? "") || a.id.localeCompare(b.id));
|
|
154
|
+
if (ordered.length !== refunds.length) return void 0;
|
|
155
|
+
let before = 0;
|
|
156
|
+
return ordered.map((refund) => {
|
|
157
|
+
const entry = {
|
|
158
|
+
id: refund.id,
|
|
159
|
+
amount: {
|
|
160
|
+
value: refund.value,
|
|
161
|
+
currency: require_webhook.normalizeCurrency(currency)
|
|
162
|
+
},
|
|
163
|
+
refundedBefore: before,
|
|
164
|
+
createdAt: refund.createdAt
|
|
165
|
+
};
|
|
166
|
+
before = sum([before, refund.value]);
|
|
167
|
+
return entry;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
147
170
|
function barionPaymentEvent(state, options = {}) {
|
|
148
171
|
const paymentId = require_json.text(state.PaymentId);
|
|
149
172
|
if (!paymentId) throw new require_webhook.PaymentProviderError("barion", "A Barion PaymentState válaszából hiányzik a PaymentId.");
|
|
@@ -170,6 +193,7 @@ function barionPaymentEvent(state, options = {}) {
|
|
|
170
193
|
value: refunded,
|
|
171
194
|
currency: require_webhook.normalizeCurrency(currency)
|
|
172
195
|
} : void 0,
|
|
196
|
+
refunds: refundsOf(refunds, currency),
|
|
173
197
|
paidAt: require_json.text(state.CompletedAt),
|
|
174
198
|
method: methodOf(state, options.method),
|
|
175
199
|
customer: customerOf(sales.length > 0 ? sales : transactions),
|
|
@@ -192,7 +216,7 @@ function barionWebhook(options) {
|
|
|
192
216
|
});
|
|
193
217
|
const returnedId = require_json.text(state.PaymentId);
|
|
194
218
|
if (!returnedId || normalizeId(returnedId) !== normalizeId(paymentId)) throw new require_webhook.PaymentProviderError("barion", `A Barion más fizetést adott vissza (${returnedId ?? "?"}) a kért ${paymentId} helyett.`);
|
|
195
|
-
await
|
|
219
|
+
await require_webhook.deliverPayment(options, barionPaymentEvent(state, { method: options.method }));
|
|
196
220
|
return require_webhook.plainResponse(200, "OK");
|
|
197
221
|
});
|
|
198
222
|
}
|
|
@@ -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/barion.d.ts
|
|
5
5
|
export declare const BARION_LIVE_API_URL = "https://api.barion.com";
|
|
6
6
|
export declare const BARION_SANDBOX_API_URL = "https://api.test.barion.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/barion.d.ts
|
|
5
5
|
export declare const BARION_LIVE_API_URL = "https://api.barion.com";
|
|
6
6
|
export declare const BARION_SANDBOX_API_URL = "https://api.test.barion.com";
|
package/dist/payments/barion.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as roundMoney } from "../rounding-BLyHjjI5.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as plainResponse, d as WebhookVerificationError, h as normalizeCurrency, i as respondToWebhook, l as readRawBody, r as deliverPayment, u as PaymentProviderError } from "../webhook-CQVShAfI.js";
|
|
3
3
|
import { a as text, i as records, r as record, t as numeric } from "../json-DjnqnaJK.js";
|
|
4
4
|
//#region src/payments/barion.ts
|
|
5
5
|
const BARION_LIVE_API_URL = "https://api.barion.com";
|
|
@@ -143,6 +143,29 @@ function kindOf(status, paidTotal, refunds) {
|
|
|
143
143
|
if (status && FAILED_STATUSES.has(status)) return "failed";
|
|
144
144
|
return "other";
|
|
145
145
|
}
|
|
146
|
+
function refundsOf(refunds, currency) {
|
|
147
|
+
if (!currency || refunds.length === 0) return void 0;
|
|
148
|
+
const ordered = refunds.map((refund) => ({
|
|
149
|
+
id: text(refund.TransactionId) ?? text(refund.POSTransactionId),
|
|
150
|
+
value: Math.abs(numeric(refund.Total) ?? 0),
|
|
151
|
+
createdAt: text(refund.TransactionTime)
|
|
152
|
+
})).filter((refund) => Boolean(refund.id)).sort((a, b) => (a.createdAt ?? "").localeCompare(b.createdAt ?? "") || a.id.localeCompare(b.id));
|
|
153
|
+
if (ordered.length !== refunds.length) return void 0;
|
|
154
|
+
let before = 0;
|
|
155
|
+
return ordered.map((refund) => {
|
|
156
|
+
const entry = {
|
|
157
|
+
id: refund.id,
|
|
158
|
+
amount: {
|
|
159
|
+
value: refund.value,
|
|
160
|
+
currency: normalizeCurrency(currency)
|
|
161
|
+
},
|
|
162
|
+
refundedBefore: before,
|
|
163
|
+
createdAt: refund.createdAt
|
|
164
|
+
};
|
|
165
|
+
before = sum([before, refund.value]);
|
|
166
|
+
return entry;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
146
169
|
function barionPaymentEvent(state, options = {}) {
|
|
147
170
|
const paymentId = text(state.PaymentId);
|
|
148
171
|
if (!paymentId) throw new PaymentProviderError("barion", "A Barion PaymentState válaszából hiányzik a PaymentId.");
|
|
@@ -169,6 +192,7 @@ function barionPaymentEvent(state, options = {}) {
|
|
|
169
192
|
value: refunded,
|
|
170
193
|
currency: normalizeCurrency(currency)
|
|
171
194
|
} : void 0,
|
|
195
|
+
refunds: refundsOf(refunds, currency),
|
|
172
196
|
paidAt: text(state.CompletedAt),
|
|
173
197
|
method: methodOf(state, options.method),
|
|
174
198
|
customer: customerOf(sales.length > 0 ? sales : transactions),
|
|
@@ -191,7 +215,7 @@ function barionWebhook(options) {
|
|
|
191
215
|
});
|
|
192
216
|
const returnedId = text(state.PaymentId);
|
|
193
217
|
if (!returnedId || normalizeId(returnedId) !== normalizeId(paymentId)) throw new PaymentProviderError("barion", `A Barion más fizetést adott vissza (${returnedId ?? "?"}) a kért ${paymentId} helyett.`);
|
|
194
|
-
await options
|
|
218
|
+
await deliverPayment(options, barionPaymentEvent(state, { method: options.method }));
|
|
195
219
|
return plainResponse(200, "OK");
|
|
196
220
|
});
|
|
197
221
|
}
|
package/dist/payments/index.cjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_issue = require("../issue-
|
|
3
|
-
const require_webhook = require("../webhook-
|
|
2
|
+
const require_issue = require("../issue-Bin4tKD_.cjs");
|
|
3
|
+
const require_webhook = require("../webhook-Ckj-_hPD.cjs");
|
|
4
|
+
exports.DEFAULT_DEDUPE_TTL_SECONDS = require_webhook.DEFAULT_DEDUPE_TTL_SECONDS;
|
|
4
5
|
exports.DEFAULT_MAX_WEBHOOK_BYTES = require_webhook.DEFAULT_MAX_WEBHOOK_BYTES;
|
|
5
6
|
exports.PaymentProviderError = require_webhook.PaymentProviderError;
|
|
7
|
+
exports.WEBHOOK_DEDUPE_KEY_PREFIX = require_webhook.WEBHOOK_DEDUPE_KEY_PREFIX;
|
|
6
8
|
exports.WebhookVerificationError = require_webhook.WebhookVerificationError;
|
|
7
9
|
exports.buyerFromCustomer = require_issue.buyerFromCustomer;
|
|
10
|
+
exports.correctionExternalId = require_issue.correctionExternalId;
|
|
8
11
|
exports.currencyExponent = require_webhook.currencyExponent;
|
|
12
|
+
exports.deliverPayment = require_webhook.deliverPayment;
|
|
9
13
|
exports.fromMinorUnits = require_webhook.fromMinorUnits;
|
|
10
14
|
exports.isWebhookVerificationError = require_webhook.isWebhookVerificationError;
|
|
11
15
|
exports.issueForPayment = require_issue.issueForPayment;
|
|
@@ -14,3 +18,4 @@ exports.parseDecimalAmount = require_webhook.parseDecimalAmount;
|
|
|
14
18
|
exports.paymentOrderNumber = require_issue.paymentOrderNumber;
|
|
15
19
|
exports.readRawBody = require_webhook.readRawBody;
|
|
16
20
|
exports.respondToWebhook = require_webhook.respondToWebhook;
|
|
21
|
+
exports.webhookDedupeKey = require_webhook.webhookDedupeKey;
|
|
@@ -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-SVZu25MB.cjs";
|
|
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-B1A8mUIE.cjs";
|
|
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-CmdhGiH5.cjs";
|
|
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.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
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const require_crypto = require("../crypto-Dpn4FHQ6.cjs");
|
|
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
|
-
import { a as
|
|
2
|
-
import { i as
|
|
1
|
+
import { a as timingSafeEqual, i as hmacHex } from "../crypto-usDg8L2K.js";
|
|
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
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
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
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const require_crypto = require("../crypto-Dpn4FHQ6.cjs");
|
|
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
|
-
import { a as
|
|
4
|
-
import { i as
|
|
3
|
+
import { a as timingSafeEqual, r as hmac, t as bytesToHex } from "../crypto-usDg8L2K.js";
|
|
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
|
}));
|