@orangecheck/me-client 0.60.0 → 0.61.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/CHANGELOG.md +20 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -3
- package/dist/index.mjs.map +1 -1
- package/dist/integrator.js +4 -1
- package/dist/integrator.js.map +1 -1
- package/dist/integrator.mjs +4 -1
- package/dist/integrator.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -318,12 +318,15 @@ var INHERITED_NAMES = new Set(
|
|
|
318
318
|
function isInheritedName(key) {
|
|
319
319
|
return INHERITED_NAMES.has(key.toLowerCase());
|
|
320
320
|
}
|
|
321
|
+
function sitePaysFor(cfg, is_agent) {
|
|
322
|
+
return is_agent && cfg.agent?.site_pays ? cfg.agent.site_pays : cfg.site_pays;
|
|
323
|
+
}
|
|
321
324
|
function computeFees(cfg, payment_amount_sats, opts) {
|
|
322
325
|
const is_agent = opts?.is_agent === true;
|
|
323
326
|
if (is_agent && cfg.agent?.refuse) {
|
|
324
327
|
throw new Error("agent_refused");
|
|
325
328
|
}
|
|
326
|
-
const effective_site_pays =
|
|
329
|
+
const effective_site_pays = sitePaysFor(cfg, is_agent);
|
|
327
330
|
const effective_user_share_pct = is_agent && typeof cfg.agent?.user_share_pct === "number" ? cfg.agent.user_share_pct : cfg.user_share_pct;
|
|
328
331
|
let gross = 0;
|
|
329
332
|
if (effective_site_pays.kind === "fixed_sats") {
|
|
@@ -488,6 +491,7 @@ async function fire(options) {
|
|
|
488
491
|
if (options.payment_amount_sats !== void 0)
|
|
489
492
|
requestBody.payment_amount_sats = options.payment_amount_sats;
|
|
490
493
|
if (options.action_label !== void 0) requestBody.action_label = options.action_label;
|
|
494
|
+
if (options.note !== void 0) requestBody.note = options.note;
|
|
491
495
|
if (options.is_agent !== void 0) requestBody.is_agent = options.is_agent;
|
|
492
496
|
if (earner !== void 0) requestBody.user_address = earner;
|
|
493
497
|
const headers = {};
|
|
@@ -573,7 +577,23 @@ function verify(envelope, config2, payment_amount_sats, opts = {}) {
|
|
|
573
577
|
]
|
|
574
578
|
};
|
|
575
579
|
}
|
|
576
|
-
|
|
580
|
+
const is_agent = envelope.is_agent === true;
|
|
581
|
+
if (is_agent && eventCfg.agent?.refuse) {
|
|
582
|
+
return {
|
|
583
|
+
ok: false,
|
|
584
|
+
expected: null,
|
|
585
|
+
issues: [
|
|
586
|
+
...issues,
|
|
587
|
+
{
|
|
588
|
+
field: "agent_refused",
|
|
589
|
+
expected: null,
|
|
590
|
+
actual: null,
|
|
591
|
+
message: `subtype ${envelope.subtype} refuses agents on integrator ${config2.project_key} but an agent's event was billed`
|
|
592
|
+
}
|
|
593
|
+
]
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
if (sitePaysFor(eventCfg, is_agent).kind === "percent_of_amount" && payment_amount_sats == null) {
|
|
577
597
|
return {
|
|
578
598
|
ok: false,
|
|
579
599
|
expected: null,
|
|
@@ -588,7 +608,7 @@ function verify(envelope, config2, payment_amount_sats, opts = {}) {
|
|
|
588
608
|
]
|
|
589
609
|
};
|
|
590
610
|
}
|
|
591
|
-
const expected = computeFees(eventCfg, payment_amount_sats);
|
|
611
|
+
const expected = computeFees(eventCfg, payment_amount_sats, { is_agent });
|
|
592
612
|
if (envelope.gross_fee_sats !== expected.gross_fee_sats) {
|
|
593
613
|
issues.push({
|
|
594
614
|
field: "gross_fee_sats",
|