Stripe decline codes
A TypeScript library providing human-readable descriptions and localized user messages for all 44 Stripe payment decline codes. Zero dependencies, fully typed, and supports English and Japanese translations to improve payment error user experience.
Key Features
- Complete Coverage: All 44 Stripe decline codes included
- Localization: English and Japanese translations built-in
- Type Safe: Full TypeScript type definitions provided
- Current: Based on Stripe API documentation from December 2024
- Lightweight: Zero external dependencies
- Flexible: Custom message formatting support
Installation
npm install stripe-decline-codesPrimary Functions
getDeclineDescription()
Returns detailed information about a specific decline code, including descriptions, next steps, and translations.
import { getDeclineDescription } from 'stripe-decline-codes';
const info = getDeclineDescription('card_declined');
console.log(info.description);
console.log(info.nextSteps);
console.log(info.translations.en);getDeclineMessage()
Delivers localized user-facing messages. Users can specify language preference ('en' or 'ja').
import { getDeclineMessage } from 'stripe-decline-codes';
const message = getDeclineMessage('insufficient_funds', 'en');
console.log(message); // "The card was declined due to insufficient funds."formatDeclineMessage()
Enables custom message formatting with variable substitution for merchant names or support details.
import { formatDeclineMessage } from 'stripe-decline-codes';
const message = formatDeclineMessage('card_declined', 'en', {
merchantName: 'Example Store',
supportEmail: 'support@example.com'
});Benefits
When handling Stripe payment errors, converting technical decline codes into customer-friendly explanations is essential. This library simplifies the translation workflow and provides consistent user experience across multilingual applications.
Related Tools & Apps
stripe-pwa-elements
Stripe payment Web Components that work with any web framework. Integrate card payments, Apple Pay, Google Pay, Payment Element and more using simple HTML tags. Built on Stencil.js for framework-agnostic usage, with PWA and Capacitor support.
stripe-search-ql
A TypeScript query builder for constructing Stripe Search API queries with type safety. Eliminate bugs caused by hand-written query strings using a fluent, chainable API that improves developer productivity.
cdk-construct-stripe-events-to-sns
I have developed a CDK Construct library for receiving Stripe payment events via AWS EventBridge and sending notifications to an SNS topic. This design reduces costs and latency by sending notifications directly from EventBridge to SNS without using Lambda functions.
