You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Create one or more commissions (custom, lead or sale) for a partner. Commission creation is processed asynchronously. Use the List Commissions endpoint or webhooks to be notified when the commission is created.",
13
+
"Create one or more commissions (custom, lead or sale) for a partner. Custom commissions accept a negative `amount` to create a clawback; in that case `description` is required and may be a known clawback reason or any other string. Commission creation is processed asynchronously. Use the List Commissions endpoint or webhooks to be notified when the commission is created.",
.describe("The ID of the partner to create the commission for."),
470
461
amount: centsSchema
471
-
.pipe(z.number().min(1))
472
-
.describe("The commission amount in cents."),
462
+
.pipe(
463
+
z.number().refine((n)=>n!==0,{
464
+
message: "Amount cannot be 0.",
465
+
}),
466
+
)
467
+
.describe(
468
+
"The commission amount in cents. Use a negative amount to create a clawback.",
469
+
),
473
470
date: parseDateSchema
474
471
.nullish()
475
472
.describe("If not provided, the current date will be used."),
476
473
description: z
477
474
.string()
478
475
.max(190)
479
476
.nullish()
480
-
.describe("The description of the commission."),
477
+
.describe(
478
+
"The description of the commission. Required for clawbacks (negative `amount`). May be a known clawback reason (`order_canceled`, `fraud`, `terms_violation`, `tracking_error`, `payment_failed`, `ineligible_partner`, `duplicate_commission`, `other`) or any other string.",
479
+
),
481
480
}),
482
481
483
482
// Lead commission
@@ -573,15 +572,40 @@ export const createManualCommissionBodySchema = z
573
572
}),
574
573
])
575
574
.superRefine((data,ctx)=>{
576
-
if(data.type!=="sale")return;
575
+
if(data.type==="custom"){
576
+
if(data.amount<0&&!data.description?.trim()){
577
+
ctx.addIssue({
578
+
code: z.ZodIssueCode.custom,
579
+
message:
580
+
"`description` is required when creating a clawback (negative amount).",
581
+
path: ["description"],
582
+
});
583
+
}
584
+
return;
585
+
}
586
+
587
+
if(data.type==="sale"){
588
+
if(data.importStripeInvoices){
589
+
return;
590
+
}
591
+
592
+
if(data.saleAmount==null){
593
+
ctx.addIssue({
594
+
code: z.ZodIssueCode.custom,
595
+
message:
596
+
"`saleAmount` is required when `importStripeInvoices` is false.",
0 commit comments