Order Confirmation
Retrieve order details after successful checkout.
Updated
On this page
Overview
After a successful checkout, display an order confirmation page with the order details. The checkout.complete() response contains everything you need.
Using the Checkout Response
const { order, customer, access_token } = await dash.checkout.complete({
cartId: dash.cart.cartId,
shipping: { ... },
payment_token: { token, descriptor },
})
// Redirect to confirmation page with order ID
router.push(`/order-confirmation?id=${order.id}`)
Confirmation Page Example
// app/order-confirmation/page.tsx
import dash from "@/lib/dash"
export default async function OrderConfirmation({ searchParams }) {
// If customer is authenticated, fetch the order
const { order } = await dash.auth.getOrder(searchParams.id)
return (
<div className="max-w-2xl mx-auto py-12">
<h1>Order Confirmed!</h1>
<p>Thank you for your purchase.</p>
<div className="border rounded p-6 mt-6">
<p><strong>Order Number:</strong> {order.order_number}</p>
<p><strong>Status:</strong> {order.status}</p>
<p><strong>Total:</strong> ${order.total}</p>
<h2 className="mt-4">Items</h2>
{order.items.map(item => (
<div key={item.size_id} className="flex justify-between">
<span>{item.product_name} ({item.size_label}) × {item.quantity}</span>
<span>${item.subtotal}</span>
</div>
))}
<div className="border-t mt-4 pt-4">
<div className="flex justify-between"><span>Subtotal</span><span>${order.subtotal}</span></div>
<div className="flex justify-between"><span>Shipping</span><span>${order.shipping}</span></div>
<div className="flex justify-between"><span>Tax</span><span>${order.tax}</span></div>
{order.discount !== "0.00" &&
<div className="flex justify-between text-green-500">
<span>Discount</span><span>-${order.discount}</span>
</div>
}
<div className="flex justify-between font-bold text-lg">
<span>Total</span><span>${order.total}</span>
</div>
</div>
</div>
<div className="mt-6">
<a href="/products">Continue Shopping</a>
<a href="/account/orders">View Order History</a>
</div>
</div>
)
}
Guest Checkout: Auto-Login
For guest checkouts, the response includes auth tokens. Store them to automatically log the customer in:
const { order, access_token, refresh_token } = await dash.checkout.complete({ ... })
if (access_token) {
// Guest was auto-registered — save tokens
localStorage.setItem("dash_token", access_token)
localStorage.setItem("dash_refresh", refresh_token)
dash.auth.setToken(access_token, refresh_token)
}
// Reset the cart after successful order
dash.cart.reset()
Retry Failed Payments
If payment failed but the order was created, use the repayment endpoint:
POST /storefront/checkout/repayment
X-API-Key: pk_live_your_key
Content-Type: application/json
{
"order_id": "ord_abc123",
"payment_token": { "token": "tok_new", "descriptor": "..." }
}
Next Steps
- List Orders — Viewing order history
- Order Statuses — Understanding the order lifecycle
- Order Notifications — Email notifications after checkout
- Storefront Views — Tracking conversions