Backend Payment Creation
Mint payments should be created on your backend, never in the browser.
Why the backend owns payment creation
Your backend is the right place to:
- use your Mint secret key
- validate the amount and currency
- attach order metadata
- decide which checkout should be used
- log and reconcile payment creation requests
Create a payment
Send a POST request to /v1/payments.
Example:
ts
app.post('/api/mint/payments', async (req, res) => {
const response = await fetch(`${process.env.MINT_API_URL}/v1/payments`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
'x-api-key': process.env.MINT_SECRET_KEY!,
},
body: JSON.stringify({
checkout_id: process.env.MINT_CHECKOUT_ID,
currency: 'USD',
amount: 49,
order_id: 'order_123',
customer_id: 'customer_456',
return_url: 'https://your-app.example.com/checkout/complete',
metadata: {
cart_id: 'cart_789',
},
}),
});
const payload = await response.json();
if (!response.ok) {
res.status(response.status).json(payload);
return;
}
res.json(payload.data);
});Request fields you will use most often
| Field | Description |
|---|---|
checkout_id | The Mint checkout to create the payment against |
currency | Fiat display currency for the payment |
amount | Payment amount in standard units, for example 49 for 49 USD |
order_id | Your order reference |
customer_id | Your customer reference |
return_url | Where Mint should send the buyer when the flow completes |
metadata | Extra values for reconciliation and downstream workflows |
line_items | Optional list of purchasable items |
What to return to the frontend
For an embedded SDK flow, return the Mint payment object itself.
For a hosted flow, you can either:
- return the full Mint payment object and let the frontend read
payment_url - redirect to
payment_urldirectly from your backend
Payment statuses
The key statuses to handle are:
pending: payment created, waiting for buyer actionconfirming_payment: funds received and still being confirmed or settledpaid: payment completed successfullyfailed: payment failed or could not be completed
Practical guidance
- Validate amount and currency before calling Mint.
- Keep your secret key in server-side environment variables only.
- Attach your own order and customer references at payment creation time.
- Persist the Mint payment ID in your own system for reconciliation.