Skip to main content
GET
/
api
/
v1
/
payments
/
{payment_id}
Get Payment
curl --request GET \
  --url https://api.example.com/api/v1/payments/{payment_id}
{
  "payment_id": 123,
  "transaction_id": {},
  "status": "<string>",
  "amount": 123,
  "currency": "<string>",
  "created_at": "<string>"
}

Overview

Retrieves the current status and details of a payment. Use this endpoint to check if a payment has been completed after initiating a mobile checkout.

Path Parameters

payment_id
integer
required
The unique identifier of the payment to retrieve

Response

payment_id
integer
Unique identifier for the payment record
transaction_id
string | null
External transaction ID from Africa’s Talking payment gateway (null if not yet assigned)
status
string
Current payment status:
  • PENDING - Payment initiated, awaiting user confirmation
  • LOCKED - Payment completed and locked in escrow
  • RELEASED - Payment released to recipient
  • REFUNDED - Payment refunded to payer
  • FAILED - Payment failed or was cancelled
amount
float
Payment amount
currency
string
Currency code (e.g., “KES” for Kenya Shillings)
created_at
string
ISO 8601 timestamp of when the payment was created

Example Request

curl -X GET https://api.voicepact.com/api/v1/payments/42 \
  -H "Content-Type: application/json"

Example Response

{
  "payment_id": 42,
  "transaction_id": "ATXid_sample123456789",
  "status": "LOCKED",
  "amount": 5000.0,
  "currency": "KES",
  "created_at": "2026-03-06T10:30:00.000000"
}

Error Responses

Payment Not Found (404)

{
  "detail": "Payment not found"
}

Server Error (500)

{
  "detail": "Failed to retrieve payment"
}

Payment Status Lifecycle

  1. PENDING - Initial state after checkout initiated
  2. LOCKED - Payment successful and held in escrow
  3. FAILED - Payment failed or cancelled by user
  4. RELEASED - Funds released to service provider (terminal state)
  5. REFUNDED - Funds returned to payer (terminal state)

Use Cases

Polling for Payment Completion

After initiating a checkout, poll this endpoint to check when the payment is completed:
const checkPaymentStatus = async (paymentId) => {
  const response = await fetch(
    `https://api.voicepact.com/api/v1/payments/${paymentId}`
  );
  const payment = await response.json();
  
  if (payment.status === 'LOCKED') {
    console.log('Payment completed successfully!');
    return true;
  } else if (payment.status === 'FAILED') {
    console.log('Payment failed');
    return false;
  } else {
    console.log('Payment still pending...');
    return null; // Continue polling
  }
};

Verifying Payment Before Service Delivery

import httpx

async def verify_payment_before_delivery(payment_id: int) -> bool:
    async with httpx.AsyncClient() as client:
        response = await client.get(
            f"https://api.voicepact.com/api/v1/payments/{payment_id}"
        )
        payment = response.json()
        
        # Only deliver service if payment is locked in escrow
        return payment["status"] == "LOCKED"

Notes

  • Payment records are created immediately when checkout is initiated
  • Transaction ID may be null initially and populated within seconds
  • Status typically updates from PENDING to LOCKED or FAILED within 30-60 seconds
  • For contract-based queries, use the List Payments endpoint

Build docs developers (and LLMs) love