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. Simulating Declined Cards on Paystack
Bonaventure OgetoBy Bonaventure Ogeto|Updated July 22, 2026

Simulating Declined Cards on Paystack

To simulate a card decline in Paystack test mode: use card 4084080000000409 to trigger "Do Not Honor", or 4084080000000005 to trigger "Insufficient Funds". These cards will fire a charge.failed webhook event. Verify that your webhook handler does not fulfill the order, your frontend shows a useful error message, and your retry flow works.

In this article

  1. 1. Test Cards That Trigger Specific Decline Reasons
  2. 2. Handling the Decline in Your Webhook Handler
  3. 3. Learn More

Test Cards That Trigger Specific Decline Reasons

Card NumberDecline Reasongateway_response
4084080000000409 Declined by issuer Do Not Honor
4084080000000005 Insufficient funds Insufficient Funds
4084080000000007 Card expired (simulate) Expired Card
4084080000000009 Incorrect PIN Incorrect PIN

All test decline cards use CVV 408 and any future expiry date.

Handling the Decline in Your Webhook Handler

// Webhook handler — handle both success and failure events
if (event.event === 'charge.success') {
  await fulfillOrder(event.data.metadata.order_id);
}

if (event.event === 'charge.failed') {
  var orderId = event.data.metadata?.order_id;
  var reason = event.data.gateway_response; // "Do Not Honor", "Insufficient Funds", etc.

  await db.orders.update({
    id: orderId,
    status: 'payment_failed',
    failure_reason: reason,
  });

  // Notify the customer
  await sendEmail(event.data.customer.email, {
    subject: 'Payment failed',
    body: 'Your payment of NGN ' + (event.data.amount / 100) + ' could not be processed. Reason: ' + reason + '. Please try a different card.',
  });
}

Test this by sending the decline test card through your actual checkout flow in test mode, then verifying the webhook fires and your order status updates to payment_failed.

Get weekly developer tips

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

No spam. Unsubscribe anytime.

Learn More

This guide is part of the Paystack testing guide.

Sign up for the McTaba newsletter

Key Takeaways

  • ✓Card 4084080000000409 triggers "Do Not Honor" — the most common real-world decline reason.
  • ✓Card 4084080000000005 triggers "Insufficient Funds" — test that your UI suggests the customer checks their balance.
  • ✓A declined card fires a charge.failed webhook event, not charge.success — your handler must handle both.
  • ✓Never fulfill an order based on the checkout callback alone — always verify via webhook or the verify endpoint.
  • ✓Test your retry flow: can a customer enter a different card after a decline without losing their cart?
  • ✓Log the gateway_response field from decline events — it tells you exactly why the card was declined.

Frequently Asked Questions

Does Paystack send a webhook for declined cards?
Yes. Paystack fires a charge.failed webhook event when a card is declined. Your webhook endpoint receives this event with the same structure as charge.success, but with status: "failed" and a gateway_response explaining the decline reason.
How do I test that my frontend shows the right error message for each decline type?
Use the Paystack Inline popup in test mode with each decline test card. The Paystack popup will display a decline message. Additionally, check that your backend stores the gateway_response and any customer-facing messaging maps it to a helpful instruction (e.g., "Insufficient Funds" → "Please check your account balance or try a different card").
What is the difference between a declined card and a failed charge?
A declined card is when the issuing bank rejects the charge (gateway_response like "Do Not Honor" or "Insufficient Funds"). A failed charge can also result from network issues, expired cards, or Paystack's own risk checks. Both result in a charge.failed webhook event, but the gateway_response field tells you the specific reason.
Should I show the raw gateway_response to customers?
No — raw gateway responses like "Do Not Honor" are technical and unhelpful to customers. Map them to friendly messages: "Do Not Honor" → "Your bank declined this payment. Please try a different card or contact your bank." Keep the raw response in your logs for debugging but show a friendly message to the user.

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

Testing Paystack Integrations: The Complete Guide

A complete guide to testing Paystack integrations at every level: test mode, test cards, unit tests with mocks, integration tests, end-to-end flows with Playwright, webhook simulation, contract testing, CI pipelines, staging environments, load testing, and coverage targets for payment code.

Read more

Unit Testing Paystack Integrations

Unit tests for Paystack integrations focus on your business logic, not the Paystack API itself. The goal is to test that your code responds correctly to different Paystack responses — without ever calling the real API. This guide shows what to unit test and how.

Read more

Integration Testing Paystack Flows End to End

Integration tests for Paystack test the real flow — your backend calls the actual Paystack test API, a webhook fires to your server, and your database is updated. Unlike unit tests with mocks, integration tests catch issues that only appear when the real API is involved.

Read more

Seeding Test Data for a Payments Feature

Good test data is essential for testing payment features. This guide covers creating Paystack test mode resources (plans, subaccounts, split codes) and seeding your application database with matching payment records for realistic test scenarios.

Read more

Paystack Webhook Returning 419 in Laravel

Laravel returns 419 Page Expired when a POST request does not include a valid CSRF token. Paystack cannot send CSRF tokens with webhooks. The fix is to exclude your webhook route from Laravel CSRF verification. This guide shows the exact code for Laravel 11 and older versions.

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.