Skip to main content
GET
/
api
/
v1
/
payments
/
contract
/
{contract_id}
List Contract Payments
curl --request GET \
  --url https://api.example.com/api/v1/payments/contract/{contract_id}
{
  "contract_id": "<string>",
  "payments": [
    {
      "payment_id": 123,
      "transaction_id": {},
      "status": "<string>",
      "amount": 123,
      "currency": "<string>",
      "created_at": "<string>"
    }
  ]
}

Overview

Retrieves a list of all payments made for a specific contract, ordered by creation date (most recent first). This is useful for viewing payment history and tracking multiple payments for a single contract.

Path Parameters

contract_id
string
required
The unique identifier of the contract

Response

contract_id
string
The contract ID that was queried
payments
array
Array of payment objects associated with the contract

Example Request

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

Example Response

{
  "contract_id": "contract_123456",
  "payments": [
    {
      "payment_id": 45,
      "transaction_id": "ATXid_xyz789",
      "status": "LOCKED",
      "amount": 2500.0,
      "currency": "KES",
      "created_at": "2026-03-06T14:20:00.000000"
    },
    {
      "payment_id": 42,
      "transaction_id": "ATXid_sample123456789",
      "status": "RELEASED",
      "amount": 5000.0,
      "currency": "KES",
      "created_at": "2026-03-06T10:30:00.000000"
    },
    {
      "payment_id": 38,
      "transaction_id": "ATXid_abc123",
      "status": "FAILED",
      "amount": 5000.0,
      "currency": "KES",
      "created_at": "2026-03-06T09:15:00.000000"
    }
  ]
}

Example Response (No Payments)

{
  "contract_id": "contract_789012",
  "payments": []
}

Error Responses

Server Error (500)

{
  "detail": "Failed to retrieve contract payments"
}

Use Cases

Payment History Display

Show users all payment attempts for a contract:
const getPaymentHistory = async (contractId) => {
  const response = await fetch(
    `https://api.voicepact.com/api/v1/payments/contract/${contractId}`
  );
  const data = await response.json();
  
  console.log(`Total payments for contract: ${data.payments.length}`);
  
  data.payments.forEach(payment => {
    console.log(`Payment ${payment.payment_id}: ${payment.status} - ${payment.amount} ${payment.currency}`);
  });
};

Calculate Total Paid Amount

import httpx
from typing import Decimal

async def calculate_total_paid(contract_id: str) -> Decimal:
    async with httpx.AsyncClient() as client:
        response = await client.get(
            f"https://api.voicepact.com/api/v1/payments/contract/{contract_id}"
        )
        data = response.json()
        
        # Sum all locked or released payments
        total = sum(
            payment["amount"] 
            for payment in data["payments"]
            if payment["status"] in ["LOCKED", "RELEASED"]
        )
        
        return Decimal(str(total))

Check for Pending Payments

async def has_pending_payment(contract_id: str) -> bool:
    async with httpx.AsyncClient() as client:
        response = await client.get(
            f"https://api.voicepact.com/api/v1/payments/contract/{contract_id}"
        )
        data = response.json()
        
        return any(
            payment["status"] == "PENDING" 
            for payment in data["payments"]
        )

Notes

  • Payments are returned in descending order by creation date (newest first)
  • Empty array is returned if no payments exist for the contract
  • All payment statuses are included (PENDING, LOCKED, RELEASED, REFUNDED, FAILED)
  • Use this endpoint to:
    • Display payment history to users
    • Calculate total amount paid
    • Check for pending or failed payments
    • Verify payment status before contract actions

Build docs developers (and LLMs) love