Back to Plugins

Pesapal Payment Provider

Pesapal payment gateway integration for Medusa v2 with support for M-Pesa, Airtel Money, and East African payment methods


Overview

The medusa-payment-pesapal plugin is a payment provider integration for Medusa v2 that connects to Pesapal’s payment gateway. This plugin enables East African merchants to process payments through M-Pesa, Airtel Money, bank transfers, and card payments.

Key Features

System Requirements

Before installing the plugin, ensure your system meets the following requirements:

Installation

Install the plugin using your preferred package manager:

# Using npm
npm install medusa-payment-pesapal

Configuration

Step 1: Update medusa-config.ts

Add the Pesapal provider to your Medusa configuration file:

import { defineConfig } from '@medusajs/framework/utils'

export default defineConfig({
  modules: [
    {
      resolve: "@medusajs/medusa/payment",
      options: {
        providers: [
          {
            resolve: "medusa-payment-pesapal",
            id: "pesapal",
            options: {
              consumer_key: process.env.PESAPAL_CONSUMER_KEY,
              consumer_secret: process.env.PESAPAL_CONSUMER_SECRET,
              environment: process.env.PESAPAL_ENVIRONMENT || "sandbox",
              currency: process.env.PESAPAL_CURRENCY || "KES",
              merchant_name: process.env.PESAPAL_MERCHANT_NAME,
              ipn_url: process.env.PESAPAL_IPN_URL,
            }
          }
        ]
      }
    }
  ]
})

Step 2: Environment Variables

Configure your .env file with these variables:

PESAPAL_CONSUMER_KEY=your_consumer_key
PESAPAL_CONSUMER_SECRET=your_consumer_secret
PESAPAL_ENVIRONMENT=sandbox
PESAPAL_CURRENCY=KES
PESAPAL_MERCHANT_NAME="Your Business Name"
PESAPAL_IPN_URL=https://yourdomain.com/pesapal/webhook

Step 3: Test Credentials (Sandbox)

For sandbox testing in Kenya, use these credentials:

PESAPAL_CONSUMER_KEY=qkio1BGGYAXTu2JOfm7XSXNruoZsrqEW
PESAPAL_CONSUMER_SECRET=osGQ364R49cXKeOYSpaOnT++rHs=

Admin Configuration

After installation, configure Pesapal through Medusa Admin:

  1. Navigate to the Orders section
  2. Locate the “Pesapal Configuration” widget
  3. Enter your credentials
  4. Test the connection
  5. Enable the provider

API Endpoints

The plugin provides the following endpoints:

Supported Payment Methods

The plugin accepts:

Currency Support

Process transactions in:

Webhook Configuration

For production environments, register your webhook URL in the Pesapal merchant dashboard:

  1. Log into your Pesapal account
  2. Go to Settings → IPN Settings
  3. Set IPN URL to: https://yourdomain.com/store/pesapal/webhook
  4. Select desired notification events

Migration Notes

This plugin is designed specifically for Medusa v2 and uses the newer payment provider architecture, making it incompatible with v1 installations.

Support Resources


Explore More Medusa Plugins

Find more powerful plugins and integrations to enhance your Medusa store. Browse our collection of community-driven solutions.

Free & Open Source
Community Driven
Easy Integration