delete_customer_charge_credit
Delete a charge or credit from a customer account. Requires customer ID and charge/credit ID; fails if linked to an invoice.
Instructions
Delete a charge or credit for a customer. DELETE /customers/{customerId}/charges_credits/{chargeCreditId}. Fails if the charge/credit has invoice details assigned.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customerId | Yes | Customer ID (required) | |
| chargeCreditId | Yes | Charge/credit ID (required) |
Implementation Reference
- The handler function for delete_customer_charge_credit tool. Parses input args (customerId, chargeCreditId) via Zod, then delegates to customerService.deleteCustomerChargeCredit().
async function handler(client: Client, args: Record<string, unknown> | undefined) { const parsed = schema.safeParse(args); if (!parsed.success) { return errorResult(parsed.error.errors.map((e) => e.message).join("; ")); } const { customerId, chargeCreditId } = parsed.data; return handleToolCall(() => customerService.deleteCustomerChargeCredit(client, customerId, chargeCreditId) ); } - Zod schema validating customerId (string, min 1) and chargeCreditId (string, min 1).
const schema = z.object({ customerId: z.string().min(1, "customerId is required"), chargeCreditId: z.string().min(1, "chargeCreditId is required"), }); - src/tools/customers/deleteCustomerChargeCredit.ts:12-24 (registration)Tool definition/registration with name 'delete_customer_charge_credit', description, and JSON input schema (customerId + chargeCreditId both required).
const definition = { name: "delete_customer_charge_credit", description: "Delete a charge or credit for a customer. DELETE /customers/{customerId}/charges_credits/{chargeCreditId}. Fails if the charge/credit has invoice details assigned.", inputSchema: { type: "object" as const, properties: { customerId: { type: "string", description: "Customer ID (required)" }, chargeCreditId: { type: "string", description: "Charge/credit ID (required)" }, }, required: ["customerId", "chargeCreditId"], }, }; - src/tools/customers/index.ts:54-54 (registration)Tool registered in the customer tools collection via registerCustomerTools() returning the deleteCustomerChargeCreditTool.
deleteCustomerChargeCreditTool, - Service helper that makes the DELETE API call to /customers/{customerId}/charges_credits/{chargeCreditId} via the HTTP client.
export async function deleteCustomerChargeCredit( client: Client, customerId: string, chargeCreditId: string ): Promise<Record<string, unknown>> { const result = await client.delete<Record<string, unknown>>( `/customers/${customerId}/charges_credits/${chargeCreditId}` ); return Object.keys(result ?? {}).length ? result : { success: true, message: "Charge/credit deleted" }; }