RistaPay logo RistaPay
DEVELOPER RESOURCES

Build with RistaPay API

Learn how to integrate your application with RistaPay's payment interface. Start with the sandbox request format, understand transaction responses, and prepare your integration for future Daraja connectivity.

Sandbox-first development REST API JSON requests

Sandbox environment — no real money movement

The documented STK Push example describes the intended sandbox request format. It does not establish that the endpoint is implemented or connected to Safaricom. Confirm the actual endpoint response before relying on an integration. Sandbox responses must never be treated as proof of a real payment.

01. Getting started

RistaPay is being developed as a payment integration platform. Begin by reviewing the request structure below and confirming which endpoints are actually available in your current installation.

Base URL

YOUR RISTAPAY DOMAIN
https://dreamleague27.site

Use HTTPS for requests. The API base URL above is your configured website domain; it does not guarantee that every example endpoint has already been deployed.

02. API authentication

The intended example uses an API key in the X-API-Key request header. Use a valid key generated and accepted by your actual API implementation.

HTTP HEADERS
Content-Type: application/json
X-API-Key: YOUR_RISTAPAY_TEST_KEY
Replace the placeholder with your own valid test key. Never put private API keys in browser JavaScript, public repositories, screenshots, or client-side applications.

03. STK Push request

This is the documented example request for testing the intended STK Push integration. The actual endpoint must be implemented and verified separately.

POST /api/v1/stk-push.php
Example JSON body
REQUEST.JSON
{
  "phone": "254712345678",
  "amount": 10,
  "account_reference": "ORDER-1001",
  "description": "Sandbox test"
}

The phone number and amount are illustrative test values. Use only a test environment and never interpret an example request as confirmation that a customer has paid.

04. Request fields

Field Type Description
phone String Customer phone number in the expected international format.
amount Number Requested payment amount. Validate permitted amounts on the server.
account_reference String Merchant reference used to identify the order or invoice.
description String Short description of the intended transaction.

These descriptions document the example payload. Required fields, accepted formats, length limits, and validation rules must match the implemented endpoint.

05. Responses

A working API should return a clear result and a unique transaction reference. The following is an illustrative sandbox response, not a verified response from your server.

ILLUSTRATIVE RESPONSE
{
  "success": true,
  "environment": "sandbox",
  "reference": "TEST-TRANSACTION-1001",
  "status": "sandbox_pending",
  "message": "Sandbox request recorded for testing."
}
Only return a success result after the server has successfully performed the action represented by that result. A simulated sandbox response must be clearly identified as a simulation.

06. Error handling

Integrations should handle HTTP errors, invalid input, authentication failures, timeouts, and unexpected responses.

HTTP status Typical meaning
400 Invalid or incomplete request data.
401 Missing or invalid authentication credentials.
403 The request is not permitted.
404 The requested endpoint was not found.
429 Too many requests, if rate limiting is implemented.
500 Unexpected server-side error.

These are general HTTP conventions, not a claim that the current RistaPay endpoint returns every status listed.

07. Security checklist

  • Keep API secrets on your server, never in public frontend code.
  • Validate phone numbers, amounts, and references on the server.
  • Associate each API key with its authorized merchant account.
  • Use rate limits and audit logs to help detect abuse.
  • Prevent duplicate payment requests with idempotency controls.
  • Verify payment results through trusted server-side records and callbacks.
  • Never trust a customer-provided success message or screenshot as payment proof.

08. Production readiness

Before connecting live M-PESA payments, the platform needs a verified Safaricom Daraja integration and appropriate credentials, callback processing, transaction validation, monitoring, and security controls.

  • Configure and test approved Daraja credentials.
  • Implement STK Push initiation and securely process callbacks.
  • Verify callback authenticity and reconcile transaction states.
  • Protect credentials and implement logging, access controls, and rate limits.
  • Test failure, timeout, duplicate-request, and reversal scenarios.
  • Confirm any applicable legal, regulatory, and provider requirements.
This documentation does not itself activate live payments, B2C payouts, settlements, or wallet balances. Those features require their own implemented and tested integrations.
© 2026 RistaPay · Developer Documentation Back to Dashboard