How to check payment status using the POST /trdp/verify endpoint.
Use the verification endpoint to confirm whether a payment has been completed. This is useful when you need to check status on demand — for example, before fulfilling an order, or when you haven’t received a callback within the expected time window.Endpoint:POST /trdp/verifyBase URL:https://starpayqa.starpayethiopia.com/v1/starpay-api
Star-Pay offers two ways to receive payment status updates:
Method
When to use
Webhook callback
Preferred for real-time updates. Star-Pay POSTs to your callbackURL immediately after a transaction.
Verification endpoint
Use as a fallback or for on-demand checks — for example, when a user returns to your site after paying.
If you don’t receive a callback within a few minutes of the expected payment time, poll this endpoint to retrieve the current status. Implement exponential back-off to avoid rate limiting.
If you need to wait for a payment to complete, poll the verify endpoint with a delay between attempts:
JavaScript
async function waitForPayment(orderId, maxAttempts = 10, delayMs = 5000) { for (let attempt = 1; attempt <= maxAttempts; attempt++) { const response = await fetch( "https://starpayqa.starpayethiopia.com/v1/starpay-api/trdp/verify", { method: "POST", headers: { "Content-Type": "application/json", "x-api-secret": process.env.STARPAY_API_SECRET, }, body: JSON.stringify({ orderId }), } ); const result = await response.json(); const { status } = result.data; if (status === "PAID") return result.data; if (status === "FAILED") throw new Error("Payment failed"); if (attempt < maxAttempts) { await new Promise((resolve) => setTimeout(resolve, delayMs * attempt)); } } throw new Error("Payment verification timed out");}
Do not fulfill orders based solely on a redirect back to your redirectUrl. Always verify payment status server-side using the verification endpoint or a signed webhook callback before granting access to goods or services.