@delopay/sdk 0.35.0 → 0.36.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-ZS7ALFE7.js} +112 -1
- package/dist/chunk-ZS7ALFE7.js.map +1 -0
- package/dist/index.cjs +113 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +221 -1
- package/dist/index.d.ts +221 -1
- package/dist/index.js +5 -1
- package/dist/internal.cjs +181 -0
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +80 -3
- package/dist/internal.d.ts +80 -3
- package/dist/internal.js +73 -1
- package/dist/internal.js.map +1 -1
- package/package.json +1 -1
- 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 {
|
|
@@ -3095,6 +3138,74 @@ var Delopay = class {
|
|
|
3095
3138
|
/** Utility for verifying incoming webhook signatures (static, no instance needed). */
|
|
3096
3139
|
Delopay.webhooks = Webhooks;
|
|
3097
3140
|
|
|
3141
|
+
// src/feeProgram.ts
|
|
3142
|
+
function toFeeOutput(spec) {
|
|
3143
|
+
const hasPct = spec.percentage != null;
|
|
3144
|
+
const hasFlat = spec.flat != null;
|
|
3145
|
+
const feeType = hasPct && hasFlat ? "combined" : hasFlat ? "flat" : "percentage";
|
|
3146
|
+
return {
|
|
3147
|
+
fee_type: feeType,
|
|
3148
|
+
percentage_fee: spec.percentage ?? null,
|
|
3149
|
+
flat_fee_amount: spec.flat ?? null,
|
|
3150
|
+
flat_fee_currency: spec.flatCurrency ?? null,
|
|
3151
|
+
min_fee_amount: spec.min ?? null,
|
|
3152
|
+
max_fee_amount: spec.max ?? null
|
|
3153
|
+
};
|
|
3154
|
+
}
|
|
3155
|
+
function enumCondition(lhs, value) {
|
|
3156
|
+
return { lhs, comparison: "equal", value: { type: "enum_variant", value }, metadata: {} };
|
|
3157
|
+
}
|
|
3158
|
+
function numberCondition(lhs, comparison, value) {
|
|
3159
|
+
return { lhs, comparison, value: { type: "number", value }, metadata: {} };
|
|
3160
|
+
}
|
|
3161
|
+
function buildConditions(when = {}, raw = []) {
|
|
3162
|
+
const out = [];
|
|
3163
|
+
if (when.paymentMethod != null) out.push(enumCondition("payment_method", when.paymentMethod));
|
|
3164
|
+
if (when.connector != null) out.push(enumCondition("connector", when.connector));
|
|
3165
|
+
if (when.currency != null) out.push(enumCondition("currency", when.currency));
|
|
3166
|
+
if (when.cardNetwork != null) out.push(enumCondition("card_network", when.cardNetwork));
|
|
3167
|
+
if (when.amountEquals != null) out.push(numberCondition("amount", "equal", when.amountEquals));
|
|
3168
|
+
if (when.amountGreaterThan != null) {
|
|
3169
|
+
out.push(numberCondition("amount", "greater_than", when.amountGreaterThan));
|
|
3170
|
+
}
|
|
3171
|
+
if (when.amountLessThan != null) {
|
|
3172
|
+
out.push(numberCondition("amount", "less_than", when.amountLessThan));
|
|
3173
|
+
}
|
|
3174
|
+
out.push(...raw);
|
|
3175
|
+
return out;
|
|
3176
|
+
}
|
|
3177
|
+
var FeeProgramBuilder = class {
|
|
3178
|
+
constructor() {
|
|
3179
|
+
this.rules = [];
|
|
3180
|
+
this.defaultFee = null;
|
|
3181
|
+
}
|
|
3182
|
+
/** Append a rule. Provided `when`/`rawConditions` are ANDed. */
|
|
3183
|
+
rule(input) {
|
|
3184
|
+
this.rules.push({
|
|
3185
|
+
name: input.name,
|
|
3186
|
+
connectorSelection: { fee: toFeeOutput(input.fee) },
|
|
3187
|
+
statements: [{ condition: buildConditions(input.when, input.rawConditions) }]
|
|
3188
|
+
});
|
|
3189
|
+
return this;
|
|
3190
|
+
}
|
|
3191
|
+
/** Set the default selection (applied when no rule matches). */
|
|
3192
|
+
otherwise(fee) {
|
|
3193
|
+
this.defaultFee = toFeeOutput(fee);
|
|
3194
|
+
return this;
|
|
3195
|
+
}
|
|
3196
|
+
/** Produce the wire-ready program. */
|
|
3197
|
+
build() {
|
|
3198
|
+
return {
|
|
3199
|
+
defaultSelection: { fee: this.defaultFee },
|
|
3200
|
+
rules: this.rules,
|
|
3201
|
+
metadata: {}
|
|
3202
|
+
};
|
|
3203
|
+
}
|
|
3204
|
+
};
|
|
3205
|
+
function feeProgram() {
|
|
3206
|
+
return new FeeProgramBuilder();
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3098
3209
|
// src/branding.ts
|
|
3099
3210
|
var FONT_STACKS = {
|
|
3100
3211
|
inter: "'Inter Variable', 'Inter', system-ui, -apple-system, sans-serif",
|
|
@@ -4010,12 +4121,55 @@ var PlatformBilling = class {
|
|
|
4010
4121
|
body: params
|
|
4011
4122
|
});
|
|
4012
4123
|
}
|
|
4124
|
+
/**
|
|
4125
|
+
* Manually suspend a merchant (e.g. confirmed fraud or ToS violation),
|
|
4126
|
+
* independent of balance. A `reason` is required for audit. Throws 412 if
|
|
4127
|
+
* the merchant is trusted (clear the flag first) or already suspended.
|
|
4128
|
+
*
|
|
4129
|
+
* @param merchantId - The merchant account ID.
|
|
4130
|
+
* @param params - Suspension reason.
|
|
4131
|
+
* @returns The updated billing profile.
|
|
4132
|
+
*/
|
|
4133
|
+
async suspend(merchantId, params) {
|
|
4134
|
+
return this.request("POST", `/billing/${encodeURIComponent(merchantId)}/admin/suspend`, {
|
|
4135
|
+
body: params
|
|
4136
|
+
});
|
|
4137
|
+
}
|
|
4138
|
+
/**
|
|
4139
|
+
* Lift a suspension. Restores the merchant to `active` (or `delinquent` if
|
|
4140
|
+
* the balance is at/below the hard floor) and resets the recharge-failure
|
|
4141
|
+
* counter. Throws 412 if the merchant is not suspended.
|
|
4142
|
+
*
|
|
4143
|
+
* @param merchantId - The merchant account ID.
|
|
4144
|
+
* @param params - Optional audit note.
|
|
4145
|
+
* @returns The updated billing profile.
|
|
4146
|
+
*/
|
|
4147
|
+
async unsuspend(merchantId, params = {}) {
|
|
4148
|
+
return this.request("POST", `/billing/${encodeURIComponent(merchantId)}/admin/unsuspend`, {
|
|
4149
|
+
body: params
|
|
4150
|
+
});
|
|
4151
|
+
}
|
|
4152
|
+
/**
|
|
4153
|
+
* Set or clear the trusted (suspension-exempt) flag. Trusted merchants
|
|
4154
|
+
* cannot be suspended automatically or manually. Does not lift an existing
|
|
4155
|
+
* suspension — use {@link PlatformBilling.unsuspend} for that.
|
|
4156
|
+
*
|
|
4157
|
+
* @param merchantId - The merchant account ID.
|
|
4158
|
+
* @param params - The desired trusted state.
|
|
4159
|
+
* @returns The updated billing profile.
|
|
4160
|
+
*/
|
|
4161
|
+
async setTrusted(merchantId, params) {
|
|
4162
|
+
return this.request("PATCH", `/billing/${encodeURIComponent(merchantId)}/admin/trusted`, {
|
|
4163
|
+
body: params
|
|
4164
|
+
});
|
|
4165
|
+
}
|
|
4013
4166
|
};
|
|
4014
4167
|
|
|
4015
4168
|
// src/internal/resources/platformFees.ts
|
|
4016
4169
|
var PlatformFees = class {
|
|
4017
4170
|
constructor(request) {
|
|
4018
4171
|
this.request = request;
|
|
4172
|
+
this.rules = new PlatformFeeRulesManager(request);
|
|
4019
4173
|
}
|
|
4020
4174
|
/** Create a platform fee schedule for a specific merchant. */
|
|
4021
4175
|
async create(params, merchantId) {
|
|
@@ -4043,6 +4197,31 @@ var PlatformFees = class {
|
|
|
4043
4197
|
return this.request("DELETE", `/admin/fees/${encodeURIComponent(feeId)}`);
|
|
4044
4198
|
}
|
|
4045
4199
|
};
|
|
4200
|
+
var PlatformFeeRulesManager = class {
|
|
4201
|
+
constructor(request) {
|
|
4202
|
+
this.request = request;
|
|
4203
|
+
}
|
|
4204
|
+
/** Create or replace the platform fee-rule program for a merchant. */
|
|
4205
|
+
async upsert(params, merchantId) {
|
|
4206
|
+
const body = { ...params, fee_owner: "platform" };
|
|
4207
|
+
return this.request("PUT", "/admin/fees/rules", {
|
|
4208
|
+
body,
|
|
4209
|
+
query: { merchant_id: merchantId }
|
|
4210
|
+
});
|
|
4211
|
+
}
|
|
4212
|
+
/** Retrieve the active platform fee-rule program for a merchant, or `null`. */
|
|
4213
|
+
async retrieve(merchantId) {
|
|
4214
|
+
return this.request("GET", "/admin/fees/rules", {
|
|
4215
|
+
query: { merchant_id: merchantId }
|
|
4216
|
+
});
|
|
4217
|
+
}
|
|
4218
|
+
/** Deactivate the platform fee-rule program for a merchant. Idempotent. */
|
|
4219
|
+
async delete(merchantId) {
|
|
4220
|
+
await this.request("DELETE", "/admin/fees/rules", {
|
|
4221
|
+
query: { merchant_id: merchantId }
|
|
4222
|
+
});
|
|
4223
|
+
}
|
|
4224
|
+
};
|
|
4046
4225
|
|
|
4047
4226
|
// src/internal/client.ts
|
|
4048
4227
|
var DelopayInternal = class extends Delopay {
|
|
@@ -4086,6 +4265,7 @@ var DelopayInternal = class extends Delopay {
|
|
|
4086
4265
|
DelopayInternal,
|
|
4087
4266
|
Export,
|
|
4088
4267
|
FeatureMatrix,
|
|
4268
|
+
FeeProgramBuilder,
|
|
4089
4269
|
Files,
|
|
4090
4270
|
Forex,
|
|
4091
4271
|
Gsm,
|
|
@@ -4104,6 +4284,7 @@ var DelopayInternal = class extends Delopay {
|
|
|
4104
4284
|
defaultBranding,
|
|
4105
4285
|
encodeBadges,
|
|
4106
4286
|
encodeBranding,
|
|
4287
|
+
feeProgram,
|
|
4107
4288
|
fontStack,
|
|
4108
4289
|
fontWeightValue,
|
|
4109
4290
|
inputPadValue,
|