Check payment status in real-time using the payment reference. Essential for order processing, status polling, and payment verification.
Automatic Environment Detection: This endpoint automatically checks both
production (SATIM) and sandbox transactions based on where the payment was
created.
When you see this: - Payment completed successfully - Funds will be
credited to your OneClick balance What to do: - Mark order as paid in your
system - Fulfill the order/provide service - Send confirmation to customer
FAILED
When you see this:
Payment was declined or failed
Payment link expired (20 minutes)
Customer cancelled the payment
What to do:
Mark order as failed/cancelled
Create a new payment link if customer wants to retry
Here’s how to implement status checking in your order system:
Copy
async function checkOrderPayment(orderId) { // Get payment ref from your database const order = await db.orders.findOne({ id: orderId }); if (!order || !order.paymentRef) { throw new Error("Order not found or no payment link"); } // Check payment status const response = await fetch( `https://api.oneclickdz.com/v3/ocpay/checkPayment/${order.paymentRef}`, { headers: { "X-Access-Token": process.env.ONECLICK_API_KEY }, } ); const data = await response.json(); // Update order status based on payment status switch (data.data.status) { case "CONFIRMED": await db.orders.update(orderId, { status: "paid", paidAt: new Date(), }); // Fulfill order await fulfillOrder(orderId); break; case "FAILED": await db.orders.update(orderId, { status: "payment_failed", }); break; case "PENDING": // Keep polling break; } return data.data;}