@zauthx402/sdk 0.1.5 → 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/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 +1 -1
|
@@ -4693,6 +4693,8 @@ var RefundExecutor = class {
|
|
|
4693
4693
|
// YYYY-MM-DD
|
|
4694
4694
|
lastCapResetMonth = (/* @__PURE__ */ new Date()).toISOString().slice(0, 7);
|
|
4695
4695
|
// YYYY-MM
|
|
4696
|
+
// Track processed refundIds to prevent double execution within same session
|
|
4697
|
+
processedRefundIds = /* @__PURE__ */ new Set();
|
|
4696
4698
|
constructor(client, config, debug = false) {
|
|
4697
4699
|
this.client = client;
|
|
4698
4700
|
this.config = config;
|
|
@@ -4785,6 +4787,11 @@ var RefundExecutor = class {
|
|
|
4785
4787
|
case "rejection_ack":
|
|
4786
4788
|
this.log("Refund rejection acknowledged", { refundId: msg.refundId });
|
|
4787
4789
|
break;
|
|
4790
|
+
case "executing_ack":
|
|
4791
|
+
if (this.debug) {
|
|
4792
|
+
this.log("Refund executing acknowledged", { refundId: msg.refundId, status: msg.status });
|
|
4793
|
+
}
|
|
4794
|
+
break;
|
|
4788
4795
|
case "pong":
|
|
4789
4796
|
break;
|
|
4790
4797
|
default:
|
|
@@ -4799,6 +4806,10 @@ var RefundExecutor = class {
|
|
|
4799
4806
|
*/
|
|
4800
4807
|
async processSingleRefund(refund) {
|
|
4801
4808
|
try {
|
|
4809
|
+
if (this.processedRefundIds.has(refund.id)) {
|
|
4810
|
+
this.log("Refund already processed in this session", { refundId: refund.id });
|
|
4811
|
+
return;
|
|
4812
|
+
}
|
|
4802
4813
|
const endpointConfig = this.getEndpointConfig(refund.url);
|
|
4803
4814
|
if (endpointConfig?.enabled === false) {
|
|
4804
4815
|
this.log("Refunds disabled for endpoint", { url: refund.url });
|
|
@@ -4857,8 +4868,13 @@ var RefundExecutor = class {
|
|
|
4857
4868
|
return;
|
|
4858
4869
|
}
|
|
4859
4870
|
}
|
|
4871
|
+
this.sendMessage({
|
|
4872
|
+
type: "refund_executing",
|
|
4873
|
+
refundId: refund.id
|
|
4874
|
+
});
|
|
4860
4875
|
const result = await this.executeRefundTx(refund);
|
|
4861
4876
|
if (result.success) {
|
|
4877
|
+
this.processedRefundIds.add(refund.id);
|
|
4862
4878
|
this.sendMessage({
|
|
4863
4879
|
type: "refund_confirmed",
|
|
4864
4880
|
refundId: refund.id,
|
|
@@ -5104,6 +5120,25 @@ function createZauthMiddleware(options) {
|
|
|
5104
5120
|
if (config.debug) {
|
|
5105
5121
|
console.log("[zauthSDK] Refund executor started");
|
|
5106
5122
|
}
|
|
5123
|
+
client.updateRefundConfig({
|
|
5124
|
+
enabled: true,
|
|
5125
|
+
maxRefundUsdCents: Math.round((config.refund.maxRefundUsd || 1) * 100),
|
|
5126
|
+
dailyCapCents: config.refund.dailyCapUsd ? Math.round(config.refund.dailyCapUsd * 100) : void 0,
|
|
5127
|
+
monthlyCapCents: config.refund.monthlyCapUsd ? Math.round(config.refund.monthlyCapUsd * 100) : void 0,
|
|
5128
|
+
triggers: {
|
|
5129
|
+
serverError: config.refund.triggers?.serverError ?? true,
|
|
5130
|
+
timeout: config.refund.triggers?.timeout ?? true,
|
|
5131
|
+
emptyResponse: config.refund.triggers?.emptyResponse ?? true,
|
|
5132
|
+
schemaValidation: config.refund.triggers?.schemaValidation ?? false,
|
|
5133
|
+
minMeaningfulness: config.refund.triggers?.minMeaningfulness ?? 0.3
|
|
5134
|
+
}
|
|
5135
|
+
}).then((result) => {
|
|
5136
|
+
if (config.debug) {
|
|
5137
|
+
console.log("[zauthSDK] Refund config registered with server", { success: result.success });
|
|
5138
|
+
}
|
|
5139
|
+
}).catch((err) => {
|
|
5140
|
+
console.error("[zauthSDK] Failed to register refund config:", err.message);
|
|
5141
|
+
});
|
|
5107
5142
|
}
|
|
5108
5143
|
function shouldMonitorRoute(req) {
|
|
5109
5144
|
if (options.shouldMonitor) {
|