Skip to content

Commit

Permalink
Update types, add checks for error types
Browse files Browse the repository at this point in the history
  • Loading branch information
exah committed Aug 24, 2020
1 parent 765ef2b commit b06d2db
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/checks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ValidationError, RevolutCheckoutError } from './types'

export function isValidationError(error?: Error): error is ValidationError {
return error != null && error.name === 'Validation'
}

export function isRevolutCheckoutError(
error?: Error
): error is RevolutCheckoutError {
return error != null && error.name === 'RevolutCheckout'
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { RevolutCheckoutLoader as default } from './loader'
export { isRevolutCheckoutError, isValidationError } from './checks'
export {
ValidationErrorType,
ValidationError,
Expand Down
23 changes: 22 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,28 @@ export type RevolutCheckoutErrorType =
| 'error.expired-card'
| 'error.incorrect-cvv-code'
| 'error.order-is-cancelled'
| 'error.transaction-failed'
| 'error.trusted-principal-not-specified'
| 'error.merchant-not-specified'
| 'error.invalid-order-type'
| 'error.transaction-step'
| 'error.payment-method-already-exists'
| 'error.payment-method-not-found'
| 'error.order-customer-id-is-not-set'
| 'error.payment-method-not-permitted-for-merchant'
| 'error.webhook-not-found'
| 'error.verification-not-permitted'
| 'error.customer-already-exists'
| 'error.unknown-authorisation'
| 'error.submerchant-not-found'
| 'error.submerchant-incorrect-notification'
| 'error.3ds-incorrect-notification'
| 'error.authentication-challenge-not-found'
| 'error.mpi-provider'
| 'error.payment-gateway'
| 'error.invalid-provider-response'
| 'error.unexpected-mpi-provider'
| 'error.terminal-not-found'
| 'error.submerchant-not-onboarded'

export interface ValidationError extends Error {
name: 'Validation'
Expand Down

0 comments on commit b06d2db

Please sign in to comment.