get_customer_payment_method
Retrieve a specific payment method for a customer by providing the customer ID and payment method ID.
Instructions
Get a single payment method by ID. GET /customers/{customerId}/paymentmethods/{paymentMethodId}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customerId | Yes | Customer ID (required) | |
| paymentMethodId | Yes | Payment method ID (required) |
Implementation Reference
- Handler function that validates inputs with Zod schema, then calls customerService.getCustomerPaymentMethod to fetch a payment method by customer ID and payment method ID.
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, paymentMethodId } = parsed.data; return handleToolCall(() => customerService.getCustomerPaymentMethod(client, customerId, paymentMethodId) ); } - Zod schema defining required inputs: customerId (string) and paymentMethodId (string).
const schema = z.object({ customerId: z.string().min(1, "customerId is required"), paymentMethodId: z.string().min(1, "paymentMethodId is required"), }); - src/tools/customers/getCustomerPaymentMethod.ts:12-24 (registration)Tool definition including name 'get_customer_payment_method', description, and JSON Schema input format.
const definition = { name: "get_customer_payment_method", description: "Get a single payment method by ID. GET /customers/{customerId}/paymentmethods/{paymentMethodId}.", inputSchema: { type: "object" as const, properties: { customerId: { type: "string", description: "Customer ID (required)" }, paymentMethodId: { type: "string", description: "Payment method ID (required)" }, }, required: ["customerId", "paymentMethodId"], }, }; - src/tools/customers/getCustomerPaymentMethod.ts:37-40 (registration)Export of the Tool object combining definition and handler, registered in the customer tools index.
export const getCustomerPaymentMethodTool: Tool = { definition, handler, }; - Service function that makes the actual GET /customers/{customerId}/paymentmethods/{paymentMethodId} API call.
export async function getCustomerPaymentMethod( client: Client, customerId: string, paymentMethodId: string ): Promise<CustomerPaymentMethod> { return client.get<CustomerPaymentMethod>( `/customers/${customerId}/paymentmethods/${paymentMethodId}` ); }