def handle_errors(self, r_dict): """ Check the response for error conditions, and raise an exception if one is found. @param r_dict dictionary of response values indexed by name @type r_dict dict """ # Make sure this exists before accessing it. if 'ACK' not in r_dict: # FIXME: put some more information in the exception raised if reasonable raise invalid_response_exception # See if we failed if r_dict['ACK'] in set(['Failure', 'FailureWithWarning', 'Warning']): keys = r_dict.keys() error_messages = [] # There may be more than error message, but their keys all start with the same string for key in keys: if key.upper().startswith('L_LONGMESSAGE'): error_messages.append(r_dict[key]) error = '' for message in error_messages: if len(error): error += ' ' error += message raise transaction_failure_exception(error) # Since we didn't fail, make sure we got a transaction_id if 'TRANSACTIONID' not in r_dict and 'REFUNDTRANSACTIONID' not in r_dict: # FIXME: put some more information in the exception if possible raise invalid_response_exception
def _handle_result_code(self, result_code): """ Interpret a result code and act accordingly @param result_code result code received from payflowpro server @type result_code int """ result_code = int(result_code) if result_code == 0: pass #this means approved elif result_code == 1: raise transaction_failure_exception('authentication failed to the merchant services gateway') elif result_code == 4: raise transaction_failure_exception('invalid currency amount format. Please indicate currency in cents') elif result_code == 12: raise transaction_denied_exception else: raise transaction_failure_exception('transaction failed')
def handle_errors(self, response_dict): """ Check the response for error conditions, and raise an exception if one is found. @param response_dict Dictionary of response values indexed by name @type response_dict dict """ if 'errorMessage' in response_dict: raise transaction_failure_exception(response_dict['errorMessage']) elif 'ssl_result' not in response_dict or response_dict['ssl_result'] != '0': raise transaction_denied_exception
def _handle_result_code(self, result_code): """ Interpret a result code and act accordingly @param result_code result code received from payflowpro server @type result_code int """ result_code = int(result_code) if result_code == 0: pass #this means approved elif result_code == 1: raise transaction_failure_exception( 'authentication failed to the merchant services gateway') elif result_code == 4: raise transaction_failure_exception( 'invalid currency amount format. Please indicate currency in cents' ) elif result_code == 12: raise transaction_denied_exception else: raise transaction_failure_exception('transaction failed')