PayGate

Payouts

Send money to mobile money wallets and bank accounts.

Payouts API

The Payouts API allows you to send money to mobile money wallets and bank accounts in Ghana.

The Payout Object

{
  "id": "po_abc123def456",
  "object": "payout",
  "amount": 10000,
  "currency": "GHS",
  "status": "pending",
  "recipient": "rcp_xyz789",
  "description": "Salary payment",
  "failure_code": null,
  "failure_message": null,
  "metadata": {
    "employee_id": "123"
  },
  "created_at": "2024-01-15T10:00:00Z",
  "completed_at": null
}

Attributes

AttributeTypeDescription
idstringUnique identifier
objectstringAlways "payout"
amountintegerAmount in pesewas
currencystringCurrency code (GHS)
statusstringpending, processing, completed, failed
recipientstringRecipient ID
descriptionstringPayout description
failure_codestringError code if failed
failure_messagestringError message if failed
metadataobjectCustom metadata
created_atstringCreation timestamp
completed_atstringCompletion timestamp

Create a Payout

Sends money to a recipient.

POST /v1/payouts

Request Body

ParameterTypeRequiredDescription
amountintegerYesAmount in pesewas
currencystringNoCurrency (default: GHS)
recipientstringYesRecipient ID
descriptionstringNoDescription
metadataobjectNoCustom metadata

You must first create a recipient before sending a payout. See the Recipients API.

curl -X POST https://api.44.200.142.19.nip.io/v1/payouts \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 10000,
    "currency": "GHS",
    "recipient": "rcp_xyz789",
    "description": "Salary payment",
    "metadata": {
      "employee_id": "123"
    }
  }'
const payout = await paygate.payouts.create({
  amount: 10000,
  currency: 'GHS',
  recipient: 'rcp_xyz789',
  description: 'Salary payment',
  metadata: {
    employee_id: '123'
  }
})
payout = client.payouts.create(
    amount=10000,
    currency='GHS',
    recipient='rcp_xyz789',
    description='Salary payment',
    metadata={'employee_id': '123'}
)
$payout = $paygate->payouts->create([
    'amount' => 10000,
    'currency' => 'GHS',
    'recipient' => 'rcp_xyz789',
    'description' => 'Salary payment',
    'metadata' => ['employee_id' => '123']
]);

Response

{
  "id": "po_abc123def456",
  "object": "payout",
  "amount": 10000,
  "currency": "GHS",
  "status": "pending",
  "recipient": "rcp_xyz789",
  "description": "Salary payment",
  "metadata": {
    "employee_id": "123"
  },
  "created_at": "2024-01-15T10:00:00Z"
}

Retrieve a Payout

Retrieves a payout by ID.

GET /v1/payouts/:id
curl https://api.44.200.142.19.nip.io/v1/payouts/po_abc123def456 \
  -H "Authorization: Bearer sk_test_..."
const payout = await paygate.payouts.retrieve('po_abc123def456')
payout = client.payouts.retrieve('po_abc123def456')

Cancel a Payout

Cancels a pending payout.

POST /v1/payouts/:id/cancel

You can only cancel payouts that are in pending status. Once processing begins, the payout cannot be canceled.

curl -X POST https://api.44.200.142.19.nip.io/v1/payouts/po_abc123def456/cancel \
  -H "Authorization: Bearer sk_test_..."
const payout = await paygate.payouts.cancel('po_abc123def456')
payout = client.payouts.cancel('po_abc123def456')

List Payouts

Returns a list of payouts.

GET /v1/payouts

Query Parameters

ParameterTypeDescription
limitintegerNumber of results (1-100)
starting_afterstringCursor for pagination
statusstringFilter by status
recipientstringFilter by recipient ID
created[gte]stringFilter by creation date
created[lte]stringFilter by creation date
curl "https://api.44.200.142.19.nip.io/v1/payouts?status=completed&limit=10" \
  -H "Authorization: Bearer sk_test_..."
const payouts = await paygate.payouts.list({
  status: 'completed',
  limit: 10
})
payouts = client.payouts.list(status='completed', limit=10)

Response

{
  "object": "list",
  "data": [
    {
      "id": "po_abc123def456",
      "object": "payout",
      "amount": 10000,
      "status": "completed",
      ...
    }
  ],
  "has_more": true,
  "url": "/v1/payouts"
}

Payout Statuses

StatusDescription
pendingPayout is queued for processing
processingPayout is being processed
completedPayout was successful
failedPayout failed
canceledPayout was canceled

Error Codes

CodeDescription
insufficient_balanceNot enough balance in your account
invalid_recipientRecipient account is invalid
recipient_unavailableRecipient's account is unavailable
daily_limit_exceededDaily payout limit exceeded
amount_too_smallAmount below minimum (GHS 1.00)
amount_too_largeAmount above maximum

Webhook Events

EventDescription
payout.createdPayout was created
payout.processingPayout is being processed
payout.completedPayout was successful
payout.failedPayout failed
payout.canceledPayout was canceled
app.post('/webhooks', (req, res) => {
  const event = Webhook.constructEvent(req.body, signature, secret)

  switch (event.type) {
    case 'payout.completed':
      const payout = event.data.object
      console.log(`Payout ${payout.id} completed!`)
      break
    case 'payout.failed':
      const failedPayout = event.data.object
      console.log(`Payout failed: ${failedPayout.failure_message}`)
      break
  }

  res.json({ received: true })
})