コード例 #1
0
ファイル: utils.py プロジェクト: ricomoss/AyeGotchoPayCheque
 def test_get_index_safely(self):
     tmp_list = [1, 'test_value_2']
     actual = utils.get_index_safely(tmp_list, 0)
     self.assertEqual(tmp_list[0], actual)
     actual = utils.get_index_safely(tmp_list, 1)
     self.assertEqual(tmp_list[1], actual)
コード例 #2
0
    def handle_response(self, full_response):
        regex_str = r'.*The following errors have occurred.</H3>(.*)<BR.*'
        matchObj = re.search(regex_str, full_response)
        if matchObj is not None:
            raise AuthorizeReturnedError

        response = full_response.split('|')
        return {
            'Response Code': utils.get_index_safely(response, 0),
            'Response Subcode': utils.get_index_safely(response, 1),
            'Response Reason Code': utils.get_index_safely(response, 2),
            'Response Reason Text': utils.get_index_safely(response, 3),
            'Authorization Code': utils.get_index_safely(response, 4),
            'AVS Response': utils.get_index_safely(response, 5),
            'Transaction ID': utils.get_index_safely(response, 6),
            'Invoice Number': utils.get_index_safely(response, 7),
            'Description': utils.get_index_safely(response, 8),
            'Amount': utils.get_index_safely(response, 9),
            'Method': utils.get_index_safely(response, 10),
            'Transaction Type': utils.get_index_safely(response, 11),
            'Customer ID': utils.get_index_safely(response, 12),
            'First Name': utils.get_index_safely(response, 13),
            'Last Name': utils.get_index_safely(response, 14),
            'Company': utils.get_index_safely(response, 15),
            'Address': utils.get_index_safely(response, 16),
            'City': utils.get_index_safely(response, 17),
            'State': utils.get_index_safely(response, 18),
            'ZIP Code': utils.get_index_safely(response, 19),
            'Country': utils.get_index_safely(response, 20),
            'Phone': utils.get_index_safely(response, 21),
            'Fax': utils.get_index_safely(response, 22),
            'Email Address': utils.get_index_safely(response, 23),
            'Ship To First Name': utils.get_index_safely(response, 24),
            'Ship To last Name': utils.get_index_safely(response, 25),
            'Ship To Company': utils.get_index_safely(response, 26),
            'Ship To Address': utils.get_index_safely(response, 27),
            'Ship To City': utils.get_index_safely(response, 28),
            'Ship To State': utils.get_index_safely(response, 29),
            'Ship To ZIP Code': utils.get_index_safely(response, 30),
            'Ship To Country': utils.get_index_safely(response, 31),
            'Tax': utils.get_index_safely(response, 32),
            'Duty': utils.get_index_safely(response, 33),
            'Freight': utils.get_index_safely(response, 34),
            'Tax Exempt': utils.get_index_safely(response, 35),
            'Purchase Order Number': utils.get_index_safely(response, 36),
            'MD5 Hash': utils.get_index_safely(response, 37),
            'Card Code Response': utils.get_index_safely(response, 38),
            'Cardholder Authentication Verification Response':
                utils.get_index_safely(response, 39),
            'Account Number': utils.get_index_safely(response, 40),
            'Card Type': utils.get_index_safely(response, 41),
            'Split Tender ID': utils.get_index_safely(response, 42),
            'Requested Amount': utils.get_index_safely(response, 43),
            'Balance On Card': utils.get_index_safely(response, 44),
        }