@delopay/sdk 0.35.1 → 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 +208 -1
- package/dist/index.d.ts +208 -1
- package/dist/index.js +5 -1
- package/dist/internal.cjs +139 -0
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +24 -3
- package/dist/internal.d.ts +24 -3
- package/dist/internal.js +31 -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",
|
|
@@ -4058,6 +4169,7 @@ var PlatformBilling = class {
|
|
|
4058
4169
|
var PlatformFees = class {
|
|
4059
4170
|
constructor(request) {
|
|
4060
4171
|
this.request = request;
|
|
4172
|
+
this.rules = new PlatformFeeRulesManager(request);
|
|
4061
4173
|
}
|
|
4062
4174
|
/** Create a platform fee schedule for a specific merchant. */
|
|
4063
4175
|
async create(params, merchantId) {
|
|
@@ -4085,6 +4197,31 @@ var PlatformFees = class {
|
|
|
4085
4197
|
return this.request("DELETE", `/admin/fees/${encodeURIComponent(feeId)}`);
|
|
4086
4198
|
}
|
|
4087
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
|
+
};
|
|
4088
4225
|
|
|
4089
4226
|
// src/internal/client.ts
|
|
4090
4227
|
var DelopayInternal = class extends Delopay {
|
|
@@ -4128,6 +4265,7 @@ var DelopayInternal = class extends Delopay {
|
|
|
4128
4265
|
DelopayInternal,
|
|
4129
4266
|
Export,
|
|
4130
4267
|
FeatureMatrix,
|
|
4268
|
+
FeeProgramBuilder,
|
|
4131
4269
|
Files,
|
|
4132
4270
|
Forex,
|
|
4133
4271
|
Gsm,
|
|
@@ -4146,6 +4284,7 @@ var DelopayInternal = class extends Delopay {
|
|
|
4146
4284
|
defaultBranding,
|
|
4147
4285
|
encodeBadges,
|
|
4148
4286
|
encodeBranding,
|
|
4287
|
+
feeProgram,
|
|
4149
4288
|
fontStack,
|
|
4150
4289
|
fontWeightValue,
|
|
4151
4290
|
inputPadValue,
|