PayGate

Quick Start

Get up and running with PayGate in under 5 minutes.

Quick Start

This guide will help you integrate PayGate and create your first payment in under 5 minutes.

Prerequisites

Before you begin, make sure you have:

  • A PayGate account (Sign up here)
  • Your API keys from the Dashboard
  • Node.js 18+ (or your preferred language)

Installation

npm install @paygate/node
pip install paygate-python
composer require paygate/paygate-php
go get github.com/paygate/paygate-go

Create Your First Payment

Initialize the SDK

Configure the SDK with your secret API key:

import PayGate from '@paygate/node'

const paygate = new PayGate('sk_test_...')
import paygate

client = paygate.Client('sk_test_...')
<?php
require 'vendor/autoload.php';

$paygate = new \PayGate\PayGate('sk_test_...');
import "github.com/paygate/paygate-go"

client := paygate.New("sk_test_...")

Create a Payment

Create a mobile money payment request:

const payment = await paygate.payments.create({
  amount: 5000, // Amount in pesewas (GHS 50.00)
  currency: 'GHS',
  payment_method: 'mobile_money',
  provider: 'mtn',
  phone: '0241234567',
  description: 'Order #1234',
  metadata: {
    order_id: '1234',
    customer_email: 'customer@example.com'
  }
})

console.log(payment.id) // pay_abc123...
console.log(payment.status) // pending
payment = client.payments.create(
    amount=5000,
    currency='GHS',
    payment_method='mobile_money',
    provider='mtn',
    phone='0241234567',
    description='Order #1234',
    metadata={
        'order_id': '1234',
        'customer_email': 'customer@example.com'
    }
)

print(payment.id)  # pay_abc123...
print(payment.status)  # pending
$payment = $paygate->payments->create([
    'amount' => 5000,
    'currency' => 'GHS',
    'payment_method' => 'mobile_money',
    'provider' => 'mtn',
    'phone' => '0241234567',
    'description' => 'Order #1234',
    'metadata' => [
        'order_id' => '1234',
        'customer_email' => 'customer@example.com'
    ]
]);

echo $payment->id; // pay_abc123...
echo $payment->status; // pending
payment, err := client.Payments.Create(&paygate.PaymentParams{
    Amount:        5000,
    Currency:      "GHS",
    PaymentMethod: "mobile_money",
    Provider:      "mtn",
    Phone:         "0241234567",
    Description:   "Order #1234",
    Metadata: map[string]string{
        "order_id":       "1234",
        "customer_email": "customer@example.com",
    },
})

fmt.Println(payment.ID)     // pay_abc123...
fmt.Println(payment.Status) // pending

Handle the Payment

The customer will receive a prompt on their phone to authorize the payment. You can:

  1. Poll for status - Check the payment status periodically
  2. Use webhooks - Receive real-time notifications (recommended)
// Option 1: Poll for status
const updatedPayment = await paygate.payments.retrieve(payment.id)
console.log(updatedPayment.status) // succeeded, failed, or pending

// Option 2: Set up webhooks (see Webhooks guide)

Test Your Integration

Use test API keys (sk_test_...) during development. No real money is moved in test mode.

Test Phone Numbers

Phone NumberBehavior
0241234567Always succeeds
0241234568Always fails (insufficient funds)
0241234569Always fails (timeout)

Test Amounts

Amount (pesewas)Behavior
Any amountSucceeds normally
99999999Fails (amount too large)

What's Next?

Now that you've created your first payment, explore more features: