DEV Community

Suleiman
Suleiman

Posted on

Stop reconciling by hand: a one-time bank account for every order

Use Paymish dynamic virtual accounts so every incoming transfer is already tied to an order.

tags: fintech, api, backend, nigeria

If all customers pay into one account, you end up matching sender names and amounts by eye. Paymish can return a one-time dynamic virtual account for a transaction, straight from your backend with no hosted checkout redirect. Each order gets its own account number, so every incoming transfer is already tied to an order.

const BASE = 'https://api.paymish.com/api/transaction-service/external/v1';

async function createPaymentAccount(order) {
  const res = await fetch(`${BASE}/transaction-initialize/dva`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.PAYMISH_SECRET_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      email: order.customerEmail,
      amount: String(order.amountKobo), // kobo
      reference: order.id, // optional, must be unique
    }),
  });

  const data = await res.json();
  if (!res.ok) throw new Error(`Paymish error ${res.status}: ${JSON.stringify(data)}`);
  return data; // { status, message, data }
}
Enter fullscreen mode Exit fullscreen mode

What to know

  • email and amount are required. reference is optional and auto-generated if you leave it out, but pass your own order ID so the webhook maps straight back to the order.
  • The customer's email receives the account details and receipt notifications.
  • A 400 means a missing email or amount, or that an account could not be issued. A 401 means a missing or invalid key.
  • [CONFIRM: the docs show the response data field only as a placeholder. Fill in the real field names for account number, bank, and expiry before publishing.]

Need a permanent account per customer instead of per order? Look at the Dedicated Virtual Accounts collection.

Decide your rules before launch

What should happen in each case?

Situation Suggested handling
Exact amount Mark paid and fulfil
Underpayment Do not fulfil. Hold, then refund or ask for the balance
Overpayment Fulfil only if policy allows, and refund the excess
Duplicate payment Fulfil once, refund the extra
Payment after your order has expired Do not auto-fulfil. Review manually

Always reconcile by the order reference and your own records, never by the sender's name. Confirm each payment with a signed webhook before you fulfil the order.

Docs: docs.paymish.com

Top comments (0)