McTaba Labs logo
Software EngineeringThe WhiteboardProjectsEventsMasterclassesWebinarsLearn
Book Call

500+ developers already in the community

Get answers, find accountability partners, and stay ahead

Join Discord →
McTaba Labs logo

Educating 1 million students in tech by 2030.

Programs

  • HighSchool Graduates Launchpad
  • AI & Business Automation
  • Corporate Training
  • McTaba Story & Mission
  • Full-Stack Curriculum
  • Course Pricing & Plans
  • Frequently Asked Questions

Resources

  • Join Discord Community
  • Tech Events in Nairobi
  • Masterclasses
  • Free Resources
  • Learn
  • Campus
  • Africa Tech Talent Report
  • Partner With Us
  • Start a Project
  • Our Work

Contact Us

  • 124 Manyani East Road, Lavington, Nairobi
  • +254727795603
  • Book a Discovery Call

Office Hours:

Mon-Fri: 9am - 2pm EAT

Sat: 10am - 12pm EAT

© 2027 McTaba Labs - A product of Edtech Industries. All rights reserved.

Privacy PolicyTerms of ServiceRefund Policy
  1. Learn
  2. Paystack for African Developers
  3. Verify Paystack Payments in Symfony
Bonaventure OgetoBy Bonaventure Ogeto|Updated July 20, 2026

Verify Paystack Payments in Symfony

To verify a Paystack payment in Symfony, use your PaystackService to GET the verify endpoint. Check status, amount, and currency against your Doctrine Order entity. Use DQL UPDATE with a condition on paid=false for idempotent fulfillment.

In this article

  1. 1. Verification Service Method
  2. 2. Controller Usage
  3. 3. Common Mistakes
  4. 4. Ship Payments Faster

Verification Service Method

// In PaystackService
public function verifyAndFulfill(string $reference, EntityManagerInterface $em): array
{
    $order = $em->getRepository(Order::class)->findOneBy(['reference' => $reference]);

    if (!$order) {
        return ['success' => false, 'error' => 'Order not found'];
    }

    if ($order->isPaid()) {
        return ['success' => true, 'already_fulfilled' => true];
    }

    $result = $this->verifyTransaction($reference);

    if (!($result['status'] ?? false) || $result['data']['status'] !== 'success') {
        return ['success' => false, 'error' => 'Payment not successful'];
    }

    if ($result['data']['amount'] !== $order->getAmount()) {
        return ['success' => false, 'error' => 'Amount mismatch'];
    }

    // Atomic update
    $updated = $em->createQueryBuilder()
        ->update(Order::class, 'o')
        ->set('o.paid', true)
        ->set('o.paidAt', ':now')
        ->where('o.reference = :ref')
        ->andWhere('o.paid = false')
        ->setParameter('ref', $reference)
        ->setParameter('now', new \DateTime())
        ->getQuery()
        ->execute();

    return [
        'success' => true,
        'already_fulfilled' => $updated === 0,
    ];
}

Controller Usage

#[Route('/payment/callback')]
public function callback(Request $request, PaystackService $paystack, EntityManagerInterface $em): Response
{
    $reference = $request->query->get('reference') ?? $request->query->get('trxref');

    if (!$reference) {
        return new Response('Missing reference', 400);
    }

    $result = $paystack->verifyAndFulfill($reference, $em);

    if ($result['success']) {
        return $this->render('payment/success.html.twig', ['reference' => $reference]);
    }

    return $this->render('payment/failed.html.twig', ['error' => $result['error']]);
}

Get weekly developer tips

Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.

No spam. Unsubscribe anytime.

Common Mistakes

  • Using $em->flush() without atomic conditions. Use DQL UPDATE with a WHERE clause instead.
  • Not checking currency. Always verify the currency matches your entity.
  • Trusting request parameters. Verify against your database, not URL params.

Ship Payments Faster

This guide is part of the Paystack integration guides by language and framework series.

Sign up for the McTaba newsletter

Key Takeaways

  • ✓Extend your PaystackService with a verifyAndFulfill method that checks amount, currency, and status.
  • ✓Use Doctrine DQL or QueryBuilder for atomic updates that prevent double-granting.
  • ✓Both callback and webhook handlers should call the same verification service method.
  • ✓Always check amount and currency against your Doctrine entity, not request parameters.
  • ✓If the verify call fails, retry with exponential backoff.
  • ✓The Paystack verify endpoint is idempotent. Calling it multiple times returns the same result.

Frequently Asked Questions

Can I use the Symfony Messenger component for async verification?
Yes. Dispatch a message from your webhook handler and process it asynchronously. The idempotent verification logic ensures safety.
Should I verify in the webhook handler?
Yes. Both callback and webhook should call verifyAndFulfill. The atomic update ensures only one fulfills the order.
How do I handle verification timeouts?
Set a timeout on the HttpClient request. If it times out, retry. The transaction state on Paystack does not change.

Learn Paystack Integration

KES 2,999

The definitive guide to building payment systems with Paystack — from your first transaction to production-grade payment infrastructure across Africa. 9 modules, 47 lessons. Free preview available.

Start Paystack Course

Not ready? Create Free Account

Keep reading

Paystack Integration Guides by Language and Framework

A complete directory of Paystack integration guides organized by programming language and framework. Each guide covers accepting payments, verifying transactions, handling webhooks, and building subscriptions in your specific stack.

Read more

Accept Payments with Paystack in Svelte and SvelteKit

Accept Paystack payments in SvelteKit using server endpoints for backend logic and Svelte components for the frontend. This guide covers initializing transactions, inline popup checkout, redirect checkout, and verification in a single full-stack SvelteKit project.

Read more

Verify Paystack Payments in Flask

Verify Paystack payments server-side in your Flask application. This guide covers calling the Paystack verify endpoint, validating amounts and currencies, building reusable verification helpers, and preventing double-granting.

Read more

Build Paystack Subscriptions in ASP.NET Core

Implement Paystack recurring billing in ASP.NET Core. This guide covers creating plans, subscribing customers through transaction initialization, handling renewal webhooks with C#, and cancelling subscriptions.

Read more

Building a Wallet Top-Up Flow on Paystack

A step-by-step guide to building wallet top-up flows with Paystack. Initialize payment, handle webhooks, credit wallets safely, enforce minimum amounts, and prevent double-crediting in production.

Read more

Paystack Rate Limit and 429 Handling

Paystack returns 429 Too Many Requests when you exceed their API rate limit. This guide covers the actual limits, how to implement exponential backoff, when to cache responses, and how to batch operations to avoid hitting the limit.

Read more

Explore related topics

M-Pesa & African Stack

M-Pesa Daraja API tutorials, USSD development, and WhatsApp Business API guides. The African Stack that global bootcamps do not teach.

Learn to Code in Kenya

Everything a Kenyan needs to know before writing their first line of code. Career paths, real costs, hardware requirements, and honest answers about what it takes.

Learning to Code

Roadmaps, language guides, and practical advice for learning to code and launching a programming career.

Breaking Into Tech

Practical, no-nonsense guides for anyone looking to start or change their career in tech. From choosing your first language to acing interviews.

The African Stack: Skills for This Market

The skills that make Kenyan developers hard to replace: M-Pesa, USSD, WhatsApp, fintech, and building for the African market.

Bonaventure Ogeto

Bonaventure Ogeto

Founder, McTaba Labs

Bonaventure is the founder of McTaba Labs, a coding bootcamp in Nairobi, Kenya. He has spent years building products for the African market and mentoring the next generation of developers across the continent.