PageRenderTime 71ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/error.js

https://github.com/larafale/mangopay
JavaScript | 110 lines | 75 code | 22 blank | 13 comment | 13 complexity | 540724934ae1153a2877bcd909ff3ed0 MD5 | raw file
  1. function mangoError(error){
  2. this.name = 'MangoPayError'
  3. this.message = error
  4. }
  5. mangoError.prototype = new Error()
  6. mangoError.prototype.constructor = mangoError
  7. module.exports = function(err, body, res){
  8. var code = /[0-9]/.test(''+err) ? err : (body && body.ResultCode) || false
  9. if(err && !code)
  10. return new mangoError(err)
  11. if(code && code != '000000'){
  12. var error = new mangoError(module.exports.codes[code] || 'Unknow error code')
  13. error.code = code
  14. return error
  15. }
  16. if(res.statusCode != 200)
  17. return new mangoError(err || body || { statusCode: res.statusCode })
  18. }
  19. module.exports.codes = {
  20. // Operation failed
  21. '001999':'Generic Operation error'
  22. , '001001':'Unsufficient wallet balance'
  23. , '001002':'Author is not the wallet owner'
  24. , '001011':'Transaction amount is higher than maximum permitted amount'
  25. , '001012':'Transaction amount is lower than minimum permitted amount'
  26. // Refund transaction error
  27. , '001401':'Transaction has already been successfully refunded'
  28. , '005403':'The refund cannot exceed initial transaction amount'
  29. , '005404':'The refunded fees cannot exceed initial fee amount'
  30. , '005405':'Balance of client fee wallet insufficient'
  31. , '005407':'Duplicated operation: you cannot refund the same amount more than once for a transaction during the same day. '
  32. // Card input error
  33. , '105101':'Invalid card number'
  34. , '105102':'Invalid cardholder name'
  35. , '105103':'Invalid PIN code'
  36. , '105104':'Invalid PIN format'
  37. // Token input Error
  38. , '105299':'Token input Error'
  39. , '105202':'Card number: invalid format'
  40. , '105203':'Expiry date: missing or invalid format'
  41. , '105204':'CVV: missing or invalid format'
  42. , '105205':'Callback URL: Invalid format'
  43. , '105206':'Registration data : Invalid format'
  44. // Generic transaction Error
  45. , '101001':'The user does not complete transaction'
  46. , '101002':'The transaction has been cancelled by the user'
  47. // Transaction refused
  48. , '101101':'Transaction refused by the bank (Do not honor)'
  49. , '101102':'Transaction refused by the bank (Amount limit)'
  50. , '101103':'Transaction refused by the terminal'
  51. , '101104':'Transaction refused by the bank (card limit reached)'
  52. , '101106':'The card is inactive'
  53. , '101410':'The card is not active' // payline
  54. , '101111':'Maximum number of attempts reached'
  55. , '101112':'Maximum amount exceeded'
  56. , '101115':'Debit limit exceeded'
  57. , '101119':'Debit limit exceeded'
  58. // Secure mode / 3DSecure error
  59. , '101399':'Secure mode: 3DSecure authentication is not available'
  60. // Tokenization / Card registration error
  61. , '001599':'Token processing error'
  62. // KYC error
  63. , '002999':'Blocked due to the KYC limitation'
  64. // Fraud issue
  65. , '008999':'Fraud policy error'
  66. , '008001':'Counterfeit Card'
  67. , '008002':'Lost Card'
  68. , '008004':'Card bin not authorized'
  69. , '008005':'Security violation'
  70. , '008006':'Fraud suspected by the bank'
  71. , '008007':'Opposition on bank account (Temporary)'
  72. , '008500':'Transaction blocked by Fraud Policy'
  73. , '008600':'Wallet blocked by Fraud policy'
  74. , '008700':'User blocked by Fraud policy'
  75. // Technical error
  76. , '009199':'PSP technical error'
  77. , '009499':'Bank technical error'
  78. , '009999':'Technical error'
  79. // Tokenisation server error codes
  80. , '09101': 'Username/Password is incorrect'
  81. , '09102': 'Account is locked or inactive'
  82. , '09104': 'Client certificate is disabled'
  83. , '09201': 'You do not have permissions to make this API call'
  84. // Tokenization server error code (while card registration)
  85. , '02625': 'Invalid card number'
  86. , '02626': 'Invalid date. Use mmdd format'
  87. , '02627': 'Invalid CCV number'
  88. }