What is PayLink?

PayLink is an open-source framework designed to simplify payment integrations for AI agents by leveraging the Model Context Protocol (MCP). It provides a standardized interface for various payment providers, including M-Pesa and Airtel, enabling seamless integration of payment functionalities into your AI applications.

How It Works

PayLink SDK connects to a PayLink MCP server via Server-Sent Events (SSE), allowing your application to:
  1. Discover available payment tools on the server
  2. Call payment tools with appropriate arguments
  3. Process payment results from the tools
The SDK handles all the communication details, so you can focus on integrating payment functionality into your application. Before using the PayLink SDK, you need to complete the following setup steps:
  1. Create a PayLink Account: Sign up for a PayLink account to obtain your API key
  2. Configure Payment Providers: Set up the payment providers you want to use
  3. Add Payment Provider Keys: Configure the necessary credentials for each provider

Required Configuration

When initializing the PayLink SDK, you’ll need to provide the following:
  • PayLink API Key: Your unique API key from your PayLink account
  • PayLink Project: Your project identifier
  • Payment Providers: List of payment providers you want to use
  • Provider-specific Keys: Credentials for each payment provider
You can provide these values directly when initializing the client or through environment variables:
# Example .env file configuration
PAYLINK_API_KEY=your_api_key_here
PAYLINK_PROJECT=your_project_id
PAYLINK_TRACING=enabled  # Optional for debugging
PAYMENT_PROVIDER=["mpesa"]  # JSON array of providers

# M-Pesa specific settings (if using M-Pesa)
MPESA_BUSINESS_SHORTCODE=your_shortcode
MPESA_CONSUMER_SECRET=your_consumer_secret
MPESA_CONSUMER_KEY=your_consumer_key
MPESA_CALLBACK_URL=your_callback_url
MPESA_PASSKEY=your_passkey
MPESA_BASE_URL=your_base_url

Architecture Overview

The PayLink ecosystem consists of three main components:
  1. PayLink Server: Hosts payment tools and connects to payment providers
  2. PayLink SDK: Client libraries for connecting to the server
  3. Payment Providers: External services like M-Pesa, Airtel, etc.

Available SDK Clients

Framework Integrations

PayLink SDK provides specialized adapters for popular AI frameworks, making it easy to integrate payment functionality into AI-driven applications:
  • OpenAI Compatible: Use PayLink with OpenAI’s function-calling API to enable AI agents to process payments.
  • LangChain Compatible: Integrate PayLink with LangChain agents for building payment-enabled AI workflows.

Getting Started

To start using the PayLink SDK, you’ll need to:
  1. Create a PayLink Account to obtain your API key
  2. Configure Payment Providers in your PayLink dashboard
  3. Set up Provider Credentials for your chosen payment methods
For detailed setup instructions and code examples, see our Quickstart Guide.

Next Steps