Skip to main content

ArtinTech Solution

Gateway payments list in Linkhive

A customer’s browser coming back from a payment page proves nothing, because anyone can type that URL. To verify payment gateway callbacks in Laravel properly, treat the return as a hint and ask the gateway what really happened. This is how we built it in Linkhive, our ISP billing platform.

One small interface

Every gateway implements two methods: checkout() returns the URL to send the customer to, and verify() returns a verified payment or null. Controllers never read amounts from the request. They only pass a verified result to the billing service.

What Stripe verification checks

When a Checkout session starts, we store its ID and the exact amount charged on our payment row. On return, the code rejects the request unless the session ID matches that row, then fetches the session from Stripe and compares it:

if (($session['payment_status'] ?? null) !== 'paid'
    || ($session['client_reference_id'] ?? null) !== $payment->number
    || (int) ($session['amount_total'] ?? -1) !== $expected
    || ! self::sameCurrency($payment, $session['currency'] ?? null)) {
    return null;
}

Each check closes a real attack: replaying another customer’s session, paying a smaller amount, or paying in a cheaper currency.

Linkhive payments list showing method, reference, amount, pending bank transfers and completed gateway payments
Gateway payments complete on their own. Bank transfers wait for staff approval.

Applying the money once

A verified payment goes to approvePayment(), which locks the row inside a transaction. If two callbacks arrive together, the second finds the payment already completed and does nothing. A payment marked failed by the browser can still complete if the gateway later confirms it.

Key takeaways

  • Treat return URLs as hints, and confirm with the gateway’s API.
  • Compare the session, reference, amount and currency.
  • Lock the payment row so that repeated callbacks are harmless.

Try the flow in the Linkhive live demo or get Linkhive on Vibe96. Need gateways integrated in your own Laravel app? Let’s Talk, or see our Laravel development service.

Share this article