Understanding Stripe Error Codes
When building payment integrations with Stripe, understanding the various error codes and how to handle them properly is essential for creating a robust, user-friendly payment experience. This guide covers the fundamental concepts of Stripe error codes, with special focus on the card_velocity_exceeded code that frequently impacts subscription businesses.
What Are Stripe Error Codes?
Stripe uses a structured error code system to communicate issues that occur during API requests and payment processing. Each error response contains specific information that helps developers diagnose and handle problems appropriately.
The error system is hierarchical, with error types representing broad categories of problems and error codes providing specific details about the exact issue encountered. For example:
- Error type
card_error: Issues related to payment cards - Error code
card_velocity_exceeded: Card has exceeded velocity limits
This layered approach allows developers to handle errors at both a general level and with precise granularity depending on their use case. When Stripe returns an error, the response includes an error type, a specific error code, and a human-readable message that provides context about what went wrong. Stripe logs every successful or failed API request, which means you can review errors and monitor your integration's performance through the Stripe Dashboard or API. This logging capability is crucial for identifying recurring issues and optimizing your error handling strategy over time.
Building reliable payment integrations requires understanding these error patterns and implementing appropriate handling strategies. Our /services/web-development expertise helps businesses create seamless payment experiences that gracefully handle any error scenario.
Error Types and Categories
Stripe organizes errors into several high-level types that help categorize the nature of the problem. The most common error type is card_error, which covers issues specific to payment cards such as declines, expired cards, and insufficient funds. Another frequent type is invalid_request_error, which occurs when the API request is malformed or contains invalid parameters. Authentication errors fall under the authentication_error type, while rate limiting issues are categorized as rate_limit_error.
Common Error Types
| Error Type | Description | Example Codes |
|---|---|---|
card_error | Issues specific to payment cards | card_velocity_exceeded, card_declined, expired_card |
invalid_request_error | Malformed API requests | invalid_parameter, resource_missing |
authentication_error | API authentication failures | invalid_api_key, account_invalid |
rate_limit_error | Too many requests | rate_limit |
The card_error type is particularly important because it represents the majority of payment failures encountered in real-world scenarios. These errors often require different handling strategies depending on the specific error code. For instance, some card errors indicate temporary conditions that can be resolved by retrying the payment, while others represent permanent issues that require the customer to update their payment method.
HTTP Status Codes
Stripe uses conventional HTTP response codes to indicate the success or failure of API requests. Codes in the 2xx range indicate success, with 200 being the standard response for successful operations. When an error occurs, Stripe returns status codes in the 4xx range, indicating client errors, or 5xx range, indicating server errors.
The specific 4xx status codes help identify the general category of the error:
- 2xx: Success (200 for standard operations)
- 400: Bad Request (invalid request errors)
- 401: Unauthorized (authentication errors)
- 402: Payment Required (card errors and payment failures)
- 429: Too Many Requests (rate limit errors)
Each error response includes a JSON body with detailed information about the error. The response contains fields such as error.type, error.code, error.message, and error.param (when applicable). The error.param field specifically indicates which parameter in the request caused the error, which is invaluable for debugging invalid request errors.
The card_velocity_exceeded Error Code
What Does It Mean?
The card_velocity_exceeded error code is returned when a payment attempt is declined because the customer has exceeded the balance, credit limit, or transaction amount limit available on their card. This can happen with credit cards, virtual company cards, or due to transaction limits imposed by the card issuer. This error originates from the card issuing bank and is further categorized by card networks.
Card velocity limits are security measures implemented by card issuers to prevent fraud and protect cardholders from unauthorized usage. These limits cap the number of transactions or the total transaction amount within a specific time period, such as per day or per week. When a card exceeds these limits, subsequent transactions are automatically declined until the time period resets or the cardholder contacts their bank to authorize additional transactions.
Common Causes
Several factors can trigger the card_velocity_exceeded error:
- Transaction count limits: Maximum number of transactions within a time period
- Spending amount limits: Monetary caps on daily or weekly spending
- Unusual spending patterns: Sudden spikes triggering fraud detection
- Quick succession transactions: Multiple purchases in short timeframe
- New card limits: Newly issued cards often start with lower limits
- High-risk merchant categories: Stricter limits for certain industries
Timing issues can also play a role, particularly when budget transfers or credit limit increases have been requested but not yet processed by the card issuer.
Hard vs Soft Declines
card_velocity_exceeded is a hard decline -- it cannot be resolved by retrying the transaction. When a card's velocity has been exceeded for a defined period, the customer has no choice but to use a different payment method to complete the transaction. This distinction is crucial for implementing appropriate error handling.
| Decline Type | Retry Possible | Resolution |
|---|---|---|
| Hard (card_velocity_exceeded) | No | Customer must update payment method |
| Soft (insufficient_funds) | Sometimes | Retry or customer action |
For subscription businesses, hard declines present a significant challenge because automatic retry attempts will not resolve the issue. Stripe does not retry hard declines automatically through their standard smart retry system, which is appropriate because retrying would simply result in repeated failures. Instead, merchants should implement their own logic to identify hard declines and trigger appropriate recovery workflows.
Handling card_velocity_exceeded in Your Integration
Best Practices
When the card_velocity_exceeded error occurs, the most effective resolution is to request that the customer update their payment method. This requires implementing a seamless customer experience that makes it easy for users to enter new card information without navigating away from your application.
- Request payment method update: Provide a seamless way for customers to enter new card information
- Clear user messaging: Translate technical codes into user-friendly language
- Implement dunning workflows: Automate customer notifications for hard declines
- Monitor and log errors: Track decline patterns and recovery rates
Recommended Customer Messaging
Instead of displaying technical error codes, communicate clearly:
"Your card has reached its transaction limit. Please try a different payment method or contact your bank to resolve this issue."
Code Example
// Handle card errors with specific codes
const handleStripeError = (error: Stripe.StripeError) => {
switch (error.code) {
case 'card_velocity_exceeded':
// Hard decline - requires customer action
showCustomerNotification(
'Payment method needs update',
'Your card has reached its limit. Please update your payment method.'
);
redirectToBillingPortal(customerId);
break;
case 'card_declined':
// Could be temporary - offer retry
showRetryOption('Card was declined. Try again?');
break;
default:
// Generic error handling
showErrorMessage(error.message);
}
};
Dunning Workflow Components
For subscription businesses, implementing a dunning workflow is essential:
- Email notification within hours of failure
- Inline payment update via billing portal
- Multiple retry attempts over days
- Service pause notice with clear restore path
- Ultimate subscription cancellation if unresolved
Automating the customer communication workflow is essential. When card_velocity_exceeded occurs, trigger an email notification that explains the issue, suggests contacting their bank if they believe this is an error, and provides a direct link to update their payment method. Leveraging our /services/ai-automation expertise can help you build intelligent dunning workflows that recover more revenue automatically.
Error Handling Best Practices
Implementing Robust Error Handling
Effective error handling requires a multi-layered approach that addresses different types of errors with appropriate strategies. Start by categorizing errors based on their type and determining whether they can be resolved automatically through retry logic or require customer intervention.
Key strategies:
- Graceful degradation: Don't block entire checkout on payment failure
- Webhook listening: Handle async payment failures (subscription renewals)
- State preservation: Save progress to resume after payment update
- Idempotency: Prevent duplicate charges on retry
Use Stripe's webhooks to receive notifications about asynchronous events, including payment failures that occur after the initial checkout process. Webhooks are essential for handling scenarios such as subscription payment failures, where the initial payment succeeds but a subsequent recurring payment fails. Our team has extensive experience implementing webhook-based systems that handle complex payment scenarios reliably.
User Experience Guidelines
The way you communicate errors to customers significantly impacts conversion rates and customer satisfaction:
- Translate technical error codes to user-friendly messages
- Provide multiple resolution paths
- Include support links for complex issues
- Test error flows regularly with test cards
Logging and Monitoring
Implement comprehensive logging:
- Error type, code, message, and parameters
- Customer ID, subscription ID, timestamp
- Geographic and segmentation data
Set up alerts for:
- Sudden error rate increases
- Specific error code spikes
- Recovery rate changes
Testing Error Scenarios
Use Stripe's test card numbers to simulate:
- card_velocity_exceeded
- card_declined
- expired_card
- insufficient_funds
- authentication failures
Verify complete user journey including recovery flows. When testing, verify that your integration correctly identifies the error type and code, displays appropriate user feedback, and triggers any automated workflows. Partnering with our /services/web-development team ensures your payment integration is thoroughly tested and production-ready.
Common Error Codes Reference
Payment-Related Error Codes
| Error Code | Description | Action Required |
|---|---|---|
card_velocity_exceeded | Card limits exceeded | Customer must update payment method |
card_declined | Bank refused transaction | Try different payment method |
expired_card | Card past expiration date | Update payment method |
insufficient_funds | Not enough funds | Retry or different payment method |
incorrect_cvc | Security code mismatch | Re-enter card information |
processing_error | Processing failure | Retry after brief delay |
Request Validation Errors
| Error Code | Description | Action Required |
|---|---|---|
invalid_parameter | Missing or invalid parameter | Fix request parameters |
resource_missing | Referenced object doesn't exist | Verify IDs and references |
Authentication Errors
| Error Code | Description | Action Required |
|---|---|---|
invalid_api_key | API key is invalid | Check API key configuration |
account_invalid | Stripe account issue | Verify account status |
Rate Limiting
| Error Code | Description | Action Required |
|---|---|---|
rate_limit | Too many requests | Implement backoff and retry |
Sources
- Stripe Error Codes Documentation - Official Stripe documentation covering all API error codes, error types, and handling patterns
- Stripe Testing Documentation - Official guide for test card numbers and error simulation scenarios
- Churnkey: Card Velocity Exceeded Decline Code Guide - Comprehensive coverage of the card_velocity_exceeded error code for subscription businesses
Frequently Asked Questions
What is card_velocity_exceeded in Stripe?
card_velocity_exceeded is a hard decline error that occurs when a customer has exceeded their card's transaction or spending limits. This can happen due to daily/weekly transaction count limits, spending amount caps, or unusual spending patterns that trigger fraud prevention measures.
Can I retry a card_velocity_exceeded error?
No, card_velocity_exceeded is a hard decline meaning retry attempts will also fail. The customer must update their payment method or contact their bank to resolve the underlying issue. Implement dunning campaigns to guide customers through this recovery process.
How do I test card_velocity_exceeded in Stripe?
Use Stripe's test card numbers that are specifically configured to trigger this decline code. Refer to the Stripe Testing Documentation for the complete list of test cards and the scenarios they simulate.
What's the difference between hard and soft declines?
Hard declines (like card_velocity_exceeded) cannot be resolved through retry and require customer intervention. Soft declines (like insufficient_funds) may be resolved by retrying after a delay or with customer action.
How should I communicate card_velocity_exceeded to customers?
Avoid technical language and provide clear, actionable guidance. Explain that their card has reached its limit and provide a direct link to update their payment method. Include an option to contact support if they believe this is an error.
Stripe Payment Intents
Learn how to create and manage payment intents for secure payment processing.
Learn moreStripe Subscriptions
Implement recurring billing with Stripe's subscription management features.
Learn moreStripe Webhooks
Handle asynchronous events and payment notifications with webhooks.
Learn more