stripe-decline-codes 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/data/decline-codes.ts","../src/index.ts"],"sourcesContent":["import type { DeclineCode, DeclineCodeInfo } from '../types.js';\n\n/**\n * Stripe API documentation version for decline codes\n * Last updated: 2024-12\n * Reference: https://docs.stripe.com/declines/codes\n */\nexport const DOC_VERSION = '2024-12-18';\n\n/**\n * Complete database of Stripe decline codes with descriptions and recommended actions\n * Includes English and Japanese translations\n */\nexport const DECLINE_CODES: Record<DeclineCode, DeclineCodeInfo> = {\n approve_with_id: {\n description: 'The payment cannot be authorized.',\n nextSteps:\n 'The payment should be attempted again. If it still cannot be processed, the customer needs to contact their card issuer.',\n nextUserAction:\n 'Please try again. If it still cannot be processed, the please contact your card issuer.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: '支払いは承認できません。',\n nextUserAction:\n 'もう一度やり直してください。それでも処理できない場合は、カード発行会社にお問い合わせください。',\n },\n },\n },\n call_issuer: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps: 'The customer needs to contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n card_not_supported: {\n description: 'The card does not support this type of purchase.',\n nextSteps:\n 'The customer needs to contact their card issuer to make sure their card can be used to make this type of purchase.',\n nextUserAction:\n 'Your card issuer may not support this type of purchase, please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードはこのタイプの購入をサポートしません。',\n nextUserAction:\n 'カード発行者はこのタイプの購入をサポートしていない可能性があります。詳細については、カード発行会社にお問い合わせください。',\n },\n },\n },\n card_velocity_exceeded: {\n description: 'The customer has exceeded the balance or credit limit available on their card.',\n nextSteps: 'The customer should contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'このカードの残高またはクレジット制限を超えました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n currency_not_supported: {\n description: 'The card does not support the specified currency.',\n nextSteps:\n 'The customer needs to check with the issuer whether the card can be used for the type of currency specified.',\n nextUserAction:\n 'Please contact your card issuer to verify this type of currency can be used for this payment.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは指定された通貨をサポートしていません。',\n nextUserAction:\n 'この支払いにこのタイプの通貨が使用できることを確認するには、カード発行会社に連絡してください。',\n },\n },\n },\n do_not_honor: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps: 'The customer needs to contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n do_not_try_again: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps: 'The customer should contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n duplicate_transaction: {\n description:\n 'A transaction with identical amount and credit card information was submitted very recently.',\n nextSteps: 'Check to see if a recent payment already exists.',\n nextUserAction: 'Check to see if a recent payment already exists.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'ごく最近、同一の金額とクレジットカード情報を使用した取引が送信されました。',\n nextUserAction: '最近の支払いが既に存在するかどうかを確認してください。',\n },\n },\n },\n expired_card: {\n description: 'The card has expired.',\n nextSteps: 'The customer should use another card.',\n nextUserAction: 'Please use another card.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは期限切れです。',\n nextUserAction: '別のカードを使用してください。',\n },\n },\n },\n fraudulent: {\n description: 'The payment has been declined as Stripe suspects it is fraudulent.',\n nextSteps:\n 'Do not report more detailed information to your customer. Instead, present as you would the generic_decline described below.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: '不正と思われるため、支払いは拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n generic_decline: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps: 'The customer needs to contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n incorrect_number: {\n description: 'The card number is incorrect.',\n nextSteps: 'The customer should try again using the correct card number.',\n nextUserAction:\n 'Please check your card numbers and try again. If it still cannot be processed, the please contact your card issuer.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カード番号が正しくありません。',\n nextUserAction:\n 'カード番号を確認してもう一度やり直してください。それでも処理できない場合は、カード発行会社にお問い合わせください。',\n },\n },\n },\n incorrect_cvc: {\n description: 'The CVC number is incorrect.',\n nextSteps: 'The customer should try again using the correct CVC.',\n nextUserAction:\n 'Please check your card numbers and try again. If it still cannot be processed, the please contact your card issuer.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'CVC番号が正しくありません。',\n nextUserAction:\n 'CSC番号を確認してもう一度やり直してください。それでも処理できない場合は、カード発行会社にお問い合わせください。',\n },\n },\n },\n incorrect_pin: {\n description:\n 'The PIN entered is incorrect. This decline code only applies to payments made with a card reader.',\n nextSteps: 'The customer should try again using the correct PIN.',\n nextUserAction:\n 'Please check your PIN and try again. If it still cannot be processed, the please contact your card issuer.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'PINコードが正しくありません。',\n nextUserAction:\n 'PINコードを確認してもう一度やり直してください。それでも処理できない場合は、カード発行会社にお問い合わせください。',\n },\n },\n },\n incorrect_zip: {\n description: 'The ZIP/postal code is incorrect.',\n nextSteps: 'The customer should try again using the correct billing ZIP/postal code.',\n nextUserAction: 'Please try again using the correct ZIP/postal code.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: '郵便番号が正しくありません。',\n nextUserAction: '正しい郵便番号を使用してもう一度お試しください。',\n },\n },\n },\n insufficient_funds: {\n description: 'The card has insufficient funds to complete the purchase.',\n nextSteps: 'The customer should use an alternative payment method.',\n nextUserAction: 'Please try again using an alternative payment method.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'カードの購入に必要な資金が不足しています。',\n nextUserAction: '別のお支払い方法を使用してもう一度お試しください。',\n },\n },\n },\n invalid_account: {\n description: 'The card, or account the card is connected to, is invalid.',\n nextSteps:\n 'The customer needs to contact their card issuer to check that the card is working correctly.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カード、またはカードが接続されているアカウントが無効です。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n invalid_amount: {\n description: 'The payment amount is invalid, or exceeds the amount that is allowed.',\n nextSteps:\n 'If the amount appears to be correct, the customer needs to check with their card issuer that they can make purchases of that amount.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: '支払い金額が無効であるか、許可されている金額を超えています。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n invalid_cvc: {\n description: 'The CVC number is incorrect.',\n nextSteps: 'The customer should try again using the correct CVC.',\n nextUserAction: 'Please try again using the correct CVC.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'CVC番号が正しくありません。',\n nextUserAction: '正しいCVCを使用してもう一度やり直してください。',\n },\n },\n },\n invalid_expiry_year: {\n description: 'The expiration year invalid.',\n nextSteps: 'The customer should try again using the correct expiration date.',\n nextUserAction: 'Please try again using the correct expiration date.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: '有効期限が無効です。',\n nextUserAction: '正しい有効期限を入力してもう一度お試しください。',\n },\n },\n },\n invalid_number: {\n description: 'The card number is incorrect.',\n nextSteps: 'The customer should try again using the correct card number.',\n nextUserAction: 'Please try again using the correct card number.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カード番号が正しくありません。',\n nextUserAction: '正しいカード番号を使用してもう一度やり直してください。',\n },\n },\n },\n invalid_pin: {\n description:\n 'The PIN entered is incorrect. This decline code only applies to payments made with a card reader.',\n nextSteps: 'The customer should try again using the correct PIN.',\n nextUserAction: 'Please try again using the correct card PIN.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'PINコードが正しくありません。',\n nextUserAction: '正しいPINコードを使用してもう一度やり直してください。',\n },\n },\n },\n issuer_not_available: {\n description: 'The card issuer could not be reached, so the payment could not be authorized.',\n nextSteps:\n 'The payment should be attempted again. If it still cannot be processed, the customer needs to contact their card issuer.',\n nextUserAction:\n 'Please try again. If it still cannot be processed, the please contact your card issuer.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'カード発行者に連絡できなかったため、支払いを承認できませんでした。',\n nextUserAction:\n 'もう一度やり直してください。それでも処理できない場合は、カード発行会社にお問い合わせください。',\n },\n },\n },\n lost_card: {\n description: 'The payment has been declined because the card is reported lost.',\n nextSteps:\n 'The specific reason for the decline should not be reported to the customer. Instead, it needs to be presented as a generic decline.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n merchant_blacklist: {\n description:\n \"The payment has been declined because it matches a value on the Stripe user's blocklist.\",\n nextSteps:\n 'Do not report more detailed information to your customer. Instead, present as you would the generic_decline described above.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n new_account_information_available: {\n description: 'The card, or account the card is connected to, is invalid.',\n nextSteps: 'The customer needs to contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'カード、またはカードが接続されているアカウントが無効です。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n no_action_taken: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps: 'The customer should contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n not_permitted: {\n description: 'The payment is not permitted.',\n nextSteps: 'The customer needs to contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: '支払いは許可されていません。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n pickup_card: {\n description:\n 'The card cannot be used to make this payment (it is possible it has been reported lost or stolen).',\n nextSteps: 'The customer needs to contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description:\n 'カードでこの支払いを行うことはできません(紛失または盗難にあったと報告されている可能性があります)。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n pin_try_exceeded: {\n description: 'The allowable number of PIN tries has been exceeded.',\n nextSteps: 'The customer must use another card or method of payment.',\n nextUserAction: 'Please use another card or method of payment.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'PIN試行回数の上限を超えました。',\n nextUserAction: '別のカードまたはお支払い方法をご利用ください。',\n },\n },\n },\n processing_error: {\n description: 'An error occurred while processing the card.',\n nextSteps:\n 'The payment should be attempted again. If it still cannot be processed, try again later.',\n nextUserAction:\n 'Please try again. If it still cannot be processed, the please contact your card issuer.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'カードの処理中にエラーが発生しました。',\n nextUserAction:\n 'もう一度やり直してください。それでも処理できない場合は、カード発行会社にお問い合わせください。',\n },\n },\n },\n reenter_transaction: {\n description: 'The payment could not be processed by the issuer for an unknown reason.',\n nextSteps:\n 'The payment should be attempted again. If it still cannot be processed, the customer needs to contact their card issuer.',\n nextUserAction:\n 'Please try again. If it still cannot be processed, the please contact your card issuer.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: '原因不明のため、発行者が支払いを処理できませんでした。',\n nextUserAction:\n 'もう一度やり直してください。それでも処理できない場合は、カード発行会社にお問い合わせください。',\n },\n },\n },\n restricted_card: {\n description:\n 'The card cannot be used to make this payment (it is possible it has been reported lost or stolen).',\n nextSteps: 'The customer needs to contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description:\n 'カードでこの支払いを行うことはできません(紛失または盗難にあったと報告されている可能性があります)。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n revocation_of_all_authorizations: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps: 'The customer should contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n revocation_of_authorization: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps: 'The customer should contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n security_violation: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps: 'The customer needs to contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n service_not_allowed: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps: 'The customer should contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n stolen_card: {\n description: 'The payment has been declined because the card is reported stolen.',\n nextSteps:\n 'The specific reason for the decline should not be reported to the customer. Instead, it needs to be presented as a generic decline.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n stop_payment_order: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps: 'The customer should contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n testmode_decline: {\n description: 'A Stripe test card number was used.',\n nextSteps: 'A genuine card must be used to make a payment.',\n nextUserAction: 'A genuine card must be used to make a payment.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'Stripeテストカード番号を使用しました。',\n nextUserAction: '支払いには本物のカードを使用する必要があります。',\n },\n },\n },\n transaction_not_allowed: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps: 'The customer needs to contact their card issuer for more information.',\n nextUserAction: 'Please contact your card issuer for more information.',\n category: 'HARD_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction: '詳しくはカード発行会社にお問い合わせください。',\n },\n },\n },\n try_again_later: {\n description: 'The card has been declined for an unknown reason.',\n nextSteps:\n 'Ask the customer to attempt the payment again. If subsequent payments are declined, the customer should contact their card issuer for more information.',\n nextUserAction:\n 'Please try again. If it still cannot be processed, the please contact your card issuer.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'カードは未知の理由で拒否されました。',\n nextUserAction:\n 'もう一度やり直してください。それでも処理できない場合は、カード発行会社にお問い合わせください。',\n },\n },\n },\n withdrawal_count_limit_exceeded: {\n description: 'The customer has exceeded the balance or credit limit available on their card.',\n nextSteps: 'The customer should use an alternative payment method.',\n nextUserAction: 'Please use another card or contact your card issuer for more information.',\n category: 'SOFT_DECLINE',\n translations: {\n ja: {\n description: 'このカードの残高またはクレジット制限を超えました。',\n nextUserAction: '別のカードを使用するか、カード発行会社にお問い合わせください。',\n },\n },\n },\n};\n","import { DECLINE_CODES, DOC_VERSION } from './data/decline-codes.js';\nimport type {\n DeclineCategory,\n DeclineCode,\n DeclineCodeResult,\n Locale,\n StripeDeclineError,\n StripeError,\n} from './types.js';\n\n/**\n * Get decline code information with description and recommended actions\n *\n * @param declineCode - The Stripe decline code to look up\n * @returns Object containing the decline code information and documentation version\n *\n * @example\n * ```ts\n * const result = getDeclineDescription('insufficient_funds');\n * console.log(result.code.description);\n * // => \"The card has insufficient funds to complete the purchase.\"\n * console.log(result.code.nextUserAction);\n * // => \"Please try again using an alternative payment method.\"\n * ```\n */\nexport function getDeclineDescription(declineCode?: string): DeclineCodeResult {\n if (!declineCode || !isValidDeclineCode(declineCode)) {\n return {\n docVersion: DOC_VERSION,\n code: {},\n };\n }\n\n const code = DECLINE_CODES[declineCode];\n return {\n docVersion: DOC_VERSION,\n code,\n };\n}\n\n/**\n * Get localized decline code message for end users\n *\n * @param declineCode - The Stripe decline code\n * @param locale - The locale to use (default: 'en')\n * @returns User-facing message in the specified locale, or undefined if not found\n *\n * @example\n * ```ts\n * const message = getDeclineMessage('insufficient_funds', 'ja');\n * console.log(message);\n * // => \"別のお支払い方法を使用してもう一度お試しください。\"\n * ```\n */\nexport function getDeclineMessage(declineCode: string, locale: Locale = 'en'): string | undefined {\n if (!isValidDeclineCode(declineCode)) {\n return undefined;\n }\n\n const codeInfo = DECLINE_CODES[declineCode];\n\n if (locale === 'en') {\n return codeInfo.nextUserAction;\n }\n\n return codeInfo.translations?.[locale]?.nextUserAction;\n}\n\n/**\n * Get all available decline codes\n *\n * @returns Array of all supported decline code strings\n *\n * @example\n * ```ts\n * const codes = getAllDeclineCodes();\n * console.log(codes.length); // => 44\n * console.log(codes.includes('insufficient_funds')); // => true\n * ```\n */\nexport function getAllDeclineCodes(): DeclineCode[] {\n return Object.keys(DECLINE_CODES) as DeclineCode[];\n}\n\n/**\n * Check if a decline code is valid\n *\n * @param code - The code to validate\n * @returns True if the code exists in the database\n *\n * @example\n * ```ts\n * isValidDeclineCode('insufficient_funds'); // => true\n * isValidDeclineCode('invalid_code'); // => false\n * ```\n */\nexport function isValidDeclineCode(code: string): code is DeclineCode {\n return Object.hasOwn(DECLINE_CODES, code);\n}\n\n/**\n * Get the documentation version for the decline codes data\n *\n * @returns The Stripe API documentation version string\n *\n * @example\n * ```ts\n * const version = getDocVersion();\n * console.log(version); // => \"2024-12-18\"\n * ```\n */\nexport function getDocVersion(): string {\n return DOC_VERSION;\n}\n\n/**\n * Format a decline message with custom template variables\n *\n * @param declineCode - The Stripe decline code\n * @param locale - The locale to use (default: 'en')\n * @param variables - Optional variables to replace in the message template\n * @returns Formatted user-facing message with variables replaced\n *\n * @example\n * ```ts\n * const message = formatDeclineMessage('insufficient_funds', 'en', {\n * merchantName: 'Acme Store',\n * supportEmail: 'support@acme.com'\n * });\n * console.log(message);\n * // => \"Please try again using an alternative payment method.\"\n * ```\n */\nexport function formatDeclineMessage(\n declineCode: string,\n locale: Locale = 'en',\n variables?: Record<string, string>,\n): string | undefined {\n const baseMessage = getDeclineMessage(declineCode, locale);\n\n if (!baseMessage) {\n return undefined;\n }\n\n if (!variables || Object.keys(variables).length === 0) {\n return baseMessage;\n }\n\n // Replace variables in the format {{variableName}}\n let formattedMessage = baseMessage;\n for (const [key, value] of Object.entries(variables)) {\n // Escape special regex characters in the key\n const escapedKey = key.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const placeholder = new RegExp(`\\\\{\\\\{${escapedKey}\\\\}\\\\}`, 'g');\n formattedMessage = formattedMessage.replace(placeholder, value);\n }\n\n return formattedMessage;\n}\n\n/**\n * Get the category of a decline code (SOFT_DECLINE or HARD_DECLINE)\n *\n * @param code - The decline code to categorize\n * @returns The category of the decline code, or undefined if invalid\n *\n * @example\n * ```ts\n * getDeclineCategory('insufficient_funds'); // => 'SOFT_DECLINE'\n * getDeclineCategory('fraudulent'); // => 'HARD_DECLINE'\n * ```\n */\nexport function getDeclineCategory(code: string): DeclineCategory | undefined {\n if (!isValidDeclineCode(code)) {\n return undefined;\n }\n\n return DECLINE_CODES[code].category;\n}\n\n/**\n * Check if a decline code is a hard decline (permanent, should not retry)\n *\n * @param code - The decline code to check\n * @returns True if the code is a hard decline\n *\n * @example\n * ```ts\n * isHardDecline('fraudulent'); // => true\n * isHardDecline('insufficient_funds'); // => false\n * ```\n */\nexport function isHardDecline(code: string): boolean {\n return getDeclineCategory(code) === 'HARD_DECLINE';\n}\n\n/**\n * Check if a decline code is a soft decline (temporary, can retry)\n *\n * @param code - The decline code to check\n * @returns True if the code is a soft decline\n *\n * @example\n * ```ts\n * isSoftDecline('insufficient_funds'); // => true\n * isSoftDecline('fraudulent'); // => false\n * ```\n */\nexport function isSoftDecline(code: string): boolean {\n return getDeclineCategory(code) === 'SOFT_DECLINE';\n}\n\n/**\n * Extract localized message from a Stripe error object\n *\n * @param error - The Stripe error object (or any caught value)\n * @param locale - The locale to use (default: 'en')\n * @returns User-facing message in the specified locale, or undefined if not found\n *\n * @example\n * ```ts\n * const stripeError = {\n * type: 'StripeCardError',\n * decline_code: 'insufficient_funds',\n * message: 'Your card has insufficient funds.'\n * };\n * const message = getMessageFromStripeError(stripeError, 'ja');\n * console.log(message);\n * // => \"別のお支払い方法を使用してもう一度お試しください。\"\n * ```\n */\nexport function getMessageFromStripeError(\n error: unknown,\n locale: Locale = 'en',\n): string | undefined {\n if (!isStripeDeclineError(error)) {\n return undefined;\n }\n\n return getDeclineMessage(error.decline_code, locale);\n}\n\n/**\n * Type guard that narrows an unknown error to one carrying a known Stripe decline code\n *\n * Returns true when `error` is an object whose `decline_code` is a valid\n * {@link DeclineCode}. Designed for `catch` blocks: a `StripeCardError` from\n * stripe-node >= 18 (where `decline_code` is a required `string`) narrows\n * straight to {@link StripeDeclineError}; errors from stripe-node <= 17 or\n * plain objects fall back through the same runtime check.\n *\n * @param error - The value to check (e.g. a caught Stripe error)\n * @returns True if the error carries a known decline code\n *\n * @example\n * ```ts\n * try {\n * await stripe.charges.create({ ... });\n * } catch (err) {\n * if (isStripeDeclineError(err)) {\n * // err.decline_code is typed as DeclineCode here\n * console.log(getDeclineMessage(err.decline_code, 'ja'));\n * }\n * }\n * ```\n */\nexport function isStripeDeclineError(error: unknown): error is StripeDeclineError {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'decline_code' in error &&\n typeof (error as StripeError).decline_code === 'string' &&\n isValidDeclineCode((error as StripeDeclineError).decline_code)\n );\n}\n\n/**\n * Extract a validated decline code from a Stripe error object\n *\n * Unlike `getMessageFromStripeError`, this returns the decline code itself\n * (typed as {@link DeclineCode}) so it can be passed to any other helper in\n * this library. Accepts `unknown` so caught errors can be passed directly.\n *\n * @param error - The Stripe error object (or any caught value)\n * @returns The decline code, or undefined if absent or unknown\n *\n * @example\n * ```ts\n * try {\n * await stripe.charges.create({ ... });\n * } catch (err) {\n * const code = getDeclineCodeFromError(err);\n * if (code && isSoftDecline(code)) {\n * // safe to retry\n * }\n * }\n * ```\n */\nexport function getDeclineCodeFromError(error: unknown): DeclineCode | undefined {\n return isStripeDeclineError(error) ? error.decline_code : undefined;\n}\n\n// Export data for advanced use cases\nexport { DECLINE_CODES, DOC_VERSION } from './data/decline-codes.js';\n// Export types\nexport type {\n DeclineCategory,\n DeclineCode,\n DeclineCodeInfo,\n DeclineCodeResult,\n Locale,\n StripeDeclineError,\n StripeError,\n Translation,\n} from './types.js';\n"],"names":["DOC_VERSION","DECLINE_CODES","getDeclineDescription","declineCode","isValidDeclineCode","code","getDeclineMessage","locale","codeInfo","getAllDeclineCodes","getDocVersion","formatDeclineMessage","variables","baseMessage","formattedMessage","key","value","escapedKey","placeholder","getDeclineCategory","isHardDecline","isSoftDecline","getMessageFromStripeError","error","isStripeDeclineError","getDeclineCodeFromError"],"mappings":"AAOO,MAAMA,IAAc,cAMdC,IAAsD;AAAA,EACjE,iBAAiB;AAAA,IACf,aAAa;AAAA,IACb,WACE;AAAA,IACF,gBACE;AAAA,IACF,UAAU;AAAA,IACV,cAAc;AAAA,MACZ,IAAI;AAAA,QACF,aAAa;AAAA,QACb,gBACE;AAAA,MAAA;AAAA,IACJ;AAAA,EACF;AAAA,EAEF,aAAa;AAAA,IACX,aAAa;AAAA,IACb,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,cAAc;AAAA,MACZ,IAAI;AAAA,QACF,aAAa;AAAA,QACb,gBAAgB;AAAA,MAAA;AAAA,IAClB;AAAA,EACF;AAAA,EAEF,oBAAoB;AAAA,IAClB,aAAa;AAAA,IACb,WACE;AAAA,IACF,gBACE;AAAA,IACF,UAAU;AAAA,IACV,cAAc;AAAA,MACZ,IAAI;AAAA,QACF,aAAa;AAAA,QACb,gBACE;AAAA,MAAA;AAAA,IACJ;AAAA,EACF;AAAA,EAEF,wBAAwB;AAAA,IACtB,aAAa;AAAA,IACb,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,cAAc;AAAA,MACZ,IAAI;AAAA,QACF,aAAa;AAAA,QACb,gBAAgB;AAAA,MAAA;AAAA,IAClB;AAAA,EACF;AAAA,EAEF,wBAAwB;AAAA,IACtB,aAAa;AAAA,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AOF;AACT;AAcO,SAASK,EAAmBd,GAA2C;AAC5E,MAAKD,EAAmBC,CAAI;AAI5B,WAAOJ,EAAcI,CAAI,EAAE;AAC7B;AAcO,SAASe,EAAcf,GAAuB;AACnD,SAAOc,EAAmBd,CAAI,MAAM;AACtC;AAcO,SAASgB,EAAchB,GAAuB;AACnD,SAAOc,EAAmBd,CAAI,MAAM;AACtC;AAqBO,SAASiB,EACdC,GACAhB,IAAiB,MACG;AACpB,MAAKiB,EAAqBD,CAAK;AAI/B,WAAOjB,EAAkBiB,EAAM,cAAchB,CAAM;AACrD;AA0BO,SAASiB,EAAqBD,GAA6C;AAChF,SACE,OAAOA,KAAU,YACjBA,MAAU,QACV,kBAAkBA,KAClB,OAAQA,EAAsB,gBAAiB,YAC/CnB,EAAoBmB,EAA6B,YAAY;AAEjE;AAwBO,SAASE,EAAwBF,GAAyC;AAC/E,SAAOC,EAAqBD,CAAK,IAAIA,EAAM,eAAe;AAC5D;"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Supported locale codes for decline code translations
3
+ */
4
+ export type Locale = 'en' | 'ja';
5
+ /**
6
+ * Decline code categories based on Stripe's classification
7
+ */
8
+ export type DeclineCategory = 'SOFT_DECLINE' | 'HARD_DECLINE';
9
+ /**
10
+ * Translation for a specific locale
11
+ */
12
+ export interface Translation {
13
+ description: string;
14
+ nextUserAction: string;
15
+ }
16
+ /**
17
+ * Decline code information including descriptions and recommended actions
18
+ */
19
+ export interface DeclineCodeInfo {
20
+ /** Technical description of why the payment was declined */
21
+ description: string;
22
+ /** Recommended next steps for merchants */
23
+ nextSteps: string;
24
+ /** User-facing message that can be shown to customers */
25
+ nextUserAction: string;
26
+ /** Category of the decline (soft or hard) */
27
+ category: DeclineCategory;
28
+ /** Translations for different locales */
29
+ translations?: Partial<Record<Locale, Translation>>;
30
+ }
31
+ /**
32
+ * Result containing decline code information and metadata
33
+ */
34
+ export interface DeclineCodeResult {
35
+ /** Stripe API documentation version */
36
+ docVersion: string;
37
+ /** Decline code information, or empty object if code not found */
38
+ code: DeclineCodeInfo | Record<string, never>;
39
+ }
40
+ /**
41
+ * Stripe error object with decline code information
42
+ */
43
+ export interface StripeError {
44
+ type?: string;
45
+ decline_code?: string;
46
+ message?: string;
47
+ [key: string]: unknown;
48
+ }
49
+ /**
50
+ * A Stripe error known to carry a valid decline code.
51
+ *
52
+ * Matches the stripe-node >= 18 `StripeCardError` shape, where `decline_code`
53
+ * is a required string, narrowed further to the {@link DeclineCode} union.
54
+ * Errors from stripe-node <= 17 (where `decline_code` is optional) or plain
55
+ * objects can be narrowed to this type with `isStripeDeclineError`.
56
+ */
57
+ export interface StripeDeclineError extends StripeError {
58
+ decline_code: DeclineCode;
59
+ }
60
+ /**
61
+ * All supported Stripe decline codes
62
+ */
63
+ export type DeclineCode = 'approve_with_id' | 'call_issuer' | 'card_not_supported' | 'card_velocity_exceeded' | 'currency_not_supported' | 'do_not_honor' | 'do_not_try_again' | 'duplicate_transaction' | 'expired_card' | 'fraudulent' | 'generic_decline' | 'incorrect_number' | 'incorrect_cvc' | 'incorrect_pin' | 'incorrect_zip' | 'insufficient_funds' | 'invalid_account' | 'invalid_amount' | 'invalid_cvc' | 'invalid_expiry_year' | 'invalid_number' | 'invalid_pin' | 'issuer_not_available' | 'lost_card' | 'merchant_blacklist' | 'new_account_information_available' | 'no_action_taken' | 'not_permitted' | 'pickup_card' | 'pin_try_exceeded' | 'processing_error' | 'reenter_transaction' | 'restricted_card' | 'revocation_of_all_authorizations' | 'revocation_of_authorization' | 'security_violation' | 'service_not_allowed' | 'stolen_card' | 'stop_payment_order' | 'testmode_decline' | 'transaction_not_allowed' | 'try_again_later' | 'withdrawal_count_limit_exceeded';
64
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAEj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