EasyPay
Browse guides
DocsReference

Order verification

Match a Chapa transaction to your stored order and fulfill it once.

Verify on the server

Use the same backend verification logic for a signed webhook, a hosted callback, or your checkout's status request. Load the order and payment attempt from your database. Supply the amount, currency, and mode saved by the backend.

const result = await payments.verifyTransaction(order.txRef, {
  amount: order.totalETB, // number or decimal string, e.g. "120.50"
  currency: "ETB",
  mode: order.paymentMode, // "test" or "live"
});

if (result.status === "verified") {
  // Run the order transition and fulfillment event in one database transaction.
  await recordVerifiedPayment(order.id, result.data);
}

Handle duplicate events

For example, recordVerifiedPayment can use the following PostgreSQL statement. Give the payment-attempt reference a unique constraint. The conditional update claims the order once, including when a webhook and a polling request arrive together. Deliver the queued event with the order ID as its idempotency key.

WITH paid AS (
  UPDATE orders
     SET payment_status = 'paid', provider_ref = $3
   WHERE id = $1 AND tx_ref = $2 AND payment_status = 'pending'
   RETURNING id
)
INSERT INTO fulfillment_outbox (order_id)
SELECT id FROM paid;

Bind the order ID, verified merchant txRef, and verified providerRef to the three parameters. Keep price and currency fixed for the lifetime of each attempt. Repeated calls to verifyTransaction can return the same verified payment and invoke onSuccess again. The database transition owns fulfillment. Chapa verification · Webhook authentication and idempotency

Next guide API reference