AI Agent Integration

Enable AI agents to process payments autonomously

Overview

Hedge Payments is purpose-built for the AI economy. Our API is designed from the ground up to work seamlessly with AI agents, chatbots, and autonomous systems, enabling them to handle payment transactions on behalf of users with minimal friction.

✅ Fully Compatible & Tested With

Anthropic

  • • Claude 3.5 Sonnet
  • • Claude Code
  • • Claude API
  • • MCP (Model Context Protocol)

OpenAI

  • • ChatGPT (GPT-4, GPT-4 Turbo)
  • • Custom GPTs & GPT Actions
  • • OpenAI Codex
  • • Function Calling API

Google

  • • Gemini Pro
  • • Gemini Ultra
  • • Function Calling API

Other Platforms

  • • Custom AI agents
  • • LangChain integrations
  • • AutoGPT & AgentGPT
  • • Any REST API-compatible system

Whether you're building with Claude Code for development automation, using ChatGPT for customer service, or deploying autonomous agents with Codex, Hedge Payments provides the payment infrastructure you need.

Claude & Claude Code Integration

Hedge Payments works seamlessly with both Claude Desktop and Claude Code (the CLI for developers). Using the Model Context Protocol (MCP), Claude can create and manage payments directly, making it perfect for AI-assisted development and autonomous payment workflows.

Why Claude Code + Hedge Payments?

  • 💻 Development Automation: Let Claude Code handle payment integrations while you focus on features
  • Instant Testing: Create test payments and verify integrations without leaving your terminal
  • 🔄 Rapid Iteration: Modify payment flows and test changes in seconds
  • 📚 Context Awareness: Claude Code understands your entire codebase and payment requirements

Installation

# Install the Hedge Payments MCP server
npm install -g @hedgepayments/mcp-server

# Configure in your Claude Desktop config
# Location: ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "hedge-payments": {
      "command": "hedge-mcp",
      "args": ["--api-key", "YOUR_API_KEY"]
    }
  }
}

Example Usage

Once configured, you can ask Claude to create payments naturally:

User: "Create a payment request for $50 from john@example.com for a premium subscription"

Claude: "I'll create that payment for you."
[Creates payment using Hedge Payments MCP tool]
"I've created a payment request for $50. Here's the payment link: https://pay.hedgepayments.com/pay_abc123..."

Available MCP Tools

create_payment

Create a new payment request

get_payment

Retrieve payment details and status

cancel_payment

Cancel a pending payment

refund_payment

Process a full or partial refund

check_balance

View current account balance

ChatGPT Integration (Function Calling)

Enable ChatGPT to process payments using OpenAI's function calling feature.

Function Definition

const functions = [
  {
    name: "create_payment",
    description: "Create a payment request for a customer",
    parameters: {
      type: "object",
      properties: {
        amount: {
          type: "number",
          description: "Payment amount"
        },
        currency: {
          type: "string",
          description: "Three-letter currency code (e.g., USD, EUR)"
        },
        customerEmail: {
          type: "string",
          description: "Customer's email address"
        },
        description: {
          type: "string",
          description: "Payment description"
        }
      },
      required: ["amount", "currency", "customerEmail"]
    }
  }
]

// Use in chat completion
const response = await openai.chat.completions.create({
  model: "gpt-4",
  messages: messages,
  functions: functions,
  function_call: "auto"
})

Handling Function Calls

if (response.choices[0].message.function_call) {
  const functionCall = response.choices[0].message.function_call
  const args = JSON.parse(functionCall.arguments)

  if (functionCall.name === "create_payment") {
    // Call Hedge Payments API
    const payment = await hedge.payments.create({
      amount: args.amount,
      currency: args.currency,
      customerEmail: args.customerEmail,
      description: args.description
    })

    // Return result to ChatGPT
    messages.push({
      role: "function",
      name: "create_payment",
      content: JSON.stringify({
        success: true,
        paymentId: payment.id,
        paymentUrl: payment.url
      })
    })

    // Continue conversation with function result
    const secondResponse = await openai.chat.completions.create({
      model: "gpt-4",
      messages: messages
    })
  }
}

OpenAI Codex Integration

OpenAI Codex can interact with the Hedge Payments API just like any other REST API. The straightforward design of our API makes it perfect for code generation and automation with Codex.

Using Codex for Payment Integration

Simply provide Codex with your payment requirements and it will generate the integration code:

Prompt: "Write a function to create a payment using the Hedge Payments API for $50 USD"

async function createPayment() {
  const response = await fetch('https://api.hedgepayments.com/api/payments', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer ' + process.env.HEDGE_API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      amount: 50.00,
      currency: 'USD',
      customerEmail: 'user@example.com',
      description: 'Payment for service'
    })
  })
  return await response.json()
}

Why Codex + Hedge Payments Works Well

  • 🎯 Simple API Design: Clean REST endpoints that Codex understands instantly
  • 📝 Standard HTTP Methods: POST, GET, DELETE - no special protocols
  • 🔑 Bearer Token Auth: Industry-standard authentication pattern
  • 📊 JSON Responses: Predictable, well-structured response format
  • Quick Prototyping: Get payment flows working in minutes

ChatGPT Actions (Custom GPTs)

Create a Custom GPT with Hedge Payments actions to build payment-enabled chatbots.

OpenAPI Schema

Import this OpenAPI schema in your Custom GPT configuration:

openapi: 3.0.0
info:
  title: Hedge Payments API
  version: 1.0.0
servers:
  - url: https://api.hedgepayments.com
paths:
  /api/payments:
    post:
      operationId: createPayment
      summary: Create a payment request
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - amount
                - currency
                - customerEmail
              properties:
                amount:
                  type: number
                currency:
                  type: string
                customerEmail:
                  type: string
                description:
                  type: string
      responses:
        '200':
          description: Payment created successfully
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

🔐 Authentication:
In the Custom GPT authentication settings, select "API Key" and use Bearer authentication with your Hedge Payments API key.

AI Agent Use Cases

💼 Autonomous Sales Agent

An AI agent that handles customer inquiries, recommends products, and processes payments autonomously.

Example: "I'd like to buy the premium plan" → Agent creates payment → Customer completes purchase

🎮 Gaming Assistant

An AI-powered gaming bot that can process in-game purchases and subscriptions.

Example: "Buy 1000 gold coins" → Agent creates $9.99 payment → Purchase confirmed

📧 Email Assistant

An AI that monitors email for payment requests and automatically generates payment links.

Example: Customer emails "Send me an invoice for $500" → Agent creates payment link and replies

🏦 Financial Advisor Bot

An AI that helps users manage subscriptions, process refunds, and track payment history.

Example: "Cancel my subscription and refund last month" → Agent processes refund automatically

Best Practices for AI Integration

  • 🔒 Secure API Keys:
    Never expose API keys in client-side code. Use server-side proxies or JWT tokens.
  • ✅ User Confirmation:
    Always confirm payment details with the user before processing transactions.
  • 💬 Clear Communication:
    Provide clear payment summaries including amount, currency, and description before creating payments.
  • 🔔 Error Handling:
    Gracefully handle API errors and provide helpful messages to users.
  • 📊 Logging:
    Log all payment transactions with metadata for auditing and troubleshooting.
  • 🔄 Webhook Integration:
    Use webhooks to receive real-time payment status updates and keep your AI agent in sync.

Example Conversation Flow

Here's how a typical payment conversation might flow with an AI agent:

User: "I'd like to purchase the premium subscription"

Agent: "Great! The premium subscription is $29.99/month. This includes unlimited access, priority support, and advanced features. Would you like to proceed with this purchase?"

User: "Yes, please"

Agent: "Perfect! I've created a payment link for you. The payment details are:"

  • Amount: $29.99 USD
  • Description: Premium Subscription - Monthly
  • Payment methods: Crypto or Credit Card

Click here to complete your payment: pay.hedgepayments.com/pay_abc123

[User completes payment]

Agent: "Thank you! Your payment has been received successfully. Your premium subscription is now active. You'll receive a confirmation email shortly. Is there anything else I can help you with?"