create_setup_intent
Create a setup intent to securely store payment methods without handling raw card data. Use the returned ID as a nonce to attach a payment method to a customer.
Instructions
Create or retrieve a setup intent via the gateway endpoint. Use only as part of a gateway-agnostic payment method flow: the returned setupIntent.id can be used as paymentMethodNonce for create_customer_payment_method. No raw card data.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| companyGatewayId | Yes | Company gateway ID (required). | |
| customerId | Yes | Customer ID (required). |
Implementation Reference
- The handler function that parses args (companyGatewayId, customerId) and calls gatewayService.createSetupIntent.
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 { companyGatewayId, customerId } = parsed.data; return handleToolCall(() => gatewayService.createSetupIntent(client, String(companyGatewayId), String(customerId)) ); } - Zod schema defining required inputs: companyGatewayId (number) and customerId (number).
const schema = z.object({ companyGatewayId: z.number({ required_error: "companyGatewayId is required" }), customerId: z.number({ required_error: "customerId is required" }), }); - src/tools/gateways/createSetupIntent.ts:37-40 (registration)The Tool export object with definition and handler, used for registration elsewhere.
export const createSetupIntentTool: Tool = { definition, handler, }; - src/tools/gateways/index.ts:17-29 (registration)registerGatewayTools() includes createSetupIntentTool in the list of all gateway tools.
export function registerGatewayTools(): Tool[] { return [ listGlobalGatewaysTool, listGatewaysTool, getGatewayTool, getClientTokenTool, createSetupIntentTool, createGatewayTool, updateGatewayTool, deleteGatewayTool, testGatewayTool, ]; } - The actual service function that makes the GET /gateways/{companyGatewayId}/customers/{customerId}/setup_intent API call.
export async function createSetupIntent( client: Client, companyGatewayId: string, customerId: string ): Promise<unknown> { return client.get<unknown>( `/gateways/${encodeURIComponent(companyGatewayId)}/customers/${encodeURIComponent( customerId )}/setup_intent` ); }