Unganisha mfumo wako wa malipo na HarakaPay. Pokea malipo ya USSD push moja kwa moja kwenye app au website yako.
Kila ombi lazima liwe na API key yako kwenye header:
X-API-Key: hpk_your_api_key_here
Unaweza kupata API key yako kwenye Mipangilio.
Tuma ombi la malipo kwa simu ya mteja kupitia USSD push.
| Parameter | Type | Required | Description |
|---|---|---|---|
phone | string | Yes | Namba ya simu (mfano: 0712345678) |
amount | number | Yes | Kiasi cha TZS (min: 100) |
description | string | No | Maelezo ya malipo |
webhook_url | string | No | URL ya kupokea taarifa (POST) pale status itakapotofautiana kwa "completed" au "failed". |
Response (Success):
{
"success": true,
"message": "USSD push sent to phone",
"order_id": "HP1706123456789",
"amount": 10000,
"net_amount": 9400,
"fee": 600
}
Angalia hali ya malipo kwa kutumia order_id. Endpoint hii pia inatoa fursa ya kusababisha HarakaPay kutuma
takwimu kwenye webhook_url kama ulivyopatia wakati wa /api/v1/collect.
{
"success": true,
"payment": {
"order_id": "HP1706123456789",
"status": "completed",
"amount": 10000,
"net_amount": 9400,
"fee_amount": 600,
"created_at": "2026-01-24T12:00:00Z",
"completed_at": "2026-01-24T12:01:30Z"
}
}
{
"success": true,
"wallet_balance": 94000,
"float_balance": 50000
}
Ikiwa ulikuwa umeongeza webhook_url kwenye ombi la /api/v1/collect, HarakaPay itatuma POST
mara moja (kila inapotokea) unapopokea matokeo ya completed au failed kutoka Selcom. Mwisho wa
maombi haya ni 200; tukio la nje halijatambuliwa hatutarekodi taarifa ya kutuma.
{
"order_id": "HP1706123456789",
"status": "completed",
"amount": 10000,
"net_amount": 9400,
"fee_amount": 600,
"created_at": "2026-01-24T12:00:00Z",
"completed_at": "2026-01-24T12:01:30Z"
}
<?php
// HarakaPay PHP Integration Example
class HarakaPay {
private $apiKey;
private $baseUrl = 'https://harakapay.net';
public function __construct($apiKey) {
$this->apiKey = $apiKey;
}
public function collectPayment($phone, $amount, $description = '') {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->baseUrl . '/api/v1/collect');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'X-API-Key: ' . $this->apiKey
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'phone' => $phone,
'amount' => $amount,
'description' => $description,
'webhook_url' => 'https://your-domain.com/harakap-webhook' // optional callback URL
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
public function checkStatus($orderId) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->baseUrl . '/api/v1/status/' . $orderId);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $this->apiKey
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
public function getBalance() {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->baseUrl . '/api/v1/balance');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $this->apiKey
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
}
// Jinsi ya Kutumia:
$harakaPay = new HarakaPay('hpk_your_api_key_here');
// Kusanya malipo
$result = $harakaPay->collectPayment('0712345678', 10000, 'Bidhaa yangu');
if ($result['success']) {
echo 'Order ID: ' . $result['order_id'];
// Hifadhi order_id kwenye database yako
} else {
echo 'Error: ' . $result['error'];
}
// Baadaye, angalia hali ya malipo
$status = $harakaPay->checkStatus('HP1706123456789');
if ($status['payment']['status'] === 'completed') {
echo 'Malipo yamekamilika!';
}
?>
const axios = require('axios');
const API_KEY = 'hpk_your_api_key_here';
const BASE_URL = 'https://harakapay.net';
async function collectPayment(phone, amount, description) {
const response = await axios.post(`${BASE_URL}/api/v1/collect`, {
phone, amount, description,
webhook_url: 'https://your-domain.com/harakap-webhook' // optional callback URL
}, {
headers: { 'X-API-Key': API_KEY }
});
return response.data;
}
async function checkStatus(orderId) {
const response = await axios.get(`${BASE_URL}/api/v1/status/${orderId}`, {
headers: { 'X-API-Key': API_KEY }
});
return response.data;
}
// Mfano wa matumizi
collectPayment('0712345678', 10000, 'Bidhaa').then(result => {
console.log('Order ID:', result.order_id);
});
import requests
API_KEY = 'hpk_your_api_key_here'
BASE_URL = 'https://harakapay.net'
class HarakaPay:
def __init__(self, api_key):
self.api_key = api_key
self.headers = {
'Content-Type': 'application/json',
'X-API-Key': api_key
}
def collect_payment(self, phone, amount, description=''):
"""Tuma ombi la malipo kwa simu ya mteja"""
response = requests.post(
f'{BASE_URL}/api/v1/collect',
json={
'phone': phone,
'amount': amount,
'description': description,
'webhook_url': 'https://your-domain.com/harakap-webhook' # optional callback URL
},
headers=self.headers
)
return response.json()
def check_status(self, order_id):
"""Angalia hali ya malipo"""
response = requests.get(
f'{BASE_URL}/api/v1/status/{order_id}',
headers=self.headers
)
return response.json()
def get_balance(self):
"""Angalia salio lako"""
response = requests.get(
f'{BASE_URL}/api/v1/balance',
headers=self.headers
)
return response.json()
# Jinsi ya Kutumia:
harakapay = HarakaPay('hpk_your_api_key_here')
# Kusanya malipo
result = harakapay.collect_payment('0712345678', 10000, 'Bidhaa yangu')
if result.get('success'):
print(f"Order ID: {result['order_id']}")
# Hifadhi order_id kwenye database yako
else:
print(f"Error: {result.get('error')}")
# Baadaye, angalia hali ya malipo
status = harakapay.check_status('HP1706123456789')
if status.get('payment', {}).get('status') == 'completed':
print('Malipo yamekamilika!')
# Angalia salio
balance = harakapay.get_balance()
print(f"Wallet: TZS {balance['wallet_balance']}")
print(f"Float: TZS {balance['float_balance']}")
HarakaPay inakata ada kulingana na aina ya akaunti yako:
| Kiasi | Ada Personal (5.9%) | Unapata | Ada Biashara (2.9%) | Unapata |
|---|---|---|---|---|
| TZS 10,000 | TZS 590 | TZS 9,410 | TZS 290 | TZS 9,710 |
| TZS 50,000 | TZS 2,950 | TZS 47,050 | TZS 1,450 | TZS 48,550 |
| TZS 100,000 | TZS 5,900 | TZS 94,100 | TZS 2,900 | TZS 97,100 |
Kama una maswali au unahitaji msaada, wasiliana nasi kupitia barua pepe: support@harakapay.net