dpyScmError.h
1 
4 
8 #pragma once
9 
10 #include <boost/system/error_code.hpp>
11 
15 enum dpy_scm_errors
16 {
17  DPY_SCM_ONLINE_OK = 0,
18  DPY_SCM_TRANS_REFUSED_FORMAT = 1,
19  DPY_SCM_TRANS_REFUSED_BAND = 2,
20  DPY_SCM_TRANS_REFUSED_CMD = 3,
21  DPY_SCM_TRANS_REFUSED_NO_KEYS = 4,
22  DPY_SCM_COMM_ERROR_NO_LINE= 5,
23  DPY_SCM_COMM_ERROR_BACKOFFICE = 6,
24  DPY_SCM_COMM_ERROR_CARRIER = 7,
25  DPY_SCM_COMM_ERROR_TIMER = 8,
26  DPY_SCM_TRANS_NOT_FINISHED = 9,
27  DPY_SCM_TRANS_NOT_SUPPORTED = 10,
28  DPY_SCM_NOT_PERMITTED = 11,
29  DPY_SCM_OPERATION_CANCELLED = 12,
30  DPY_SCM_FALLBACK_BAND = 13,
31  DPY_SCM_MAC_ERROR = 14,
32  DPY_SCM_EMV_CARD_REJECTED = 15,
33  DPY_SCM_OPERATION_CANCELLED_CMD = 16,
34  DPY_SCM_ERROR_LOADING_PARAM = 17,
35 
36  DPY_SCM_OFFLINE_OK = 96,
37  DPY_SCM_EMV_OK = 97,
38  DPY_SCM_CONTACLESS_OK = 98,
39  DPY_SCM_UNKOWN_ERROR = 99,
40 
41 };
42 
51 class dpyScmError: public boost::system::error_category
52 {
53 public:
58  virtual const char *name() const noexcept
59  {
60  return "DPY_SCM_ERRORS";
61  }
67  virtual std::string message(int e) const
68  {
69  switch (e) {
70  case DPY_SCM_ONLINE_OK:
71  return "Online transaction processed successfully.";
72  case DPY_SCM_TRANS_REFUSED_FORMAT:
73  return "Transaction refused. The message received by Payment Application has not the proper format.";
74  case DPY_SCM_TRANS_REFUSED_BAND:
75  return "Transaction refused. Invalid card: Magnetic band error.";
76  case DPY_SCM_TRANS_REFUSED_CMD:
77  return "Transaction refused. Invalid card: There was an error in the chip card, before sending the first instruction to generate the cryptogram.";
78  case DPY_SCM_TRANS_REFUSED_NO_KEYS:
79  return "Transaction refused. No keys.";
80  case DPY_SCM_COMM_ERROR_NO_LINE:
81  return "Communications error, the terminal has not been connected to the phone line or it is busy.";
82  case DPY_SCM_COMM_ERROR_BACKOFFICE:
83  return "Communications error, it was not possible to establish the communication with Redsys 'back office'";
84  case DPY_SCM_COMM_ERROR_CARRIER:
85  return "Communications error, the carrier was lost.";
86  case DPY_SCM_COMM_ERROR_TIMER:
87  return "Communications error, EOT or Redsys 'back office' answer reception time has expired.";
88  case DPY_SCM_TRANS_NOT_FINISHED:
89  return "Transaction does not finish. The timer for the data input has expired.";
90  case DPY_SCM_NOT_PERMITTED:
91  return "Transaction refused. This operation is not supported by the application.";
92  case DPY_SCM_OPERATION_CANCELLED:
93  return "The transaction was cancelled by the user.";
94  case DPY_SCM_FALLBACK_BAND:
95  return "Magnetic band fallback and the operation will finish online.";
96  case DPY_SCM_MAC_ERROR:
97  return "Incorrect MAC";
98  case DPY_SCM_EMV_CARD_REJECTED:
99  return "The transaction has been refused by the EMV card before sending the second command to generate the cryptogram.";
100  case DPY_SCM_OPERATION_CANCELLED_CMD:
101  return "The message received from Redsys is not supported and has bad format.";
102  case DPY_SCM_ERROR_LOADING_PARAM:
103  return "It was an error while loading the parameters";
104  case DPY_SCM_OFFLINE_OK:
105  return "The offline band operation was accepted.";
106  case DPY_SCM_EMV_OK:
107  return "The EMV offline transaction was accepted.";
108  case DPY_SCM_CONTACLESS_OK:
109  return "Offline transaction with contacts accepted";
110  case DPY_SCM_UNKOWN_ERROR:
111  return "Unknown reason";
112 
113  default:
114  return "unknown custom::category error";
115  }
116  return "unknown custom::category error";
117  }
118 };
119 
120 inline const boost::system::error_category& get_dpy_scm_error_category();
121 static const boost::system::error_category& dpy_scm_error_category = get_dpy_scm_error_category();
122 
123 const boost::system::error_category& get_dpy_scm_error_category()
124 {
125  static dpyScmError dpy_cat;
126  return dpy_cat;
127 }
128 
129 
130 inline boost::system::error_code make_scm_error_code(dpy_scm_errors e)
131 {
132  return boost::system::error_code(static_cast<int>(e), dpy_scm_error_category);
133 }
134 
135 namespace boost
136 {
137 namespace system
138 {
142 template<>
143 struct is_error_code_enum<dpy_scm_errors>
144 {
148  BOOST_STATIC_CONSTANT(bool, value = true);
149 };
150 }
151 } // namespaces
virtual const char * name() const noexcept
Returns the name of the category.
Definition: dpyScmError.h:58
Definition: dpyError.h:192
Allows to categorize the errors.
Definition: dpyScmError.h:51
virtual std::string message(int e) const
Return the error message according to the error value.
Definition: dpyScmError.h:67