Skip to main content
Glama

create_payment

Create a new payment in GoCardless by specifying amount, currency, and mandate ID. This tool processes payments through the GoCardless MCP Server for managing payment data.

Instructions

Create a new payment in GoCardless

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesAmount in minor currency unit (e.g., 1000 for £10.00)
currencyYesISO 4217 currency code (e.g., GBP, EUR)
mandate_idYesID of the mandate to use for this payment
descriptionNoPayment description

Implementation Reference

  • Handler for the create_payment tool. Constructs payment parameters from arguments and calls client.payments.create to execute the payment creation.
    elif name == "create_payment":
        params = {
            "amount": arguments["amount"],
            "currency": arguments["currency"],
            "links": {"mandate": arguments["mandate_id"]},
        }
        if "description" in arguments:
            params["description"] = arguments["description"]
    
        payment = client.payments.create(params=params)
        return [
            types.TextContent(
                type="text",
                text=f"Payment created successfully:\n{_format_json({'id': payment.id, 'amount': payment.amount, 'currency': payment.currency, 'status': payment.status})}",
            )
        ]
  • Registration of the create_payment tool in the list_tools handler, including name, description, and input schema definition.
    types.Tool(
        name="create_payment",
        description="Create a new payment in GoCardless",
        inputSchema={
            "type": "object",
            "properties": {
                "amount": {
                    "type": "integer",
                    "description": "Amount in minor currency unit (e.g., 1000 for £10.00)",
                },
                "currency": {
                    "type": "string",
                    "description": "ISO 4217 currency code (e.g., GBP, EUR)",
                },
                "mandate_id": {
                    "type": "string",
                    "description": "ID of the mandate to use for this payment",
                },
                "description": {
                    "type": "string",
                    "description": "Payment description",
                },
            },
            "required": ["amount", "currency", "mandate_id"],
        },
    ),
  • Input schema definition for the create_payment tool, specifying required parameters and types.
    inputSchema={
        "type": "object",
        "properties": {
            "amount": {
                "type": "integer",
                "description": "Amount in minor currency unit (e.g., 1000 for £10.00)",
            },
            "currency": {
                "type": "string",
                "description": "ISO 4217 currency code (e.g., GBP, EUR)",
            },
            "mandate_id": {
                "type": "string",
                "description": "ID of the mandate to use for this payment",
            },
            "description": {
                "type": "string",
                "description": "Payment description",
            },
        },
        "required": ["amount", "currency", "mandate_id"],
    },
  • Helper function get_client() used by all tools including create_payment to initialize the GoCardless API client.
    def get_client() -> gocardless_pro.Client:
        """Initialize and return GoCardless client."""
        access_token = os.environ.get("GOCARDLESS_ACCESS_TOKEN")
        if not access_token:
            raise ValueError("GOCARDLESS_ACCESS_TOKEN environment variable is required")
    
        environment = os.environ.get("GOCARDLESS_ENVIRONMENT", "sandbox")
        return gocardless_pro.Client(access_token=access_token, environment=environment)

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/jmceleney/gocardless-mcp'

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