Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.payx.company/llms.txt

Use this file to discover all available pages before exploring further.

In this guide, we’ll walk through how to initiate your first Mobile Money charge using the PayX Node.js SDK.

1. Get your API Keys

Log in to your PayX Dashboard and navigate to the Developer Settings tab. Copy your Test Secret Key.

2. Install the SDK

In your Node.js project, install the payx-node package:
npm install payx-node@latest

3. Initialize the Client

Create a new file and initialize the PayX client with your API key.
const { PayX } = require('payx-node');

const payx = new PayX({
  apiKey: 'your_test_secret_key_here'
});

4. Initiate a Charge

Use the charge.create method to request a payment from a customer.
async function startPayment() {
  try {
    const response = await payx.charge.create({
      amount: 10.0,
      currency: 'GHS',
      phoneNumber: '0551234987',
      network: 'MTN',
      payerMessage: 'Order #1001',
      payeeNote: 'Online Purchase'
    });

    console.log('Transaction Initiated!');
    console.log('Transaction ID:', response.transactionId);
  } catch (error) {
    console.error('Payment failed:', error.message);
  }
}

startPayment();

5. Handle the Response

Since Mobile Money transactions require user approval on their phone (USSD prompt), the initial status will be PENDING. You should set up a Webhook to receive real-time updates when the payment is completed or failed.

Next Steps

API Reference

Explore all available endpoints and parameters.

Webhooks

Learn how to receive real-time notifications.