HTML Checkout
Check the public-key HTML checkout service and initialize hosted checkout.
The collection documents GET /v2/payments/html as a public-key service check. It is not a payment initialization or form-submission endpoint.
Service check
GET /v2/payments/html
Host: api.chapa.global
Authorization: Bearer <PUBLIC_KEY>No parameters or request body are required.
For cURL, set PUBLIC_KEY in your shell. Replace the placeholders in the JavaScript example before running it.
curl -X GET 'https://api.chapa.global/v2/payments/html' \
-H "Authorization: Bearer $PUBLIC_KEY"const response = await fetch("https://api.chapa.global/v2/payments/html", {
method: "GET",
headers: {
"Authorization": "Bearer <PUBLIC_KEY>"
},
});
const data = await response.json();
console.log(data);{
"status": "success",
"message": "HTML Checkout is running",
"data": {
"version": "2.0.0",
"stage": "production"
}
}{
"status": "error",
"message": "Invalid API key or User does not exist",
"error": {
"code": "UNAUTHORIZED",
"details": null
}
}Accept a payment from an HTML form
Collect order details in your form and send them to your backend. Your backend validates the order amount and currency, calls POST /v2/payments/hosted with a private key and Idempotency-Key, and returns data.checkout_url. Redirect the customer to that URL.
For cURL, set PRIVATE_KEY in your shell. Set IDEMPOTENCY_KEY for this operation and reuse it on retries. Replace the placeholders in the JavaScript example before running it.
{
"amount": 10000,
"currency": "ETB",
"merchant_reference": "ref-1791192600",
"preferred_payment_methods": [
"telebirr"
],
"customer": {
"first_name": "Abebe",
"last_name": "Kebede",
"email": "abebe.kebede@example.com",
"phone_number": "251911000000"
},
"callback_url": "https://example.com/chapa/callback",
"return_url": "https://example.com/chapa/return",
"meta": {
"order_id": "ORD-1001"
},
"customization": {
"title": "Order #1001",
"description": "Payment for order 1001",
"logo": "https://example.com/logo.png"
}
}curl -X POST 'https://api.chapa.global/v2/payments/hosted' \
-H "Authorization: Bearer $PRIVATE_KEY" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 10000,
"currency": "ETB",
"merchant_reference": "ref-1791192600",
"preferred_payment_methods": [
"telebirr"
],
"customer": {
"first_name": "Abebe",
"last_name": "Kebede",
"email": "abebe.kebede@example.com",
"phone_number": "251911000000"
},
"callback_url": "https://example.com/chapa/callback",
"return_url": "https://example.com/chapa/return",
"meta": {
"order_id": "ORD-1001"
},
"customization": {
"title": "Order #1001",
"description": "Payment for order 1001",
"logo": "https://example.com/logo.png"
}
}'const response = await fetch("https://api.chapa.global/v2/payments/hosted", {
method: "POST",
headers: {
"Authorization": "Bearer <PRIVATE_KEY>",
"Idempotency-Key": "<IDEMPOTENCY_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
"amount": 10000,
"currency": "ETB",
"merchant_reference": "ref-1791192600",
"preferred_payment_methods": [
"telebirr"
],
"customer": {
"first_name": "Abebe",
"last_name": "Kebede",
"email": "abebe.kebede@example.com",
"phone_number": "251911000000"
},
"callback_url": "https://example.com/chapa/callback",
"return_url": "https://example.com/chapa/return",
"meta": {
"order_id": "ORD-1001"
},
"customization": {
"title": "Order #1001",
"description": "Payment for order 1001",
"logo": "https://example.com/logo.png"
}
})
});
const data = await response.json();
console.log(data);Amounts are integer cents, minimum 100. Keep merchant_reference at 20 characters or fewer. Keep private keys on your server. Verify data.status === "SUCCESS" server-side and match the expected amount, currency, and reference before fulfillment.
See Hosted Checkout for hosted checkout and Inline Charge for public-key charge requests.