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 +21 -0
- package/README.md +121 -16
- package/dist/data/decline-codes.d.ts +13 -0
- package/dist/data/decline-codes.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +151 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/{index.es.js â index.mjs} +78 -17
- package/dist/index.mjs.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/docs-data/api.json +2081 -0
- package/docs-data/decline-codes.json +622 -0
- package/docs-data/functions.json +197 -0
- package/docs-data/metadata.json +23 -0
- package/docs-data/types.json +170 -0
- package/package.json +17 -11
- package/dist/index.cjs.js +0 -2
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js.map +0 -1
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 (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const userMessage = getDeclineMessage(
|
|
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
|
-
|
|
346
|
+
pnpm install
|
|
250
347
|
|
|
251
348
|
# Run tests
|
|
252
|
-
|
|
349
|
+
pnpm test
|
|
253
350
|
|
|
254
351
|
# Run tests in watch mode
|
|
255
|
-
|
|
352
|
+
pnpm run test:watch
|
|
256
353
|
|
|
257
354
|
# Build
|
|
258
|
-
|
|
355
|
+
pnpm run build
|
|
259
356
|
|
|
260
357
|
# Lint
|
|
261
|
-
|
|
358
|
+
pnpm run lint
|
|
262
359
|
|
|
263
360
|
# Format code
|
|
264
|
-
|
|
361
|
+
pnpm run format
|
|
265
362
|
|
|
266
363
|
# Type check
|
|
267
|
-
|
|
364
|
+
pnpm run typecheck
|
|
268
365
|
```
|
|
269
366
|
|
|
270
|
-
|
|
367
|
+
The `docs/` directory is a separate npm project (Starlight site) and keeps using `npm`.
|
|
271
368
|
|
|
272
|
-
|
|
369
|
+
## Publishing
|
|
273
370
|
|
|
274
|
-
|
|
275
|
-
|
|
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,Y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,IAAK,OAAO,QAAQJ,CAAS,EAAG,CAEpD,MAAMK,EAAaF,EAAI,QAAQ,sBAAuB,MAAM,EACtDG,EAAc,IAAI,OAAO,SAASD,CAAU,SAAU,GAAG,EAC/DH,EAAmBA,EAAiB,QAAQI,EAAaF,CAAK,CAChE,CAEA,OAAOF,CACT,CAcO,SAASK,EAAmBd,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"}
|
package/dist/index.d.ts
ADDED
|
@@ -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,M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