@delopay/sdk 0.35.1 → 0.37.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.md +30 -0
- package/dist/{chunk-45OPT3EW.js → chunk-IQKFNKHU.js} +126 -43
- package/dist/chunk-IQKFNKHU.js.map +1 -0
- package/dist/index.cjs +127 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +303 -25
- package/dist/index.d.ts +303 -25
- package/dist/index.js +5 -1
- package/dist/internal.cjs +174 -42
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +151 -13
- package/dist/internal.d.ts +151 -13
- package/dist/internal.js +52 -1
- package/dist/internal.js.map +1 -1
- package/package.json +17 -16
- package/dist/chunk-45OPT3EW.js.map +0 -1
package/dist/internal.cjs
CHANGED
|
@@ -43,6 +43,7 @@ __export(internal_exports, {
|
|
|
43
43
|
DelopayInternal: () => DelopayInternal,
|
|
44
44
|
Export: () => Export,
|
|
45
45
|
FeatureMatrix: () => FeatureMatrix,
|
|
46
|
+
FeeProgramBuilder: () => FeeProgramBuilder,
|
|
46
47
|
Files: () => Files,
|
|
47
48
|
Forex: () => Forex,
|
|
48
49
|
Gsm: () => Gsm,
|
|
@@ -61,6 +62,7 @@ __export(internal_exports, {
|
|
|
61
62
|
defaultBranding: () => defaultBranding,
|
|
62
63
|
encodeBadges: () => encodeBadges,
|
|
63
64
|
encodeBranding: () => encodeBranding,
|
|
65
|
+
feeProgram: () => feeProgram,
|
|
64
66
|
fontStack: () => fontStack,
|
|
65
67
|
fontWeightValue: () => fontWeightValue,
|
|
66
68
|
inputPadValue: () => inputPadValue,
|
|
@@ -703,6 +705,7 @@ var Events = class {
|
|
|
703
705
|
var Fees = class {
|
|
704
706
|
constructor(request) {
|
|
705
707
|
this.request = request;
|
|
708
|
+
this.rules = new FeeRulesManager(request);
|
|
706
709
|
}
|
|
707
710
|
/**
|
|
708
711
|
* Create a merchant-scoped fee schedule (optionally per-shop).
|
|
@@ -744,6 +747,46 @@ var Fees = class {
|
|
|
744
747
|
return this.request("DELETE", `/merchant-fees/${encodeURIComponent(feeId)}`);
|
|
745
748
|
}
|
|
746
749
|
};
|
|
750
|
+
var FeeRulesManager = class {
|
|
751
|
+
constructor(request) {
|
|
752
|
+
this.request = request;
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Create or replace the merchant's fee-rule program (a new active version;
|
|
756
|
+
* the previous version is deactivated server-side).
|
|
757
|
+
*
|
|
758
|
+
* @param params - The program plus optional name / shop scope / validity window.
|
|
759
|
+
* @param merchantId - The merchant account ID.
|
|
760
|
+
*/
|
|
761
|
+
async upsert(params, merchantId) {
|
|
762
|
+
const body = { ...params, fee_owner: "merchant" };
|
|
763
|
+
return this.request("PUT", "/merchant-fees/rules", {
|
|
764
|
+
body,
|
|
765
|
+
query: { merchant_id: merchantId }
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Retrieve the merchant's active fee-rule program, or `null` if none.
|
|
770
|
+
*
|
|
771
|
+
* @param merchantId - The merchant account ID.
|
|
772
|
+
*/
|
|
773
|
+
async retrieve(merchantId) {
|
|
774
|
+
return this.request("GET", "/merchant-fees/rules", {
|
|
775
|
+
query: { merchant_id: merchantId }
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Deactivate the merchant's active fee-rule program (falls back to the flat
|
|
780
|
+
* fee schedules / volume tier). Idempotent.
|
|
781
|
+
*
|
|
782
|
+
* @param merchantId - The merchant account ID.
|
|
783
|
+
*/
|
|
784
|
+
async delete(merchantId) {
|
|
785
|
+
await this.request("DELETE", "/merchant-fees/rules", {
|
|
786
|
+
query: { merchant_id: merchantId }
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
};
|
|
747
790
|
|
|
748
791
|
// src/resources/mandates.ts
|
|
749
792
|
var Mandates = class {
|
|
@@ -2392,51 +2435,23 @@ var Webhooks = {
|
|
|
2392
2435
|
};
|
|
2393
2436
|
|
|
2394
2437
|
// src/resources/analytics.ts
|
|
2395
|
-
var AnalyticsDomain = class {
|
|
2396
|
-
constructor(request, domain) {
|
|
2397
|
-
this.request = request;
|
|
2398
|
-
this.domain = domain;
|
|
2399
|
-
}
|
|
2400
|
-
/** Get metrics. `POST /analytics/metrics/{domain}` */
|
|
2401
|
-
async metrics(params, scope) {
|
|
2402
|
-
const prefix = scope ? `/analytics/${scope}` : "/analytics";
|
|
2403
|
-
return this.request("POST", `${prefix}/metrics/${encodeURIComponent(this.domain)}`, {
|
|
2404
|
-
body: [params]
|
|
2405
|
-
});
|
|
2406
|
-
}
|
|
2407
|
-
/** Get filters. `POST /analytics/filters/{domain}` */
|
|
2408
|
-
async filters(params, scope) {
|
|
2409
|
-
const prefix = scope ? `/analytics/${scope}` : "/analytics";
|
|
2410
|
-
return this.request("POST", `${prefix}/filters/${encodeURIComponent(this.domain)}`, {
|
|
2411
|
-
body: params
|
|
2412
|
-
});
|
|
2413
|
-
}
|
|
2414
|
-
/** Generate report. `POST /analytics/report/{domain}` */
|
|
2415
|
-
async report(params, scope) {
|
|
2416
|
-
const prefix = scope ? `/analytics/${scope}` : "/analytics";
|
|
2417
|
-
return this.request("POST", `${prefix}/report/${encodeURIComponent(this.domain)}`, {
|
|
2418
|
-
body: params
|
|
2419
|
-
});
|
|
2420
|
-
}
|
|
2421
|
-
/** Sankey chart data. `POST /analytics/metrics/{domain}/sankey` */
|
|
2422
|
-
async sankey(params, scope) {
|
|
2423
|
-
const prefix = scope ? `/analytics/${scope}` : "/analytics";
|
|
2424
|
-
return this.request("POST", `${prefix}/metrics/${encodeURIComponent(this.domain)}/sankey`, {
|
|
2425
|
-
body: params
|
|
2426
|
-
});
|
|
2427
|
-
}
|
|
2428
|
-
};
|
|
2429
2438
|
var Analytics = class {
|
|
2430
2439
|
constructor(request) {
|
|
2431
2440
|
this.request = request;
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2441
|
+
}
|
|
2442
|
+
/**
|
|
2443
|
+
* Scoped, drill-level analytics dashboard for the authenticated merchant
|
|
2444
|
+
* (the same engine as the admin portal, pinned server-side to your own
|
|
2445
|
+
* merchant). The server ignores `merchant_id` — it always scopes to your
|
|
2446
|
+
* merchant, and to your single shop for profile-scoped users — so pass only
|
|
2447
|
+
* `project_id` / `shop_id` to drill and the window / `sections` fields.
|
|
2448
|
+
* Returns one drill level: the scope's daily series + previous window,
|
|
2449
|
+
* processor mix and direct children. `GET /analytics/scope`
|
|
2450
|
+
*/
|
|
2451
|
+
async scope(params) {
|
|
2452
|
+
return this.request("GET", "/analytics/scope", {
|
|
2453
|
+
query: params
|
|
2454
|
+
});
|
|
2440
2455
|
}
|
|
2441
2456
|
/** Global search. `POST /analytics/search` */
|
|
2442
2457
|
async search(params) {
|
|
@@ -3095,6 +3110,74 @@ var Delopay = class {
|
|
|
3095
3110
|
/** Utility for verifying incoming webhook signatures (static, no instance needed). */
|
|
3096
3111
|
Delopay.webhooks = Webhooks;
|
|
3097
3112
|
|
|
3113
|
+
// src/feeProgram.ts
|
|
3114
|
+
function toFeeOutput(spec) {
|
|
3115
|
+
const hasPct = spec.percentage != null;
|
|
3116
|
+
const hasFlat = spec.flat != null;
|
|
3117
|
+
const feeType = hasPct && hasFlat ? "combined" : hasFlat ? "flat" : "percentage";
|
|
3118
|
+
return {
|
|
3119
|
+
fee_type: feeType,
|
|
3120
|
+
percentage_fee: spec.percentage ?? null,
|
|
3121
|
+
flat_fee_amount: spec.flat ?? null,
|
|
3122
|
+
flat_fee_currency: spec.flatCurrency ?? null,
|
|
3123
|
+
min_fee_amount: spec.min ?? null,
|
|
3124
|
+
max_fee_amount: spec.max ?? null
|
|
3125
|
+
};
|
|
3126
|
+
}
|
|
3127
|
+
function enumCondition(lhs, value) {
|
|
3128
|
+
return { lhs, comparison: "equal", value: { type: "enum_variant", value }, metadata: {} };
|
|
3129
|
+
}
|
|
3130
|
+
function numberCondition(lhs, comparison, value) {
|
|
3131
|
+
return { lhs, comparison, value: { type: "number", value }, metadata: {} };
|
|
3132
|
+
}
|
|
3133
|
+
function buildConditions(when = {}, raw = []) {
|
|
3134
|
+
const out = [];
|
|
3135
|
+
if (when.paymentMethod != null) out.push(enumCondition("payment_method", when.paymentMethod));
|
|
3136
|
+
if (when.connector != null) out.push(enumCondition("connector", when.connector));
|
|
3137
|
+
if (when.currency != null) out.push(enumCondition("currency", when.currency));
|
|
3138
|
+
if (when.cardNetwork != null) out.push(enumCondition("card_network", when.cardNetwork));
|
|
3139
|
+
if (when.amountEquals != null) out.push(numberCondition("amount", "equal", when.amountEquals));
|
|
3140
|
+
if (when.amountGreaterThan != null) {
|
|
3141
|
+
out.push(numberCondition("amount", "greater_than", when.amountGreaterThan));
|
|
3142
|
+
}
|
|
3143
|
+
if (when.amountLessThan != null) {
|
|
3144
|
+
out.push(numberCondition("amount", "less_than", when.amountLessThan));
|
|
3145
|
+
}
|
|
3146
|
+
out.push(...raw);
|
|
3147
|
+
return out;
|
|
3148
|
+
}
|
|
3149
|
+
var FeeProgramBuilder = class {
|
|
3150
|
+
constructor() {
|
|
3151
|
+
this.rules = [];
|
|
3152
|
+
this.defaultFee = null;
|
|
3153
|
+
}
|
|
3154
|
+
/** Append a rule. Provided `when`/`rawConditions` are ANDed. */
|
|
3155
|
+
rule(input) {
|
|
3156
|
+
this.rules.push({
|
|
3157
|
+
name: input.name,
|
|
3158
|
+
connectorSelection: { fee: toFeeOutput(input.fee) },
|
|
3159
|
+
statements: [{ condition: buildConditions(input.when, input.rawConditions) }]
|
|
3160
|
+
});
|
|
3161
|
+
return this;
|
|
3162
|
+
}
|
|
3163
|
+
/** Set the default selection (applied when no rule matches). */
|
|
3164
|
+
otherwise(fee) {
|
|
3165
|
+
this.defaultFee = toFeeOutput(fee);
|
|
3166
|
+
return this;
|
|
3167
|
+
}
|
|
3168
|
+
/** Produce the wire-ready program. */
|
|
3169
|
+
build() {
|
|
3170
|
+
return {
|
|
3171
|
+
defaultSelection: { fee: this.defaultFee },
|
|
3172
|
+
rules: this.rules,
|
|
3173
|
+
metadata: {}
|
|
3174
|
+
};
|
|
3175
|
+
}
|
|
3176
|
+
};
|
|
3177
|
+
function feeProgram() {
|
|
3178
|
+
return new FeeProgramBuilder();
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3098
3181
|
// src/branding.ts
|
|
3099
3182
|
var FONT_STACKS = {
|
|
3100
3183
|
inter: "'Inter Variable', 'Inter', system-ui, -apple-system, sans-serif",
|
|
@@ -3797,6 +3880,27 @@ var AdminPortal = class {
|
|
|
3797
3880
|
query: params
|
|
3798
3881
|
});
|
|
3799
3882
|
}
|
|
3883
|
+
/**
|
|
3884
|
+
* One drill level of the analytics dashboard: the scope's daily series +
|
|
3885
|
+
* processor mix and its direct children's series. Range / metric / donut
|
|
3886
|
+
* toggles apply client-side; only a drill (passing merchant_id / project_id
|
|
3887
|
+
* / shop_id) fetches the next level.
|
|
3888
|
+
*/
|
|
3889
|
+
async analyticsScope(params) {
|
|
3890
|
+
return this.request("GET", "/admin-portal/analytics/scope", {
|
|
3891
|
+
query: params
|
|
3892
|
+
});
|
|
3893
|
+
}
|
|
3894
|
+
/**
|
|
3895
|
+
* Platform billing dashboard: total balance across all ledger accounts (+
|
|
3896
|
+
* the net change), top-ups, fees collected, and the day-by-day ledger flow.
|
|
3897
|
+
* All amounts are in USD minor units.
|
|
3898
|
+
*/
|
|
3899
|
+
async ledgerAnalytics(params) {
|
|
3900
|
+
return this.request("GET", "/admin-portal/ledger-analytics", {
|
|
3901
|
+
query: params
|
|
3902
|
+
});
|
|
3903
|
+
}
|
|
3800
3904
|
/**
|
|
3801
3905
|
* Retrieve a merchant account via the admin portal. Unlike
|
|
3802
3906
|
* `merchantAccounts.retrieve`, this route accepts an admin JWT (or admin API
|
|
@@ -4058,6 +4162,7 @@ var PlatformBilling = class {
|
|
|
4058
4162
|
var PlatformFees = class {
|
|
4059
4163
|
constructor(request) {
|
|
4060
4164
|
this.request = request;
|
|
4165
|
+
this.rules = new PlatformFeeRulesManager(request);
|
|
4061
4166
|
}
|
|
4062
4167
|
/** Create a platform fee schedule for a specific merchant. */
|
|
4063
4168
|
async create(params, merchantId) {
|
|
@@ -4085,6 +4190,31 @@ var PlatformFees = class {
|
|
|
4085
4190
|
return this.request("DELETE", `/admin/fees/${encodeURIComponent(feeId)}`);
|
|
4086
4191
|
}
|
|
4087
4192
|
};
|
|
4193
|
+
var PlatformFeeRulesManager = class {
|
|
4194
|
+
constructor(request) {
|
|
4195
|
+
this.request = request;
|
|
4196
|
+
}
|
|
4197
|
+
/** Create or replace the platform fee-rule program for a merchant. */
|
|
4198
|
+
async upsert(params, merchantId) {
|
|
4199
|
+
const body = { ...params, fee_owner: "platform" };
|
|
4200
|
+
return this.request("PUT", "/admin/fees/rules", {
|
|
4201
|
+
body,
|
|
4202
|
+
query: { merchant_id: merchantId }
|
|
4203
|
+
});
|
|
4204
|
+
}
|
|
4205
|
+
/** Retrieve the active platform fee-rule program for a merchant, or `null`. */
|
|
4206
|
+
async retrieve(merchantId) {
|
|
4207
|
+
return this.request("GET", "/admin/fees/rules", {
|
|
4208
|
+
query: { merchant_id: merchantId }
|
|
4209
|
+
});
|
|
4210
|
+
}
|
|
4211
|
+
/** Deactivate the platform fee-rule program for a merchant. Idempotent. */
|
|
4212
|
+
async delete(merchantId) {
|
|
4213
|
+
await this.request("DELETE", "/admin/fees/rules", {
|
|
4214
|
+
query: { merchant_id: merchantId }
|
|
4215
|
+
});
|
|
4216
|
+
}
|
|
4217
|
+
};
|
|
4088
4218
|
|
|
4089
4219
|
// src/internal/client.ts
|
|
4090
4220
|
var DelopayInternal = class extends Delopay {
|
|
@@ -4128,6 +4258,7 @@ var DelopayInternal = class extends Delopay {
|
|
|
4128
4258
|
DelopayInternal,
|
|
4129
4259
|
Export,
|
|
4130
4260
|
FeatureMatrix,
|
|
4261
|
+
FeeProgramBuilder,
|
|
4131
4262
|
Files,
|
|
4132
4263
|
Forex,
|
|
4133
4264
|
Gsm,
|
|
@@ -4146,6 +4277,7 @@ var DelopayInternal = class extends Delopay {
|
|
|
4146
4277
|
defaultBranding,
|
|
4147
4278
|
encodeBadges,
|
|
4148
4279
|
encodeBranding,
|
|
4280
|
+
feeProgram,
|
|
4149
4281
|
fontStack,
|
|
4150
4282
|
fontWeightValue,
|
|
4151
4283
|
inputPadValue,
|