Initiate Direct Payment
Trigger a payment directly to a customer's mobile wallet without redirecting to a hosted checkout page.
Initiate Direct Payment
POST /v1/transactions/direct
Initiates a direct payment by pushing a prompt (USSD menu, SMS OTP, or in-app notification) to the customer's phone. No checkout URL is returned — the customer authorizes the payment on their device.
Direct payment requires the customer's phone number and a configured payment provider (e.g. TeleBirr, Awash). Contact support to enable direct payment for your account.
Connect
Platforms can call this on behalf of a connected business with the
ePay-Account header. Requires the read_write scope. See Act on
behalf.
Request
npm install @e-pay/nodenpm install @e-pay/nestjspip install epaypip install epaypip install epaypip install epaycomposer require epay-et/php-sdkcomposer require epay-et/php-sdkimplementation("com.epayethiopia:epay-java:0.1.0")implementation("com.epayethiopia:epay-spring-boot-starter:0.1.0")go get github.com/epay-et/go-sdkNothing NestJS-specific here — this is the same Node.js client call.
Nothing Django-specific here — this is the same Python client call.
Nothing Flask-specific here — this is the same Python client call.
Nothing FastAPI-specific here — this is the same Python client call.
Nothing Laravel-specific here — this is the same PHP client call.
Nothing Spring Boot-specific here — this is the same Java client call.
curl https://api.epayet.dev/v1/transactions/direct \
-X POST \
-H "Authorization: Bearer sk_live_your_key_here" \
-H "Content-Type: application/json" \
-H "x-idempotency-key: order_456" \
-d '{
"amount": "250.00",
"currencyCode": "ETB",
"customerPhone": "+251911234567",
"pspCode": "TELEBIRR",
"merchantReference": "order_456"
}'import { Epay } from '@e-pay/node';
const epay = new Epay({ apiKey: process.env.EPAY_SECRET_KEY });
const charge = await epay.payments.directPayment(
{
amount: '250.00',
currencyCode: 'ETB',
customerPhone: '+251911234567',
pspCode: 'TELEBIRR',
merchantReference: 'order_456',
},
{ idempotencyKey: 'order_456' },
);
// charge.status === 'pending': the customer authorizes on their phone,
// and the outcome arrives at your webhook.
await orders.markAwaitingPayment('order_456', charge.reference);const res = await fetch('https://api.epayet.dev/v1/transactions/direct', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.EPAY_SECRET_KEY}`,
'Content-Type': 'application/json',
'x-idempotency-key': 'order_456',
},
body: JSON.stringify({
amount: '250.00',
currencyCode: 'ETB',
customerPhone: '+251911234567',
pspCode: 'TELEBIRR',
merchantReference: 'order_456',
}),
});
if (!res.ok) throw new Error(`ePay ${res.status}: ${await res.text()}`);
const { reference, status, chargeAmount, feeAmount } = (await res.json()).data;from epay import Epay
epay = Epay() # reads EPAY_SECRET_KEY
charge = epay.payments.direct_payment(
amount="250.00",
currency_code="ETB",
customer_phone="+251911234567",
psp_code="TELEBIRR",
merchant_reference="order_456",
idempotency_key="order_456",
)
# charge["status"] == "pending": the customer authorizes on their phone,
# and the outcome arrives at your webhook.
orders.mark_awaiting_payment("order_456", charge["reference"])import os
import requests
res = requests.post(
"https://api.epayet.dev/v1/transactions/direct",
headers={
"Authorization": f"Bearer {os.environ['EPAY_SECRET_KEY']}",
"x-idempotency-key": "order_456",
},
json={
"amount": "250.00",
"currencyCode": "ETB",
"customerPhone": "+251911234567",
"pspCode": "TELEBIRR",
"merchantReference": "order_456",
},
timeout=30,
)
res.raise_for_status()
data = res.json()["data"]
reference = data["reference"]use Epay\Epay;
$epay = new Epay(); // reads EPAY_SECRET_KEY
$charge = $epay->payments->directPayment([
'amount' => '250.00',
'currencyCode' => 'ETB',
'customerPhone' => '+251911234567',
'pspCode' => 'TELEBIRR',
'merchantReference' => 'order_456',
], idempotencyKey: 'order_456');
// $charge['status'] === 'pending': the customer authorizes on their phone,
// and the outcome arrives at your webhook.
$orders->markAwaitingPayment('order_456', $charge['reference']);$ch = curl_init('https://api.epayet.dev/v1/transactions/direct');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('EPAY_SECRET_KEY'),
'Content-Type: application/json',
'x-idempotency-key: order_456',
],
CURLOPT_POSTFIELDS => json_encode([
'amount' => '250.00',
'currencyCode' => 'ETB',
'customerPhone' => '+251911234567',
'pspCode' => 'TELEBIRR',
'merchantReference' => 'order_456',
]),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
if ($status >= 400) {
throw new RuntimeException("ePay {$status}: {$body}");
}
$data = json_decode($body, true)['data'];
$reference = $data['reference'];client, err := epay.NewClient() // reads EPAY_SECRET_KEY
if err != nil {
return err
}
charge, err := client.Payments.DirectPayment(ctx, epay.DirectPaymentParams{
Amount: "250.00",
CurrencyCode: "ETB",
CustomerPhone: "+251911234567",
PSPCode: "TELEBIRR",
MerchantReference: "order_456",
IdempotencyKey: "order_456",
})
if err != nil {
return err
}
// charge.Status == epay.StatusPending: the customer authorizes on their phone,
// and the outcome arrives at your webhook.
return orders.MarkAwaitingPayment(ctx, "order_456", charge.Reference)payload, _ := json.Marshal(map[string]string{
"amount": "250.00",
"currencyCode": "ETB",
"customerPhone": "+251911234567",
"pspCode": "TELEBIRR",
"merchantReference": "order_456",
})
req, _ := http.NewRequestWithContext(ctx, http.MethodPost,
"https://api.epayet.dev/v1/transactions/direct", bytes.NewReader(payload))
req.Header.Set("Authorization", "Bearer "+os.Getenv("EPAY_SECRET_KEY"))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-idempotency-key", "order_456")
res, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode >= 400 {
return fmt.Errorf("ePay %d", res.StatusCode)
}
var envelope struct {
Data struct {
Reference string `json:"reference"`
Status string `json:"status"`
ChargeAmount string `json:"chargeAmount"`
FeeAmount string `json:"feeAmount"`
} `json:"data"`
}
if err := json.NewDecoder(res.Body).Decode(&envelope); err != nil {
return err
}
data := envelope.Data // every response is {"status": "success", "data": …}import com.epayethiopia.epay.DirectPaymentParams;
import com.epayethiopia.epay.Epay;
import com.epayethiopia.epay.model.DirectPayment;
Epay epay = Epay.fromEnvironment(); // reads EPAY_SECRET_KEY; thread-safe, share one
DirectPayment charge = epay.payments().directPayment(DirectPaymentParams.builder()
.amount("250.00")
.currencyCode("ETB")
.customerPhone("+251911234567")
.pspCode("TELEBIRR")
.merchantReference("order_456")
.idempotencyKey("order_456")
.build());
// charge.status() == PENDING: the customer authorizes on their phone,
// and the outcome arrives at your webhook.
orders.markAwaitingPayment("order_456", charge.reference());HttpClient http = HttpClient.newHttpClient();
String body = """
{
"amount": "250.00",
"currencyCode": "ETB",
"customerPhone": "+251911234567",
"pspCode": "TELEBIRR",
"merchantReference": "order_456"
}
""";
HttpRequest request = HttpRequest.newBuilder(
URI.create("https://api.epayet.dev/v1/transactions/direct"))
.header("Authorization", "Bearer " + System.getenv("EPAY_SECRET_KEY"))
.header("Content-Type", "application/json")
.header("x-idempotency-key", "order_456")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = http.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 400) {
throw new IllegalStateException("ePay " + response.statusCode() + ": " + response.body());
}
// {"status":"success","data":{"reference":"A3BX72KP","status":"pending","chargeAmount":"250.00","feeAmount":"5.00"}}
String responseBody = response.body();import { Controller, HttpCode, Param, Post } from '@nestjs/common';
import { EpayService } from '@e-pay/nestjs';
@Controller('orders')
export class ChargeController {
constructor(
private readonly epay: EpayService,
private readonly orders: OrdersService,
) {}
@Post(':id/charge')
@HttpCode(202)
async charge(@Param('id') id: string) {
const order = await this.orders.find(id);
const charge = await this.epay.payments.directPayment(
{
amount: order.total,
currencyCode: 'ETB',
customerPhone: order.customerPhone,
pspCode: order.provider, // e.g. 'TELEBIRR', chosen by the customer
merchantReference: order.id,
},
{ idempotencyKey: order.id },
);
// Accepted, not paid: fulfil from the payment.success webhook.
return { reference: charge.reference, status: charge.status };
}
}from django.http import JsonResponse
from django.shortcuts import get_object_or_404
from django.views.decorators.http import require_POST
from .clients import epay # Epay(api_key=settings.EPAY_SECRET_KEY)
from .models import Order
@require_POST
def charge(request, order_id):
order = get_object_or_404(Order, pk=order_id)
charge = epay.payments.direct_payment(
amount=order.total, # a DecimalField stays exact
currency_code="ETB",
customer_phone=order.customer_phone,
psp_code=order.provider, # e.g. "TELEBIRR", chosen by the customer
merchant_reference=str(order.pk),
idempotency_key=str(order.pk),
)
# Accepted, not paid: fulfil from the payment.success webhook.
return JsonResponse({"reference": charge["reference"], "status": charge["status"]}, status=202)from flask import jsonify
from app import app, epay # epay = Epay(), one per process
@app.post("/orders/<order_id>/charge")
def charge(order_id):
order = Order.query.get_or_404(order_id)
charge = epay.payments.direct_payment(
amount=order.total,
currency_code="ETB",
customer_phone=order.customer_phone,
psp_code=order.provider, # e.g. "TELEBIRR", chosen by the customer
merchant_reference=order_id,
idempotency_key=order_id,
)
# Accepted, not paid: fulfil from the payment.success webhook.
return jsonify(reference=charge["reference"], status=charge["status"]), 202from app.main import app, epay # epay = AsyncEpay(), closed in lifespan
@app.post("/orders/{order_id}/charge", status_code=202)
async def charge(order_id: str):
order = await orders.get(order_id)
charge = await epay.payments.direct_payment(
amount=order.total,
currency_code="ETB",
customer_phone=order.customer_phone,
psp_code=order.provider, # e.g. "TELEBIRR", chosen by the customer
merchant_reference=order_id,
idempotency_key=order_id,
)
# Accepted, not paid: fulfil from the payment.success webhook.
return {"reference": charge["reference"], "status": charge["status"]}use App\Models\Order;
use Epay\Epay;
use Illuminate\Http\JsonResponse;
final class ChargeController
{
public function __construct(private readonly Epay $epay) {}
public function store(Order $order): JsonResponse
{
$charge = $this->epay->payments->directPayment([
'amount' => $order->total,
'currencyCode' => 'ETB',
'customerPhone' => $order->customer_phone,
'pspCode' => $order->provider, // e.g. 'TELEBIRR', chosen by the customer
'merchantReference' => (string) $order->id,
], idempotencyKey: (string) $order->id);
// Accepted, not paid: fulfil from the payment.success webhook.
return response()->json([
'reference' => $charge['reference'],
'status' => $charge['status'],
], 202);
}
}
// routes/web.php
// Route::post('/orders/{order}/charge', [ChargeController::class, 'store']);@RestController
class ChargeController {
private final Epay epay;
private final Orders orders;
ChargeController(Epay epay, Orders orders) {
this.epay = epay;
this.orders = orders;
}
@PostMapping("/orders/{id}/charge")
ResponseEntity<DirectPayment> charge(@PathVariable String id) {
Order order = orders.find(id);
DirectPayment charge = epay.payments().directPayment(DirectPaymentParams.builder()
.amount(order.total())
.currencyCode("ETB")
.customerPhone(order.phone())
.pspCode(order.provider()) // e.g. "TELEBIRR", chosen by the customer
.merchantReference(order.id())
.idempotencyKey(order.id())
.build());
// Accepted, not paid: fulfil from the payment.success webhook.
return ResponseEntity.accepted().body(charge);
}
}Response
{
"status": "success",
"data": {
"reference": "A3BX72KP",
"status": "pending",
"attempt": {},
"chargeAmount": "250.00",
"feeAmount": "5.00",
"tipAmount": null
}
}Headers
Prop
Type
Body
Prop
Type
Response
Returns 201 Created. Every response is wrapped as { "status": "success", "data": … }; the fields below are inside data.
Prop
Type
Errors
| Status | Description |
|---|---|
400 | Invalid amount, unsupported currency, or provider not enabled. |
400 | Connect only: the app fee was rejected (product_fee_too_high, product_fee_too_low, …). See App fees → Rules and errors. |
401 | Missing or invalid API key. |
403 | Account is restricted from initiating payments. |
429 | Rate limit exceeded. |
Next: Authorization Flow — what happens after initiation.