Skip to content

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.

For customer integrations, use the production Mint API base URL. If you are testing, use a test checkout rather than switching to a separate dev platform.

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 ​

FieldDescription
checkout_idThe Mint checkout to create the payment against
currencyFiat display currency for the payment
amountPayment amount in standard units, for example 49 for 49 USD
order_idYour order reference
customer_idYour customer reference
return_urlWhere Mint should send the buyer when the flow completes
metadataExtra values for reconciliation and downstream workflows
line_itemsOptional 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_url directly from your backend

Payment statuses ​

The key statuses to handle are:

  • pending: payment created, waiting for buyer action
  • confirming_payment: funds received and still being confirmed or settled
  • paid: payment completed successfully
  • failed: 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.
  • Use https://api.getmint.money for customer-facing integrations.
  • Test safely by creating payments against a test checkout.