stripe-decline-codes 0.1.0 → 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-2026 Hidetaka Okamoto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -16,6 +16,8 @@ A lightweight, zero-dependency TypeScript library providing human-readable descr
16
16
  - 🔄 **Up-to-date** - Based on Stripe API documentation (2024-12-18)
17
17
  - ✅ **Well Tested** - Comprehensive test coverage
18
18
  - 🎨 **Message Formatting** - Customizable message templates with variable substitution
19
+ - 🔍 **Decline Categorization** - Soft/Hard decline classification based on Stripe guidelines
20
+ - ⚡ **Stripe SDK Integration** - Direct error object support for seamless integration
19
21
 
20
22
  ## About This Project
21
23
 
@@ -108,16 +110,72 @@ try {
108
110
  currency: 'usd',
109
111
  source: 'tok_chargeDeclined',
110
112
  });
111
- } catch (error) {
112
- if (error.type === 'StripeCardError') {
113
- const declineCode = error.decline_code;
114
- const userMessage = getDeclineMessage(declineCode, 'en');
113
+ } catch (err) {
114
+ const error = err as Stripe.StripeCardError;
115
+ if (error.type === 'card_error' && error.decline_code) {
116
+ const userMessage = getDeclineMessage(error.decline_code, 'en');
115
117
  console.log(userMessage);
116
118
  // Display this message to your user
117
119
  }
118
120
  }
119
121
  ```
120
122
 
123
+ ### Decline Code Categorization
124
+
125
+ Understand whether a decline is temporary (soft) or permanent (hard):
126
+
127
+ ```typescript
128
+ import { getDeclineCategory, isSoftDecline, isHardDecline } from 'stripe-decline-codes';
129
+
130
+ // Get the category
131
+ const category = getDeclineCategory('insufficient_funds');
132
+ console.log(category); // => 'SOFT_DECLINE'
133
+
134
+ // Check if it's a soft decline (temporary, can retry)
135
+ if (isSoftDecline('insufficient_funds')) {
136
+ console.log('This is a temporary issue, you can retry the payment');
137
+ }
138
+
139
+ // Check if it's a hard decline (permanent, should not retry)
140
+ if (isHardDecline('fraudulent')) {
141
+ console.log('This is a permanent decline, do not retry');
142
+ }
143
+ ```
144
+
145
+ ### Extract Message from Stripe Error
146
+
147
+ Directly extract user-facing messages from Stripe error objects:
148
+
149
+ ```typescript
150
+ import Stripe from 'stripe';
151
+ import { getMessageFromStripeError, isHardDecline } from 'stripe-decline-codes';
152
+
153
+ const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
154
+
155
+ try {
156
+ const charge = await stripe.charges.create({
157
+ amount: 2000,
158
+ currency: 'usd',
159
+ source: 'tok_chargeDeclined',
160
+ });
161
+ } catch (err) {
162
+ const error = err as Stripe.StripeCardError;
163
+ if (error.type === 'card_error' && error.decline_code) {
164
+ // Get localized message directly from error object
165
+ const userMessage = getMessageFromStripeError(error, 'ja');
166
+
167
+ // Check if retry is recommended
168
+ if (isHardDecline(error.decline_code)) {
169
+ // Ask for a different payment method
170
+ console.log('Please use a different card');
171
+ } else {
172
+ // Retry is possible
173
+ console.log('You may retry this payment');
174
+ }
175
+ }
176
+ }
177
+ ```
178
+
121
179
  ## API Reference
122
180
 
123
181
  ### Core Functions
@@ -180,6 +238,41 @@ const message = formatDeclineMessage('insufficient_funds', 'en', {
180
238
  });
181
239
  ```
182
240
 
241
+ ### Decline Categorization Functions
242
+
243
+ #### `getDeclineCategory(code: string): DeclineCategory | undefined`
244
+
245
+ Returns the category of a decline code ('SOFT_DECLINE' or 'HARD_DECLINE').
246
+
247
+ **Parameters:**
248
+ - `code` - The Stripe decline code
249
+
250
+ **Returns:** `'SOFT_DECLINE' | 'HARD_DECLINE' | undefined`
251
+
252
+ #### `isHardDecline(code: string): boolean`
253
+
254
+ Checks if a decline code is a hard decline (permanent, should not retry).
255
+
256
+ **Returns:** `true` if the code is a hard decline, `false` otherwise
257
+
258
+ #### `isSoftDecline(code: string): boolean`
259
+
260
+ Checks if a decline code is a soft decline (temporary, can retry).
261
+
262
+ **Returns:** `true` if the code is a soft decline, `false` otherwise
263
+
264
+ ### Stripe Error Integration
265
+
266
+ #### `getMessageFromStripeError(error: StripeError, locale?: Locale): string | undefined`
267
+
268
+ Extracts a localized user-facing message directly from a Stripe error object.
269
+
270
+ **Parameters:**
271
+ - `error` - The Stripe error object
272
+ - `locale` - The locale to use (`'en'` or `'ja'`, default: `'en'`)
273
+
274
+ **Returns:** User-facing message in the specified locale, or undefined if no decline code is present
275
+
183
276
  ## Supported Decline Codes
184
277
 
185
278
  This library includes all 44 Stripe decline codes:
@@ -239,41 +332,53 @@ import type {
239
332
  DeclineCodeResult,
240
333
  Locale,
241
334
  Translation,
335
+ DeclineCategory,
336
+ StripeError,
242
337
  } from 'stripe-decline-codes';
243
338
  ```
244
339
 
245
340
  ## Development
246
341
 
342
+ This project uses [pnpm](https://pnpm.io/) (`packageManager` is pinned in `package.json`).
343
+
247
344
  ```bash
248
345
  # Install dependencies
249
- npm install
346
+ pnpm install
250
347
 
251
348
  # Run tests
252
- npm test
349
+ pnpm test
253
350
 
254
351
  # Run tests in watch mode
255
- npm run test:watch
352
+ pnpm run test:watch
256
353
 
257
354
  # Build
258
- npm run build
355
+ pnpm run build
259
356
 
260
357
  # Lint
261
- npm run lint
358
+ pnpm run lint
262
359
 
263
360
  # Format code
264
- npm run format
361
+ pnpm run format
265
362
 
266
363
  # Type check
267
- npm run typecheck
364
+ pnpm run typecheck
268
365
  ```
269
366
 
270
- ## Publishing
367
+ The `docs/` directory is a separate npm project (Starlight site) and keeps using `npm`.
271
368
 
272
- This package uses [`np`](https://github.com/sindresorhus/np) for releases:
369
+ ## Publishing
273
370
 
274
- ```bash
275
- npm run release
276
- ```
371
+ Releases are automated by CircleCI. Merge a PR whose commits follow
372
+ [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`, â€Ļ)
373
+ into `main`, and [semantic-release](https://github.com/semantic-release/semantic-release)
374
+ pushes the git tag, publishes to npm via Trusted Publishing (OIDC), and creates the
375
+ GitHub Release. Release notes are published on
376
+ [GitHub Releases](https://github.com/hideokamoto/stripe-decline-codes/releases).
377
+ Do not bump `version`, create tags, or run `npm publish` / `np` manually.
378
+
379
+ The pipeline definition is shared via
380
+ [`circleci-configurations`](https://github.com/hideokamoto/circleci-configurations)
381
+ (`workflows/publish/npm-polyrepo-semantic-release.yaml`).
277
382
 
278
383
  ## Contributing
279
384
 
@@ -0,0 +1,13 @@
1
+ import type { DeclineCode, DeclineCodeInfo } from '../types.js';
2
+ /**
3
+ * Stripe API documentation version for decline codes
4
+ * Last updated: 2024-12
5
+ * Reference: https://docs.stripe.com/declines/codes
6
+ */
7
+ export declare const DOC_VERSION = "2024-12-18";
8
+ /**
9
+ * Complete database of Stripe decline codes with descriptions and recommended actions
10
+ * Includes English and Japanese translations
11
+ */
12
+ export declare const DECLINE_CODES: Record<DeclineCode, DeclineCodeInfo>;
13
+ //# sourceMappingURL=decline-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decline-codes.d.ts","sourceRoot":"","sources":["../../src/data/decline-codes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,WAAW,eAAe,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,WAAW,EAAE,eAAe,CA8iB9D,CAAC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o="2024-12-18",r={approve_with_id:{description:"The payment cannot be authorized.",nextSteps:"The payment should be attempted again. If it still cannot be processed, the customer needs to contact their card issuer.",nextUserAction:"Please try again. If it still cannot be processed, the please contact your card issuer.",category:"SOFT_DECLINE",translations:{ja:{description:"支払いはæ‰ŋčĒã§ããžã›ã‚“ã€‚",nextUserAction:"もう一åēĻã‚„ã‚Šį›´ã—ãĻください。それでもå‡Ļį†ã§ããĒい場合は、ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},call_issuer:{description:"The card has been declined for an unknown reason.",nextSteps:"The customer needs to contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"SOFT_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},card_not_supported:{description:"The card does not support this type of purchase.",nextSteps:"The customer needs to contact their card issuer to make sure their card can be used to make this type of purchase.",nextUserAction:"Your card issuer may not support this type of purchase, please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧドはこぎã‚ŋイプぎčŗŧå…Ĩをã‚ĩポãƒŧトしぞせん。",nextUserAction:"ã‚Ģãƒŧドį™ēčĄŒč€…ã¯ã“ãŽã‚ŋイプぎčŗŧå…Ĩをã‚ĩポãƒŧトしãĻいãĒい可čƒŊæ€§ãŒã‚ã‚Šãžã™ã€‚čŠŗį´°ãĢついãĻは、ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},card_velocity_exceeded:{description:"The customer has exceeded the balance or credit limit available on their card.",nextSteps:"The customer should contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"SOFT_DECLINE",translations:{ja:{description:"こぎã‚Ģãƒŧドぎ掋éĢ˜ãžãŸã¯ã‚¯ãƒŦジットåˆļ限をčļ…えぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},currency_not_supported:{description:"The card does not support the specified currency.",nextSteps:"The customer needs to check with the issuer whether the card can be used for the type of currency specified.",nextUserAction:"Please contact your card issuer to verify this type of currency can be used for this payment.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧãƒ‰ã¯æŒ‡åŽšã•ã‚ŒãŸé€šč˛¨ã‚’ã‚ĩポãƒŧトしãĻいぞせん。",nextUserAction:"こぎ支払いãĢこぎã‚ŋã‚¤ãƒ—ãŽé€šč˛¨ãŒäŊŋį”¨ã§ãã‚‹ã“ã¨ã‚’įĸēčĒã™ã‚‹ãĢは、ã‚Ģãƒŧドį™ē行äŧšį¤žãĢ逪įĩĄã—ãĻください。"}}},do_not_honor:{description:"The card has been declined for an unknown reason.",nextSteps:"The customer needs to contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"SOFT_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},do_not_try_again:{description:"The card has been declined for an unknown reason.",nextSteps:"The customer should contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},duplicate_transaction:{description:"A transaction with identical amount and credit card information was submitted very recently.",nextSteps:"Check to see if a recent payment already exists.",nextUserAction:"Check to see if a recent payment already exists.",category:"SOFT_DECLINE",translations:{ja:{description:"ごく最čŋ‘ã€åŒä¸€ãŽé‡‘éĄã¨ã‚¯ãƒŦジットã‚Ģãƒŧãƒ‰æƒ…å ąã‚’äŊŋį”¨ã—ãŸå–åŧ•が送äŋĄã•れぞした。",nextUserAction:"最čŋ‘ぎ支払いがæ—ĸãĢ存在するかおうかをįĸēčĒã—ãĻください。"}}},expired_card:{description:"The card has expired.",nextSteps:"The customer should use another card.",nextUserAction:"Please use another card.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧドは期限切れです。",nextUserAction:"åˆĨぎã‚ĢãƒŧドをäŊŋį”¨ã—ãĻください。"}}},fraudulent:{description:"The payment has been declined as Stripe suspects it is fraudulent.",nextSteps:"Do not report more detailed information to your customer. Instead, present as you would the generic_decline described below.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ä¸æ­Ŗã¨æ€ã‚ã‚Œã‚‹ãŸã‚ã€æ”¯æ‰•ã„ã¯æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},generic_decline:{description:"The card has been declined for an unknown reason.",nextSteps:"The customer needs to contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"SOFT_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},incorrect_number:{description:"The card number is incorrect.",nextSteps:"The customer should try again using the correct card number.",nextUserAction:"Please check your card numbers and try again. If it still cannot be processed, the please contact your card issuer.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧドį•ĒåˇãŒæ­Ŗã—ãã‚ã‚Šãžã›ã‚“ã€‚",nextUserAction:"ã‚Ģãƒŧドį•Ēåˇã‚’įĸēčĒã—ãĻもう一åēĻã‚„ã‚Šį›´ã—ãĻください。それでもå‡Ļį†ã§ããĒい場合は、ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},incorrect_cvc:{description:"The CVC number is incorrect.",nextSteps:"The customer should try again using the correct CVC.",nextUserAction:"Please check your card numbers and try again. If it still cannot be processed, the please contact your card issuer.",category:"HARD_DECLINE",translations:{ja:{description:"CVCį•ĒåˇãŒæ­Ŗã—ãã‚ã‚Šãžã›ã‚“ã€‚",nextUserAction:"CSCį•Ēåˇã‚’įĸēčĒã—ãĻもう一åēĻã‚„ã‚Šį›´ã—ãĻください。それでもå‡Ļį†ã§ããĒい場合は、ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},incorrect_pin:{description:"The PIN entered is incorrect. This decline code only applies to payments made with a card reader.",nextSteps:"The customer should try again using the correct PIN.",nextUserAction:"Please check your PIN and try again. If it still cannot be processed, the please contact your card issuer.",category:"HARD_DECLINE",translations:{ja:{description:"PINã‚ŗãƒŧãƒ‰ãŒæ­Ŗã—ãã‚ã‚Šãžã›ã‚“ã€‚",nextUserAction:"PINã‚ŗãƒŧドをįĸēčĒã—ãĻもう一åēĻã‚„ã‚Šį›´ã—ãĻください。それでもå‡Ļį†ã§ããĒい場合は、ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},incorrect_zip:{description:"The ZIP/postal code is incorrect.",nextSteps:"The customer should try again using the correct billing ZIP/postal code.",nextUserAction:"Please try again using the correct ZIP/postal code.",category:"HARD_DECLINE",translations:{ja:{description:"éƒĩäžŋį•ĒåˇãŒæ­Ŗã—ãã‚ã‚Šãžã›ã‚“ã€‚",nextUserAction:"æ­Ŗã—ã„éƒĩäžŋį•Ēåˇã‚’äŊŋį”¨ã—ãĻもう一åēĻおčŠĻしください。"}}},insufficient_funds:{description:"The card has insufficient funds to complete the purchase.",nextSteps:"The customer should use an alternative payment method.",nextUserAction:"Please try again using an alternative payment method.",category:"SOFT_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧドぎčŗŧå…ĨãĢåŋ…čρãĒčŗ‡é‡‘ãŒä¸čļŗã—ãĻいぞす。",nextUserAction:"åˆĨãŽãŠæ”¯æ‰•ã„æ–šæŗ•ã‚’äŊŋį”¨ã—ãĻもう一åēĻおčŠĻしください。"}}},invalid_account:{description:"The card, or account the card is connected to, is invalid.",nextSteps:"The customer needs to contact their card issuer to check that the card is working correctly.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧド、ぞたはã‚ĢãƒŧドがæŽĨįļšã•れãĻいるã‚ĸã‚Ģã‚ĻãƒŗãƒˆãŒį„ĄåŠšã§ã™ã€‚",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},invalid_amount:{description:"The payment amount is invalid, or exceeds the amount that is allowed.",nextSteps:"If the amount appears to be correct, the customer needs to check with their card issuer that they can make purchases of that amount.",nextUserAction:"Please contact your card issuer for more information.",category:"SOFT_DECLINE",translations:{ja:{description:"æ”¯æ‰•ã„é‡‘éĄãŒį„ĄåŠšã§ã‚ã‚‹ã‹ã€č¨ąå¯ã•ã‚ŒãĻã„ã‚‹é‡‘éĄã‚’čļ…えãĻいぞす。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},invalid_cvc:{description:"The CVC number is incorrect.",nextSteps:"The customer should try again using the correct CVC.",nextUserAction:"Please try again using the correct CVC.",category:"HARD_DECLINE",translations:{ja:{description:"CVCį•ĒåˇãŒæ­Ŗã—ãã‚ã‚Šãžã›ã‚“ã€‚",nextUserAction:"æ­Ŗã—ã„CVCをäŊŋį”¨ã—ãĻもう一åēĻã‚„ã‚Šį›´ã—ãĻください。"}}},invalid_expiry_year:{description:"The expiration year invalid.",nextSteps:"The customer should try again using the correct expiration date.",nextUserAction:"Please try again using the correct expiration date.",category:"HARD_DECLINE",translations:{ja:{description:"æœ‰åŠšæœŸé™ãŒį„ĄåŠšã§ã™ã€‚",nextUserAction:"æ­Ŗã—ã„æœ‰åŠšæœŸé™ã‚’å…Ĩ力しãĻもう一åēĻおčŠĻしください。"}}},invalid_number:{description:"The card number is incorrect.",nextSteps:"The customer should try again using the correct card number.",nextUserAction:"Please try again using the correct card number.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧドį•ĒåˇãŒæ­Ŗã—ãã‚ã‚Šãžã›ã‚“ã€‚",nextUserAction:"æ­Ŗã—ã„ã‚Ģãƒŧドį•Ēåˇã‚’äŊŋį”¨ã—ãĻもう一åēĻã‚„ã‚Šį›´ã—ãĻください。"}}},invalid_pin:{description:"The PIN entered is incorrect. This decline code only applies to payments made with a card reader.",nextSteps:"The customer should try again using the correct PIN.",nextUserAction:"Please try again using the correct card PIN.",category:"HARD_DECLINE",translations:{ja:{description:"PINã‚ŗãƒŧãƒ‰ãŒæ­Ŗã—ãã‚ã‚Šãžã›ã‚“ã€‚",nextUserAction:"æ­Ŗã—ã„PINã‚ŗãƒŧドをäŊŋį”¨ã—ãĻもう一åēĻã‚„ã‚Šį›´ã—ãĻください。"}}},issuer_not_available:{description:"The card issuer could not be reached, so the payment could not be authorized.",nextSteps:"The payment should be attempted again. If it still cannot be processed, the customer needs to contact their card issuer.",nextUserAction:"Please try again. If it still cannot be processed, the please contact your card issuer.",category:"SOFT_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧドį™ē行者ãĢ逪įĩĄã§ããĒã‹ãŖãŸãŸã‚ã€æ”¯æ‰•ã„ã‚’æ‰ŋčĒã§ããžã›ã‚“ã§ã—ãŸã€‚",nextUserAction:"もう一åēĻã‚„ã‚Šį›´ã—ãĻください。それでもå‡Ļį†ã§ããĒい場合は、ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},lost_card:{description:"The payment has been declined because the card is reported lost.",nextSteps:"The specific reason for the decline should not be reported to the customer. Instead, it needs to be presented as a generic decline.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},merchant_blacklist:{description:"The payment has been declined because it matches a value on the Stripe user's blocklist.",nextSteps:"Do not report more detailed information to your customer. Instead, present as you would the generic_decline described above.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},new_account_information_available:{description:"The card, or account the card is connected to, is invalid.",nextSteps:"The customer needs to contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"SOFT_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧド、ぞたはã‚ĢãƒŧドがæŽĨįļšã•れãĻいるã‚ĸã‚Ģã‚ĻãƒŗãƒˆãŒį„ĄåŠšã§ã™ã€‚",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},no_action_taken:{description:"The card has been declined for an unknown reason.",nextSteps:"The customer should contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"SOFT_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},not_permitted:{description:"The payment is not permitted.",nextSteps:"The customer needs to contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"æ”¯æ‰•ã„ã¯č¨ąå¯ã•ã‚ŒãĻいぞせん。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},pickup_card:{description:"The card cannot be used to make this payment (it is possible it has been reported lost or stolen).",nextSteps:"The customer needs to contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧãƒ‰ã§ã“ãŽæ”¯æ‰•ã„ã‚’čĄŒã†ã“ã¨ã¯ã§ããžã›ã‚“īŧˆį´›å¤ąãžãŸã¯į›—雪ãĢã‚ãŖãŸã¨å ąå‘Šã•ã‚ŒãĻいる可čƒŊ性がありぞすīŧ‰ã€‚",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},pin_try_exceeded:{description:"The allowable number of PIN tries has been exceeded.",nextSteps:"The customer must use another card or method of payment.",nextUserAction:"Please use another card or method of payment.",category:"SOFT_DECLINE",translations:{ja:{description:"PINčŠĻčĄŒå›žæ•°ãŽä¸Šé™ã‚’čļ…えぞした。",nextUserAction:"åˆĨぎã‚Ģãƒŧãƒ‰ãžãŸã¯ãŠæ”¯æ‰•ã„æ–šæŗ•ã‚’ã”åˆŠį”¨ãã ã•ã„ã€‚"}}},processing_error:{description:"An error occurred while processing the card.",nextSteps:"The payment should be attempted again. If it still cannot be processed, try again later.",nextUserAction:"Please try again. If it still cannot be processed, the please contact your card issuer.",category:"SOFT_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧドぎå‡Ļᐆ䏭ãĢエナãƒŧがį™ēį”Ÿã—ãžã—ãŸã€‚",nextUserAction:"もう一åēĻã‚„ã‚Šį›´ã—ãĻください。それでもå‡Ļį†ã§ããĒい場合は、ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},reenter_transaction:{description:"The payment could not be processed by the issuer for an unknown reason.",nextSteps:"The payment should be attempted again. If it still cannot be processed, the customer needs to contact their card issuer.",nextUserAction:"Please try again. If it still cannot be processed, the please contact your card issuer.",category:"SOFT_DECLINE",translations:{ja:{description:"原因不明ぎため、į™ēčĄŒč€…ãŒæ”¯æ‰•ã„ã‚’å‡Ļį†ã§ããžã›ã‚“ã§ã—ãŸã€‚",nextUserAction:"もう一åēĻã‚„ã‚Šį›´ã—ãĻください。それでもå‡Ļį†ã§ããĒい場合は、ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},restricted_card:{description:"The card cannot be used to make this payment (it is possible it has been reported lost or stolen).",nextSteps:"The customer needs to contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚Ģãƒŧãƒ‰ã§ã“ãŽæ”¯æ‰•ã„ã‚’čĄŒã†ã“ã¨ã¯ã§ããžã›ã‚“īŧˆį´›å¤ąãžãŸã¯į›—雪ãĢã‚ãŖãŸã¨å ąå‘Šã•ã‚ŒãĻいる可čƒŊ性がありぞすīŧ‰ã€‚",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},revocation_of_all_authorizations:{description:"The card has been declined for an unknown reason.",nextSteps:"The customer should contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},revocation_of_authorization:{description:"The card has been declined for an unknown reason.",nextSteps:"The customer should contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},security_violation:{description:"The card has been declined for an unknown reason.",nextSteps:"The customer needs to contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},service_not_allowed:{description:"The card has been declined for an unknown reason.",nextSteps:"The customer should contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},stolen_card:{description:"The payment has been declined because the card is reported stolen.",nextSteps:"The specific reason for the decline should not be reported to the customer. Instead, it needs to be presented as a generic decline.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},stop_payment_order:{description:"The card has been declined for an unknown reason.",nextSteps:"The customer should contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},testmode_decline:{description:"A Stripe test card number was used.",nextSteps:"A genuine card must be used to make a payment.",nextUserAction:"A genuine card must be used to make a payment.",category:"HARD_DECLINE",translations:{ja:{description:"Stripeテ゚トã‚Ģãƒŧドį•Ēåˇã‚’äŊŋį”¨ã—ãžã—ãŸã€‚",nextUserAction:"支払いãĢはæœŦį‰ŠãŽã‚ĢãƒŧドをäŊŋį”¨ã™ã‚‹åŋ…čĻãŒã‚ã‚Šãžã™ã€‚"}}},transaction_not_allowed:{description:"The card has been declined for an unknown reason.",nextSteps:"The customer needs to contact their card issuer for more information.",nextUserAction:"Please contact your card issuer for more information.",category:"HARD_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"čŠŗã—ãã¯ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},try_again_later:{description:"The card has been declined for an unknown reason.",nextSteps:"Ask the customer to attempt the payment again. If subsequent payments are declined, the customer should contact their card issuer for more information.",nextUserAction:"Please try again. If it still cannot be processed, the please contact your card issuer.",category:"SOFT_DECLINE",translations:{ja:{description:"ã‚ĢãƒŧドはæœĒįŸĨãŽį†į”ąã§æ‹’åĻされぞした。",nextUserAction:"もう一åēĻã‚„ã‚Šį›´ã—ãĻください。それでもå‡Ļį†ã§ããĒい場合は、ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}},withdrawal_count_limit_exceeded:{description:"The customer has exceeded the balance or credit limit available on their card.",nextSteps:"The customer should use an alternative payment method.",nextUserAction:"Please use another card or contact your card issuer for more information.",category:"SOFT_DECLINE",translations:{ja:{description:"こぎã‚Ģãƒŧドぎ掋éĢ˜ãžãŸã¯ã‚¯ãƒŦジットåˆļ限をčļ…えぞした。",nextUserAction:"åˆĨぎã‚ĢãƒŧドをäŊŋį”¨ã™ã‚‹ã‹ã€ã‚Ģãƒŧドį™ē行äŧšį¤žãĢお問い合わせください。"}}}};function m(e){if(!e||!s(e))return{docVersion:o,code:{}};const t=r[e];return{docVersion:o,code:t}}function c(e,t="en"){if(!s(e))return;const n=r[e];return t==="en"?n.nextUserAction:n.translations?.[t]?.nextUserAction}function y(){return Object.keys(r)}function s(e){return Object.hasOwn(r,e)}function f(){return o}function x(e,t="en",n){const i=c(e,t);if(!i)return;if(!n||Object.keys(n).length===0)return i;let a=i;for(const[u,l]of Object.entries(n)){const p=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=new RegExp(`\\{\\{${p}\\}\\}`,"g");a=a.replace(h,l)}return a}function d(e){if(s(e))return r[e].category}function g(e){return d(e)==="HARD_DECLINE"}function A(e){return d(e)==="SOFT_DECLINE"}function _(e,t="en"){if(e.decline_code)return c(e.decline_code,t)}exports.DECLINE_CODES=r;exports.DOC_VERSION=o;exports.formatDeclineMessage=x;exports.getAllDeclineCodes=y;exports.getDeclineCategory=d;exports.getDeclineDescription=m;exports.getDeclineMessage=c;exports.getDocVersion=f;exports.getMessageFromStripeError=_;exports.isHardDecline=g;exports.isSoftDecline=A;exports.isValidDeclineCode=s;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","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 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\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: StripeError,\n locale: Locale = 'en',\n): string | undefined {\n if (!error.decline_code) {\n return undefined;\n }\n\n return getDeclineMessage(error.decline_code, locale);\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 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"],"mappings":"gFAOO,MAAMA,EAAc,aAMdC,EAAsD,CACjE,gBAAiB,CACf,YAAa,oCACb,UACE,2HACF,eACE,0FACF,SAAU,eACV,aAAc,CACZ,GAAI,CACF,YAAa,eACb,eACE,iDAAA,CACJ,CACF,EAEF,YAAa,CACX,YAAa,oDACb,UAAW,wEACX,eAAgB,wDAChB,SAAU,eACV,aAAc,CACZ,GAAI,CACF,YAAa,qBACb,eAAgB,yBAAA,CAClB,CACF,EAEF,mBAAoB,CAClB,YAAa,mDACb,UACE,qHACF,eACE,gHACF,SAAU,e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,EAA2C,CAC5E,GAAKD,EAAmBC,CAAI,EAI5B,OAAOJ,EAAcI,CAAI,EAAE,QAC7B,CAcO,SAASe,EAAcf,EAAuB,CACnD,OAAOc,EAAmBd,CAAI,IAAM,cACtC,CAcO,SAASgB,EAAchB,EAAuB,CACnD,OAAOc,EAAmBd,CAAI,IAAM,cACtC,CAqBO,SAASiB,EACdC,EACAhB,EAAiB,KACG,CACpB,GAAKgB,EAAM,aAIX,OAAOjB,EAAkBiB,EAAM,aAAchB,CAAM,CACrD"}
@@ -0,0 +1,151 @@
1
+ import type { DeclineCategory, DeclineCode, DeclineCodeResult, Locale, StripeError } from './types.js';
2
+ /**
3
+ * Get decline code information with description and recommended actions
4
+ *
5
+ * @param declineCode - The Stripe decline code to look up
6
+ * @returns Object containing the decline code information and documentation version
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const result = getDeclineDescription('insufficient_funds');
11
+ * console.log(result.code.description);
12
+ * // => "The card has insufficient funds to complete the purchase."
13
+ * console.log(result.code.nextUserAction);
14
+ * // => "Please try again using an alternative payment method."
15
+ * ```
16
+ */
17
+ export declare function getDeclineDescription(declineCode?: string): DeclineCodeResult;
18
+ /**
19
+ * Get localized decline code message for end users
20
+ *
21
+ * @param declineCode - The Stripe decline code
22
+ * @param locale - The locale to use (default: 'en')
23
+ * @returns User-facing message in the specified locale, or undefined if not found
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const message = getDeclineMessage('insufficient_funds', 'ja');
28
+ * console.log(message);
29
+ * // => "åˆĨãŽãŠæ”¯æ‰•ã„æ–šæŗ•ã‚’äŊŋį”¨ã—ãĻもう一åēĻおčŠĻしください。"
30
+ * ```
31
+ */
32
+ export declare function getDeclineMessage(declineCode: string, locale?: Locale): string | undefined;
33
+ /**
34
+ * Get all available decline codes
35
+ *
36
+ * @returns Array of all supported decline code strings
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const codes = getAllDeclineCodes();
41
+ * console.log(codes.length); // => 44
42
+ * console.log(codes.includes('insufficient_funds')); // => true
43
+ * ```
44
+ */
45
+ export declare function getAllDeclineCodes(): DeclineCode[];
46
+ /**
47
+ * Check if a decline code is valid
48
+ *
49
+ * @param code - The code to validate
50
+ * @returns True if the code exists in the database
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * isValidDeclineCode('insufficient_funds'); // => true
55
+ * isValidDeclineCode('invalid_code'); // => false
56
+ * ```
57
+ */
58
+ export declare function isValidDeclineCode(code: string): code is DeclineCode;
59
+ /**
60
+ * Get the documentation version for the decline codes data
61
+ *
62
+ * @returns The Stripe API documentation version string
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const version = getDocVersion();
67
+ * console.log(version); // => "2024-12-18"
68
+ * ```
69
+ */
70
+ export declare function getDocVersion(): string;
71
+ /**
72
+ * Format a decline message with custom template variables
73
+ *
74
+ * @param declineCode - The Stripe decline code
75
+ * @param locale - The locale to use (default: 'en')
76
+ * @param variables - Optional variables to replace in the message template
77
+ * @returns Formatted user-facing message with variables replaced
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const message = formatDeclineMessage('insufficient_funds', 'en', {
82
+ * merchantName: 'Acme Store',
83
+ * supportEmail: 'support@acme.com'
84
+ * });
85
+ * console.log(message);
86
+ * // => "Please try again using an alternative payment method."
87
+ * ```
88
+ */
89
+ export declare function formatDeclineMessage(declineCode: string, locale?: Locale, variables?: Record<string, string>): string | undefined;
90
+ /**
91
+ * Get the category of a decline code (SOFT_DECLINE or HARD_DECLINE)
92
+ *
93
+ * @param code - The decline code to categorize
94
+ * @returns The category of the decline code, or undefined if invalid
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * getDeclineCategory('insufficient_funds'); // => 'SOFT_DECLINE'
99
+ * getDeclineCategory('fraudulent'); // => 'HARD_DECLINE'
100
+ * ```
101
+ */
102
+ export declare function getDeclineCategory(code: string): DeclineCategory | undefined;
103
+ /**
104
+ * Check if a decline code is a hard decline (permanent, should not retry)
105
+ *
106
+ * @param code - The decline code to check
107
+ * @returns True if the code is a hard decline
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * isHardDecline('fraudulent'); // => true
112
+ * isHardDecline('insufficient_funds'); // => false
113
+ * ```
114
+ */
115
+ export declare function isHardDecline(code: string): boolean;
116
+ /**
117
+ * Check if a decline code is a soft decline (temporary, can retry)
118
+ *
119
+ * @param code - The decline code to check
120
+ * @returns True if the code is a soft decline
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * isSoftDecline('insufficient_funds'); // => true
125
+ * isSoftDecline('fraudulent'); // => false
126
+ * ```
127
+ */
128
+ export declare function isSoftDecline(code: string): boolean;
129
+ /**
130
+ * Extract localized message from a Stripe error object
131
+ *
132
+ * @param error - The Stripe error object
133
+ * @param locale - The locale to use (default: 'en')
134
+ * @returns User-facing message in the specified locale, or undefined if not found
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * const stripeError = {
139
+ * type: 'StripeCardError',
140
+ * decline_code: 'insufficient_funds',
141
+ * message: 'Your card has insufficient funds.'
142
+ * };
143
+ * const message = getMessageFromStripeError(stripeError, 'ja');
144
+ * console.log(message);
145
+ * // => "åˆĨãŽãŠæ”¯æ‰•ã„æ–šæŗ•ã‚’äŊŋį”¨ã—ãĻもう一åēĻおčŠĻしください。"
146
+ * ```
147
+ */
148
+ export declare function getMessageFromStripeError(error: StripeError, locale?: Locale): string | undefined;
149
+ export { DECLINE_CODES, DOC_VERSION } from './data/decline-codes.js';
150
+ export type { DeclineCategory, DeclineCode, DeclineCodeInfo, DeclineCodeResult, Locale, StripeError, Translation, } from './types.js';
151
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,MAAM,EACN,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,CAAC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