ifthenpay Payments MCP

Cho phép các tác nhân AI tạo thanh toán, truy xuất lịch sử giao dịch và tương tác với các dịch vụ ifthenpay thông qua MCP.

Tài liệu

ifthenpay MCP — Payments

Technical documentation for the ifthenpay payments MCP server.
Covers the communication protocol, all available methods, each tool's schema, and request/response examples.

Overview

The ifthenpay MCP (Model Context Protocol) server exposes ifthenpay payment APIs as invocable tools for AI agents. It implements the JSON-RPC 2.0 protocol and MCP specification version 2025-03-26.

The server is identified as ifthenpay-mcp v1.0.0 and registers 9 tools covering all ifthenpay payment methods: Multibanco, MB WAY, Payshop, Credit Card, PinPay (Pay by Link), Cofidis Pay, PIX, and payment lookup.

ComponentDetail
ProtocolJSON-RPC 2.0 — Streamable HTTP (POST) + SSE (GET)
MCP version2025-03-26
Server nameifthenpay-mcp
Server version1.0.0

Endpoint

https://ai.ifthenpay.com/mcp/payments/index.php

Two transports are supported simultaneously:

MethodTransportUse case
POSTStreamable HTTP (JSON-RPC)Direct API calls, agents, MCP clients
GETSSE streamClaude desktop and other MCP hosts via url config

POST — Streamable HTTP

Send JSON-RPC 2.0 messages directly. Required header:

Content-Type: application/json

Notifications (messages without id) return HTTP 202 with no body. All other requests return HTTP 200 with a JSON body.

GET — SSE transport

Opens a persistent text/event-stream connection. The server immediately sends an endpoint event with the POST URL, then keeps the stream alive with periodic pings:

event: endpoint
data: "https://ai.ifthenpay.com/mcp/payments/index.php"

: ping

Use this transport when connecting via Claude desktop or any MCP host that supports the url configuration option — no local software required.

Claude desktop configuration

Add the following to claude_desktop_config.json (located at %APPDATA%\Claude\ on Windows or ~/Library/Application Support/Claude/ on macOS):

{
  "mcpServers": {
    "ifthenpay": {
      "url": "https://ai.ifthenpay.com/mcp/payments/index.php"
    }
  }
}

CORS

Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type, Authorization, Mcp-Session-Id
Access-Control-Allow-Methods: GET, POST, OPTIONS

OPTIONS preflight requests receive an immediate HTTP 200 response.

Client Integrations

Any MCP-compatible client can connect using the SSE endpoint. Below are ready-to-use configurations for the most common tools. If authentication is enabled, add "headers": {"Authorization": "Bearer <token>"} to each entry.

Claude Desktop

File: %APPDATA%\Claude\claude_desktop_config.json (Windows) · ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)

Cursor

Global: ~/.cursor/mcp.json · Per project: .cursor/mcp.json

Windsurf

File: ~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "ifthenpay": {
      "serverUrl": "https://ai.ifthenpay.com/mcp/payments/index.php"
    }
  }
}

VS Code — GitHub Copilot

File: .vscode/mcp.json (per project) or via User Settings → MCP.

{
  "servers": {
    "ifthenpay": {
      "type": "sse",
      "url": "https://ai.ifthenpay.com/mcp/payments/index.php"
    }
  }
}

ChatGPT Desktop

File: %APPDATA%\ChatGPT\claude_desktop_config.json (Windows) · ~/Library/Application Support/ChatGPT/claude_desktop_config.json (macOS). Requires ChatGPT desktop app with MCP support enabled.

Continue.dev

File: ~/.continue/config.json (global) · .continue/config.json (per project)

{
  "mcpServers": [
    {
      "name": "ifthenpay",
      "transport": {
        "type": "sse",
        "url": "https://ai.ifthenpay.com/mcp/payments/index.php"
      }
    }
  ]
}

Zed

File: ~/.config/zed/settings.json — add to the context_servers key.

{
  "context_servers": {
    "ifthenpay": {
      "command": {
        "path": "php",
        "args": ["/path/to/mcp/stdio-bridge.php"]
      }
    }
  }
}

Zed currently supports stdio transport only. Download stdio-bridge.php and update the path accordingly.

Gemini (Google AI Studio)

In Google AI Studio, go to Settings → Tools → Add MCP Server and enter the endpoint URL directly:

Native MCP support in Gemini products is evolving — refer to the Google AI documentation for the latest configuration steps.

JSON-RPC 2.0 Protocol

Request format

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "<method>",
  "params": { /* method-specific parameters */ }
}

Success response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": { /* result */ }
}

Error response

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": { "code": -32600, "message": "error description" }
}

Available methods

MethodDescription
initializeInitial handshake — returns protocol version and capabilities
pingHealth check — returns an empty object
tools/listLists all registered tools with their schemas
tools/callExecutes a tool with the provided arguments

Method — initialize

Mandatory handshake to establish the MCP session. Must be the first request.

Request

{
  "jsonrpc": "2.0", "id": 1, "method": "initialize",
  "params": {
    "protocolVersion": "2025-03-26",
    "clientInfo": { "name": "my-client", "version": "1.0.0" }
  }
}

Response

{
  "jsonrpc": "2.0", "id": 1,
  "result": {
    "protocolVersion": "2025-03-26",
    "serverInfo": { "name": "ifthenpay-mcp", "version": "1.0.0" },
    "capabilities": { "tools": {} }
  }
}

Method — ping

Checks that the server is reachable. No parameters required.

// Request
{ "jsonrpc": "2.0", "id": 2, "method": "ping" }

// Response
{ "jsonrpc": "2.0", "id": 2, "result": {} }

Method — tools/list

Returns all registered tools with their name, description, and input schema (JSON Schema Draft 7).

// Request
{ "jsonrpc": "2.0", "id": 3, "method": "tools/list" }

// Response (abbreviated)
{
  "jsonrpc": "2.0", "id": 3,
  "result": {
    "tools": [
      {
        "name": "multibanco_create_reference",
        "description": "Creates a Multibanco payment reference...",
        "inputSchema": { "type": "object", "properties": { /* ... */ } }
      }
      // ... + 8 more tools
    ]
  }
}

Method — tools/call

Executes a tool. The name field identifies the tool; arguments contains the parameters according to the schema.

// Request
{
  "jsonrpc": "2.0", "id": 4, "method": "tools/call",
  "params": {
    "name": "<tool_name>",
    "arguments": { /* tool parameters */ }
  }
}
{
  "jsonrpc": "2.0", "id": 4,
  "result": {
    "content": [{ "type": "text", "text": "{\"entity\":\"11249\",\"reference\":\"123456789\",...}" }],
    "isError": false
  }
}

content[0].text contains a JSON string with the data returned by the ifthenpay API. When isError is true, text contains the error message.

multibanco_create_reference POST

Creates a Multibanco payment reference for payment at any Portuguese ATM or online banking.

Input

FieldTypeReq.Description
mb_keystringRequiredifthenpay Multibanco key
order_idstringRequiredUnique order identifier
amountnumberRequiredAmount in EUR (e.g. 10.50)
expiry_daysintegerOptionalDays until the reference expires; omit for no expiry

Output (content[0].text — JSON)

FieldTypeDescription
entitystringMultibanco entity (5 digits)
referencestringPayment reference (9 digits)
amountstringPayment amount
expiry_datestring|nullExpiry date (YYYYMMDD) or null
request_idstringUnique request identifier

Example

// Request
{
  "jsonrpc": "2.0", "id": 1, "method": "tools/call",
  "params": {
    "name": "multibanco_create_reference",
    "arguments": { "mb_key": "{mb_key}", "order_id": "1001", "amount": 25.00 }
  }
}

// Response
{
  "result": {
    "content": [{ "type": "text", "text": "{\"entity\":\"11249\",\"reference\":\"123456789\",\"amount\":\"25.00\",\"expiry_date\":null,\"request_id\":\"req_abc123\"}" }],
    "isError": false
  }
}

mbway_request_payment POST

Sends a payment request to the customer's phone via the MB WAY app. The customer has 4 minutes to approve.

Input

FieldTypeReq.Description
mbway_keystringRequiredifthenpay MB WAY key
order_idstringRequiredUnique order identifier
amountnumberRequiredAmount in EUR (e.g. 10.50)
phonestringRequiredPhone number in format 351#912345678 (country code#number)
descriptionstringOptionalDescription shown in the MB WAY app

Output

FieldTypeDescription
request_idstringToken for status polling via mbway_check_status
statusstringInitial status — always "pending"
messagestringStatus message

Example

// Request
{
  "jsonrpc": "2.0", "id": 1, "method": "tools/call",
  "params": {
    "name": "mbway_request_payment",
    "arguments": { "mbway_key": "{mbway_key}", "order_id": "912345678", "amount": 15.50, "phone": "351#912345678" }
  }
}

// Response
{
  "result": {
    "content": [{ "type": "text", "text": "{\"request_id\":\"mbw_7f3a1b2c\",\"status\":\"pending\",\"message\":\"Payment request sent\"}" }],
    "isError": false
  }
}

mbway_check_status GET

Checks the status of an MB WAY payment request. Use the request_id returned by mbway_request_payment.

Input

FieldTypeReq.Description
mbway_keystringRequiredifthenpay MB WAY key
request_idstringRequiredRequest ID returned by the payment request

Output

FieldTypeDescription
statusstringpaid | rejectedexpireddeclinedpendingunknown
status_codestringRaw API code: 000=paid, 020=rejected, 101=expired, 122=cancelled
messagestringStatus message
created_atstring|nullCreation timestamp
updated_atstring|nullLast update timestamp

Example

// Request
{
  "jsonrpc": "2.0", "id": 1, "method": "tools/call",
  "params": {
    "name": "mbway_check_status",
    "arguments": { "mbway_key": "{mbway_key}", "request_id": "mbw_7f3a1b2c" }
  }
}

// Response — approved
{
  "result": {
    "content": [{ "type": "text", "text": "{\"status\":\"paid\",\"status_code\":\"000\",\"message\":\"Payment approved\",\"created_at\":\"2026-06-18 10:00:00\",\"updated_at\":\"2026-06-18 10:02:34\"}" }],
    "isError": false
  }
}

payshop_create_reference POST

Generates a Payshop reference for cash payment at over 5,000 agents, CTT post offices, and convenience stores in Portugal.

Input

FieldTypeReq.Description
payshop_keystringRequiredifthenpay Payshop key
order_idstringRequiredUnique order identifier (max 25 chars)
amountnumberRequiredAmount in EUR (e.g. 10.50)
expiry_datestringOptionalExpiry date in YYYYMMDD format; omit for no expiry

Output

FieldTypeDescription
referencestringPayshop reference (13 digits)
request_idstringUnique request identifier
amountstringPayment amount

Example

// Request
{
  "jsonrpc": "2.0", "id": 1, "method": "tools/call",
  "params": {
    "name": "payshop_create_reference",
    "arguments": { "payshop_key": "{payshop_key}", "order_id": "2024001", "amount": 50.00 }
  }
}

// Response
{
  "result": {
    "content": [{ "type": "text", "text": "{\"reference\":\"1234567890123\",\"request_id\":\"ps_req456\",\"amount\":\"50.00\"}" }],
    "isError": false
  }
}

creditcard_create_payment POST

Creates a hosted credit/debit card payment session. Supports Visa and Mastercard.

When invoked through the AI agent, this method is redirected to pinpay_create_payment with selected_method="4". Direct invocation via MCP retains the original behaviour.

Input

FieldTypeReq.Description
ccard_keystringRequiredifthenpay Credit Card key
order_idstringRequiredUnique order identifier (max 15 chars)
amountnumberRequiredAmount in EUR
success_urlstringRequiredURL after successful payment
error_urlstringRequiredURL on payment failure
cancel_urlstringRequiredURL if the customer cancels
languagestringOptionalCheckout language: "pt" or "en"; default: "pt"

Output

FieldTypeDescription
payment_urlstringHosted checkout URL
request_idstringUnique request identifier
amountstringPayment amount

pinpay_create_payment POST

Creates a PinPay (Pay by Link) payment link supporting multiple payment methods. Returns a URL and a PIN code for the customer to access the checkout.

Input

FieldTypeReq.Description
gateway_keystringRequiredifthenpay Gateway key
order_idstringRequiredUnique order identifier (max 15 chars)
amountnumberRequiredAmount (EUR or BRL for PIX)
accountsstringOptionalSemicolon-separated methods in METHOD|KEY format — see table below
selected_methodstringOptionalPre-selects a method: 1=MB, 2=MBWAY, 3=Payshop, 4=Card, 7=Cofidis, 8=PIX. Omit when multiple methods.
otpstringOptionalSingle-use payment: "true" — link expires after one use
expiry_datestringOptionalLink expiry date in YYYYMMDD format
descriptionstringOptionalDescription on the payment page (max 200 chars)
langstringOptionalLanguage: "pt", "en", "es", "fr"
success_urlstringOptionalURL after successful payment
error_urlstringOptionalURL on payment failure
cancel_urlstringOptionalURL if the customer cancels
btn_close_urlstringOptionalURL for the close button on the payment page
btn_close_labelstringOptionalLabel for the close button

Method prefixes for the accounts field

MethodPrefixselected_method
MultibancoMB|{mb_key}1
MB WAYMBWAY|{mbway_key}2
PayshopPAYSHOP|{payshop_key}3
Credit CardCCARD|{ccard_key}4
Cofidis PayCOFIDIS|{cofidis_key}7
PIXPIX|{pix_key}8
Google PayGOOGLE|{google_key}4
Apple PayAPPLE|{apple_key}4

Example with all methods:

"MB|{mb_key};MBWAY|{mbway_key};PAYSHOP|{payshop_key};CCARD|{ccard_key};COFIDIS|{cofidis_key};PIX|{pix_key};GOOGLE|{google_key};APPLE|{apple_key}"

Output

FieldTypeDescription
redirect_urlstringPayment URL to share with the customer
pinpay_urlstring|nullDirect pinpay.pt URL
pin_codestring|nullPIN code to access the checkout
amountstringPayment amount

Example — single-use credit card link

// Request
{
  "jsonrpc": "2.0", "id": 1, "method": "tools/call",
  "params": {
    "name": "pinpay_create_payment",
    "arguments": {
      "gateway_key": "{gateway_key}", "order_id": "CC-001", "amount": 99.99,
      "accounts": "CCARD|{ccard_key}", "selected_method": "4", "otp": "true"
    }
  }
}

// Response
{
  "result": {
    "content": [{ "type": "text", "text": "{\"redirect_url\":\"https://pinpay.pt/pay/a1b2c3\",\"pin_code\":\"123456\",\"amount\":\"99.99\"}" }],
    "isError": false
  }
}

cofidis_create_payment POST

Creates a Cofidis Pay instalment payment. Available mainly in Portugal and Spain.

When invoked through the AI agent, this method is redirected to pinpay_create_payment with accounts="COFIDIS|{cofidis_key}" and selected_method="7".

Input

FieldTypeReq.Description
cofidis_keystringRequiredifthenpay Cofidis Pay key
order_idstringRequiredUnique order identifier (max 15 chars)
amountnumberRequiredAmount in EUR (subject to Cofidis limits)
return_urlstringRequiredReturn URL; the API appends &Success=True on approval
descriptionstringOptionalPayment description or reference
customer_namestringOptionalCustomer full name
customer_emailstringOptionalCustomer email
customer_phonestringOptionalPhone with country code (e.g. +351256245560)

Output

FieldTypeDescription
payment_urlstringCofidis checkout URL
request_idstringUnique request identifier
amountstringPayment amount

pix_create_payment POST

Creates a PIX payment for Brazilian customers. Requires the customer's CPF.

When invoked through the AI agent, this method is redirected to pinpay_create_payment with accounts="PIX|{pix_key}" and selected_method="8".

Input

FieldTypeReq.Description
pix_keystringRequiredifthenpay PIX key
order_idstringRequiredUnique order identifier (max 25 chars)
amountnumberRequiredAmount in BRL (e.g. 50.00)
redirect_urlstringRequiredReturn URL after payment
customer_namestringRequiredCustomer full name (max 150 chars)
customer_cpfstringRequiredCPF — digits only (e.g. 74026594025)
customer_emailstringRequiredCustomer email
customer_phonestringRequiredPhone with country code (e.g. +5585912345678)
descriptionstringOptionalDescription (max 200 chars)
customer_addressstringOptionalAddress
customer_citystringOptionalCity
customer_statestringOptionalState (e.g. CE, SP)
customer_zip_codestringOptionalPostal code

Output

FieldTypeDescription
request_idstringUnique request identifier
payment_urlstringPayment URL
qr_code_valuestring|nullPIX QR code value
amountstringPayment amount

payments_list POST

Lists completed payments via Backoffice Key. Supports filtering by method, dates, order ID, reference, or request ID. Returns up to 1,000 records without filters.

Input

FieldTypeReq.Description
bo_keystringRequiredifthenpay Backoffice key (provided in your contract)
entitystringOptionalMethod filter: MB, MBWAY, PAYSHOP, CCARD, COFIDIS, GOOGLE, APPLE, PIX, or entity number (5 digits). Omit for all.
sub_entitystringOptionalMethod key or sub-entity
order_idstringOptionalFilter by order ID
referencestringOptionalFilter by reference
request_idstringOptionalFilter by request ID
amountstringOptionalFilter by exact amount
date_startstringOptionalStart date: dd-MM-yyyy HH:mm:ss
date_endstringOptionalEnd date: dd-MM-yyyy HH:mm:ss

Output

FieldTypeDescription
countintegerNumber of records returned
paymentsarrayList of payment objects

Example — MB payments from June 2026

// Request
{
  "jsonrpc": "2.0", "id": 1, "method": "tools/call",
  "params": {
    "name": "payments_list",
    "arguments": {
      "bo_key": "{bo_key}", "entity": "MB",
      "date_start": "01-06-2026 00:00:00", "date_end": "30-06-2026 23:59:59"
    }
  }
}

// Response
{
  "result": {
    "content": [{ "type": "text", "text": "{\"count\":2,\"payments\":[{\"order_id\":\"1001\",\"amount\":\"25.00\",\"status\":\"paid\"},{\"order_id\":\"1002\",\"amount\":\"80.00\",\"status\":\"paid\"}]}" }],
    "isError": false
  }
}

Errors

HTTP errors

HTTPCause
405HTTP method not allowed — only POST is accepted

JSON-RPC errors

CodeMeaning
-32700Parse error — invalid JSON
-32600Invalid request — missing required fields
-32601Method not found — unknown method
-32602Invalid params — tool not found or invalid arguments
-32603Internal error — unexpected server error

Tool errors (isError: true)

When a tool fails, the response has isError: true and content[0].text contains the message:

{
  "result": {
    "content": [{ "type": "text", "text": "Invalid key or API error: ..." }],
    "isError": true
  }
}