@zauthx402/sdk 0.1.3 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{index-CzB2rK59.d.mts → index-CylVkunV.d.mts} +1 -0
- package/dist/{index-CzB2rK59.d.ts → index-CylVkunV.d.ts} +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -0
- package/dist/index.mjs.map +1 -1
- package/dist/middleware/index.d.mts +1 -1
- package/dist/middleware/index.d.ts +1 -1
- package/dist/middleware/index.js +35 -0
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/index.mjs +35 -0
- package/dist/middleware/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -4963,6 +4963,8 @@ var RefundExecutor = class {
|
|
|
4963
4963
|
// YYYY-MM-DD
|
|
4964
4964
|
lastCapResetMonth = (/* @__PURE__ */ new Date()).toISOString().slice(0, 7);
|
|
4965
4965
|
// YYYY-MM
|
|
4966
|
+
// Track processed refundIds to prevent double execution within same session
|
|
4967
|
+
processedRefundIds = /* @__PURE__ */ new Set();
|
|
4966
4968
|
constructor(client, config, debug = false) {
|
|
4967
4969
|
this.client = client;
|
|
4968
4970
|
this.config = config;
|
|
@@ -5055,6 +5057,11 @@ var RefundExecutor = class {
|
|
|
5055
5057
|
case "rejection_ack":
|
|
5056
5058
|
this.log("Refund rejection acknowledged", { refundId: msg.refundId });
|
|
5057
5059
|
break;
|
|
5060
|
+
case "executing_ack":
|
|
5061
|
+
if (this.debug) {
|
|
5062
|
+
this.log("Refund executing acknowledged", { refundId: msg.refundId, status: msg.status });
|
|
5063
|
+
}
|
|
5064
|
+
break;
|
|
5058
5065
|
case "pong":
|
|
5059
5066
|
break;
|
|
5060
5067
|
default:
|
|
@@ -5069,6 +5076,10 @@ var RefundExecutor = class {
|
|
|
5069
5076
|
*/
|
|
5070
5077
|
async processSingleRefund(refund) {
|
|
5071
5078
|
try {
|
|
5079
|
+
if (this.processedRefundIds.has(refund.id)) {
|
|
5080
|
+
this.log("Refund already processed in this session", { refundId: refund.id });
|
|
5081
|
+
return;
|
|
5082
|
+
}
|
|
5072
5083
|
const endpointConfig = this.getEndpointConfig(refund.url);
|
|
5073
5084
|
if (endpointConfig?.enabled === false) {
|
|
5074
5085
|
this.log("Refunds disabled for endpoint", { url: refund.url });
|
|
@@ -5127,8 +5138,13 @@ var RefundExecutor = class {
|
|
|
5127
5138
|
return;
|
|
5128
5139
|
}
|
|
5129
5140
|
}
|
|
5141
|
+
this.sendMessage({
|
|
5142
|
+
type: "refund_executing",
|
|
5143
|
+
refundId: refund.id
|
|
5144
|
+
});
|
|
5130
5145
|
const result = await this.executeRefundTx(refund);
|
|
5131
5146
|
if (result.success) {
|
|
5147
|
+
this.processedRefundIds.add(refund.id);
|
|
5132
5148
|
this.sendMessage({
|
|
5133
5149
|
type: "refund_confirmed",
|
|
5134
5150
|
refundId: refund.id,
|
|
@@ -5374,6 +5390,25 @@ function createZauthMiddleware(options) {
|
|
|
5374
5390
|
if (config.debug) {
|
|
5375
5391
|
console.log("[zauthSDK] Refund executor started");
|
|
5376
5392
|
}
|
|
5393
|
+
client.updateRefundConfig({
|
|
5394
|
+
enabled: true,
|
|
5395
|
+
maxRefundUsdCents: Math.round((config.refund.maxRefundUsd || 1) * 100),
|
|
5396
|
+
dailyCapCents: config.refund.dailyCapUsd ? Math.round(config.refund.dailyCapUsd * 100) : void 0,
|
|
5397
|
+
monthlyCapCents: config.refund.monthlyCapUsd ? Math.round(config.refund.monthlyCapUsd * 100) : void 0,
|
|
5398
|
+
triggers: {
|
|
5399
|
+
serverError: config.refund.triggers?.serverError ?? true,
|
|
5400
|
+
timeout: config.refund.triggers?.timeout ?? true,
|
|
5401
|
+
emptyResponse: config.refund.triggers?.emptyResponse ?? true,
|
|
5402
|
+
schemaValidation: config.refund.triggers?.schemaValidation ?? false,
|
|
5403
|
+
minMeaningfulness: config.refund.triggers?.minMeaningfulness ?? 0.3
|
|
5404
|
+
}
|
|
5405
|
+
}).then((result) => {
|
|
5406
|
+
if (config.debug) {
|
|
5407
|
+
console.log("[zauthSDK] Refund config registered with server", { success: result.success });
|
|
5408
|
+
}
|
|
5409
|
+
}).catch((err) => {
|
|
5410
|
+
console.error("[zauthSDK] Failed to register refund config:", err.message);
|
|
5411
|
+
});
|
|
5377
5412
|
}
|
|
5378
5413
|
function shouldMonitorRoute(req) {
|
|
5379
5414
|
if (options.shouldMonitor) {
|