Momo Suite
  • Introduction
  • Getting Started
  • Basic Concepts
  • Providers (Hubtel)
    • Korba
    • PayStack
    • ITC
  • Dashboard (Overview)
    • Transaction Detail Page
      • Status Check for Pending Transactions
      • Manual Status Update (Admin Only)
      • Transaction Timeline
      • Technical Details
  • User Management
  • Transaction Status Update Notifications
Powered by GitBook
On this page
  1. Providers (Hubtel)

PayStack

  1. Add the following variables to your .env file:

PAYSTACK_SECRET_KEY=your-secret-key
PAYSTACK_PUBLIC_KEY=your-public-key
PAYSTACK_BASE_URL=https://api.paystack.co
  1. The configuration is loaded from config/momo-suite.php:

'paystack' => [
    'secret_key' => env('PAYSTACK_SECRET_KEY'),
    'public_key' => env('PAYSTACK_PUBLIC_KEY'),
    'base_url' => env('PAYSTACK_BASE_URL', 'https://api.paystack.co'),
],

Receiving Money

To receive money using Paystack:

use Rais\MomoSuite\Facades\Momo;

// Using Facade
$result = Momo::setProvider('paystack')
    ->receive([
        'phone' => '0551234987',
        'amount' => 3.00,  // Note: Paystack has minimum amount requirements
        'email' => 'customer@example.com',  // Required for Paystack
        'network' => 'MTN',
        'reference' => 'Test Payment',
    ]);

// Using Service Container
$momo = app('momo-suite');
$momo->setProvider('paystack');
$result = $momo->receive([
    'phone' => '0551234987',
    'amount' => 3.00,
    'email' => 'customer@example.com',
    'network' => 'MTN',
    'reference' => 'Test Payment',
]);


// for otp verifcaition
$momo = app('momo-suite');
$momo->setProvider('paystack');

// Test sending money with Paystack
$otp = $momo->verifyOtp([
    'otp' => $otp, // Recipient's phone number
    'reference' => $reference,
]);

// Required Parameters:
// - phone: Customer's phone number
// - amount: Transaction amount (minimum amount applies)
// - email: Customer's email address (Paystack specific requirement)
// - network: Mobile network (MTN, VODAFONE, AIRTELTIGO)
// - reference: Your transaction reference

Sending Money

To send money using Paystack:

use Rais\MomoSuite\Facades\Momo;

$result = Momo::setProvider('paystack')
    ->send([
        'phone' => '0240328274',
        'amount' => 1.00,
        'email' => 'customer@example.com',  // Required for Paystack
        'network' => 'MTN',
        'reference' => 'Test Disbursement',
    ]);

// Required Parameters:
// - phone: Recipient's phone number
// - amount: Amount to send
// - email: Recipient's email address
// - network: Mobile network (MTN, VODAFONE, AIRTELTIGO)
// - reference: Your transaction reference

Webhook Handling

Paystack sends webhook notifications for transaction updates. Configure your webhook URL in your Paystack dashboard.

1. Set up your webhook URL in Paystack Dashboard:
   - Log in to your Paystack Dashboard
   - Go to Settings → API Keys & Webhooks
   - Add webhook URL: `https://your-domain.com/momo/webhooks/paystack`

2. The package automatically handles webhooks at:

POST /momo/webhooks/paystack

Example webhook payload:

{
    "event": "charge.success",
    "data": {
        "id": "pst-xxx-xxx",
        "reference": "your-reference",
        "amount": 300, // Amount in pesewas
        "status": "success",
        "channel": "mobile_money",
        "currency": "GHS",
        "paid_at": "2025-04-24T21:40:12.000Z",
        "customer": {
            "email": "customer@example.com",
            "phone": "0551234987"
        }
    }
}

Important Notes

1. Email Requirement
   - Paystack requires an email address for all transactions
   - This is used for transaction notifications and receipts

2. Amount Formatting
   - Amounts are in Ghana Cedis (GHS)
   - Minimum amount requirements apply
   - Paystack internally converts to pesewas (multiply by 100)

3. Transaction References
   - Must be unique per transaction
   - Can be used to prevent duplicate transactions

4. Testing
   - Use test API keys for development
   - Test mobile money numbers available in Paystack documentation

5. Mobile Money OTP for First-Time Users
   - When receiving money from a first-time mobile money user,
an OTP (One-Time Password) is sent to the customer's phone.

   - You must collect:

      - The OTP

      - The transaction reference

  - Then call the OTP validation endpoint to verify the transaction.

  - Once validated, prompt the customer to complete the payment.
  
  Example
  // for otp verifcaition
   $momo = app('momo-suite');
   $momo->setProvider('paystack');
   
   // Test sending money with Paystack
   $otp = $momo->verifyOtp([
       'otp' => $otp, // Recipient's phone number
       'reference' => $reference,
   ]);

6. Subsequent Transactions
   - For returning users on the same mobile number, OTP validation may not be required.

   - Paystack may automatically recognize the customer and bypass the OTP step, allowing faster payment processing.
PreviousKorbaNextITC

Last updated 1 month ago