Skip to main content
Glama

update_customer_payment_method

Update a payment method's billing address by providing customer ID, payment method ID, and required address fields (country, street, city, state, zip) plus optional street2.

Instructions

Update a payment method's billing address (gateway-agnostic). PUT /customers/{customerId}/paymentmethods/{paymentMethodId}. Required: customerId, paymentMethodId, billingAddress (countryCode, street1, city, state, zip). Optional: street2. No payment or gateway-specific fields.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customerIdYesCustomer ID (required)
paymentMethodIdYesPayment method ID (required)
billingAddressYesBilling address (required): countryCode, street1, city, state, zip; street2 optional

Implementation Reference

  • Handler function that validates inputs via Zod schema, maps billing address (resolving countryCode to countryId), and calls the service layer to update the payment method.
    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.path.join(".")}: ${e.message}`).join("; "));
      }
      const { customerId, paymentMethodId, billingAddress } = parsed.data;
      const apiBillingAddress = await mapBillingAddressInputToApiBillingAddress(client, billingAddress);
      return handleToolCall(() =>
        customerService.updateCustomerPaymentMethod(client, customerId, paymentMethodId, {
          billingAddress: apiBillingAddress,
        })
      );
    }
  • Zod validation schema for the tool: requires customerId, paymentMethodId, and billingAddress (with countryCode, street1, city, state, zip, optional street2).
    const schema = z.object({
      customerId: z.string().min(1, "customerId is required"),
      paymentMethodId: z.string().min(1, "paymentMethodId is required"),
      billingAddress: billingAddressSchema,
    });
  • Tool definition including the name 'update_customer_payment_method', description, and JSON Schema input definition for MCP.
    const definition = {
      name: "update_customer_payment_method",
      description:
        "Update a payment method's billing address (gateway-agnostic). PUT /customers/{customerId}/paymentmethods/{paymentMethodId}. Required: customerId, paymentMethodId, billingAddress (countryCode, street1, city, state, zip). Optional: street2. No payment or gateway-specific fields.",
      inputSchema: {
        type: "object" as const,
        properties: {
          customerId: { type: "string", description: "Customer ID (required)" },
          paymentMethodId: { type: "string", description: "Payment method ID (required)" },
          billingAddress: {
            type: "object",
            description: "Billing address (required): countryCode, street1, city, state, zip; street2 optional",
            properties: {
              countryCode: { type: "string", description: COUNTRY_CODE_DESCRIPTION_CONST },
              street1: { type: "string", description: "Street line 1 (required)" },
              city: { type: "string", description: "City (required)" },
              state: { type: "string", description: "State (required)" },
              zip: { type: "string", description: "Postal code (required)" },
              street2: { type: "string", description: "Street line 2" },
            },
            required: ["countryCode", "street1", "city", "state", "zip"],
          },
        },
        required: ["customerId", "paymentMethodId", "billingAddress"],
      },
    };
  • The tool is registered in the customer tools array, returned by registerCustomerTools().
    export function registerCustomerTools(): Tool[] {
      return [
        listCustomersTool,
        getCustomerTool,
        createCustomerTool,
        updateCustomerTool,
        deleteCustomerTool,
        getCustomerInvoicesTool,
        getCustomerUnpaidInvoicesTool,
        getCustomerSubscriptionsTool,
        getCustomerLogsTool,
        listCustomerAddressesTool,
        getCustomerAddressTool,
        createCustomerAddressTool,
        updateCustomerAddressTool,
        deleteCustomerAddressTool,
        listCustomerPaymentMethodsTool,
        getCustomerPaymentMethodTool,
        createCustomerPaymentMethodTool,
        updateCustomerPaymentMethodTool,
        deleteCustomerPaymentMethodTool,
        listCustomerChargesCreditsTool,
        createCustomerChargeCreditTool,
        deleteCustomerChargeCreditTool,
      ];
    }
  • Service function that makes the PUT /customers/{customerId}/paymentmethods/{paymentMethodId} API call with the billing address payload.
    export async function updateCustomerPaymentMethod(
      client: Client,
      customerId: string,
      paymentMethodId: string,
      body: UpdateCustomerPaymentMethodBody
    ): Promise<CustomerPaymentMethod> {
      return client.put<CustomerPaymentMethod>(
        `/customers/${customerId}/paymentmethods/${paymentMethodId}`,
        { billingAddress: body.billingAddress }
      );
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full behavioral burden. It states the HTTP method and required fields but does not disclose side effects (e.g., validation triggers, impact on subscriptions), authentication needs, or rate limits. The description is adequate but lacks deeper behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise: two sentences. The first sentence states purpose and scope, the second lists required/optional fields. Every sentence adds value with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description is complete enough for a simple update operation. It covers the what, how, and constraints. It could mention return value or confirmation, but for a billing address update, a simple success/failure is implied. The tool fits well among many CRUD sibling tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description adds the HTTP path and 'No payment or gateway-specific fields', which provides some extra context beyond the schema. However, it does not significantly enhance parameter meaning. Score remains at 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Update a payment method's billing address', identifies the resource, and specifies 'gateway-agnostic'. It distinguishes itself from siblings like create/delete by explicitly focusing on billing address update and showing the HTTP path.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description lists required and optional parameters and notes 'No payment or gateway-specific fields', guiding on what not to include. It could be more explicit about when to use this vs. other payment method operations (e.g., not for changing card number), but the context is clear enough.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rhinosaas/rebillia-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server