def test_init_credit_request(self, req_mock, validator_mock):
     validator_class = Mock()
     validator_class.execute.return_value = {}
     validator_mock.return_value = validator_class
     req_class = Mock()
     req_class.executeRequest.return_value = None
     req_mock.return_value = req_class
     gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')
     result_data = gate_client.init_credit(self.init_data)
     expected_data = {'guid': 'AAAA-AAAA-AAAA-AAAA', 'account_guid': 'AAAA-AAAA-AAAA-AAAA',
                      'pwd': hashlib.sha1('111').hexdigest()}
     req_class.executeRequest.assert_called_once_with('init_credit', expected_data)
 def test_charge_hold_request(self, req_mock):
     req_class = Mock()
     req_class.executeRequest.return_value = None
     req_mock.return_value = req_class
     gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')
     initial_data = {'init_transaction_id': 1}
     result_data = gate_client.charge_hold(initial_data)
     expected_data = initial_data
     expected_data['guid'] = 'AAAA-AAAA-AAAA-AAAA'
     expected_data['account_guid'] = 'AAAA-AAAA-AAAA-AAAA'
     expected_data['pwd'] = hashlib.sha1('111').hexdigest()
     req_class.executeRequest.assert_called_once_with('charge_hold', expected_data)
    def test_init_recurrent_request(self, req_mock):
        req_class = Mock()
        req_class.executeRequest.return_value = None
        req_mock.return_value = req_class

        gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')

        initial_data =  {'original_init_id': '2250fcc6fd097e7b9df02aa9b95bf46baa7f8fea', 'merchant_transaction_id': 12121, 'rs': 'AAAA', 'description': 'la la la', 'amount': 100}
        result_data = gate_client.init_recurrent(initial_data)
        expected_data = initial_data
        expected_data['pwd'] = hashlib.sha1('111').hexdigest()
        expected_data['guid'] = 'AAAA-AAAA-AAAA-AAAA'
        expected_data['account_guid'] = 'AAAA-AAAA-AAAA-AAAA'
        req_class.executeRequest.assert_called_once_with('init_recurrent', expected_data)
    def test_status_request(self, req_mock):
        req_class = Mock()
        req_class.executeRequest.return_value = None
        req_mock.return_value = req_class

        gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')

        initial_data = {'init_transaction_id': '2250fcc6fd097e7b9df02aa9b95bf46baa7f8fea', 'f_extended': '5', 'request_type': 'transaction_status'}
        result_data = gate_client.status(initial_data)
        expected_data = initial_data
        expected_data['guid'] = 'AAAA-AAAA-AAAA-AAAA'
        expected_data['pwd'] = hashlib.sha1('111').hexdigest()
        expected_data['account_guid'] = 'AAAA-AAAA-AAAA-AAAA'
        req_class.executeRequest.assert_called_once_with('status_request', expected_data)
 def test_do_recurrent_credit_request(self, req_mock):
     req_class = Mock()
     req_class.executeRequest.return_value = None
     req_mock.return_value = req_class
     gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')
     initial_data = {
         'f_extended': '5',
         'init_transaction_id': '121212'}
     result_data = gate_client.do_recurrent_credit(initial_data)
     expected_data = initial_data
     expected_data['guid'] = 'AAAA-AAAA-AAAA-AAAA'
     expected_data['account_guid'] = 'AAAA-AAAA-AAAA-AAAA'
     expected_data['pwd'] = hashlib.sha1('111').hexdigest()
     req_class.executeRequest.assert_called_once_with('do_recurrent_credit', expected_data)
 def test_status_request(self, req_mock):
     req_class = Mock()
     req_class.executeRequest.return_value = None
     req_mock.return_value = req_class
     gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')
     initial_data = {'init_transaction_id': '2250fcc6fd097e7b9df02aa9b95bf46baa7f8fea',
                     'f_extended': '5',
                     'request_type': 'transaction_status'}
     result_data = gate_client.status(initial_data)
     expected_data = initial_data
     expected_data['guid'] = 'AAAA-AAAA-AAAA-AAAA'
     expected_data['pwd'] = hashlib.sha1('111').hexdigest()
     expected_data['account_guid'] = 'AAAA-AAAA-AAAA-AAAA'
     req_class.executeRequest.assert_called_once_with('status_request', expected_data)
 def test_do_p2p_request(self, req_mock):
     req_class = Mock()
     req_class.executeRequest.return_value = None
     req_mock.return_value = req_class
     gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')
     initial_data = {'init_transaction_id': '2250fcc6fd231231CXCZC563453sdada23233fea',
                     'cc_2': '9999999555554794',
                     'expire2': '12/18',
                     'f_extended': 5}
     result_data = gate_client.do_p2p(initial_data)
     expected_data = initial_data
     expected_data['guid'] = 'AAAA-AAAA-AAAA-AAAA'
     expected_data['account_guid'] = 'AAAA-AAAA-AAAA-AAAA'
     expected_data['pwd'] = hashlib.sha1('111').hexdigest()
     req_class.executeRequest.assert_called_once_with('do_p2p', expected_data)
 def test_init_p2p_request(self, req_mock, validator_mock):
     validator_class = Mock()
     validator_class.execute.return_value = {}
     validator_mock.return_value = validator_class
     req_class = Mock()
     req_class.executeRequest.return_value = None
     req_mock.return_value = req_class
     gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')
     credit_initial_data = self.init_data.update({'cardname': "JON DOE",
                                                  'recipient_name': "FOO BAR",
                                                  'client_birth_date': '06161981'})
     result_data = gate_client.init_p2p(credit_initial_data)
     expected_data = {'guid': 'AAAA-AAAA-AAAA-AAAA', 'account_guid': 'AAAA-AAAA-AAAA-AAAA',
                      'pwd': hashlib.sha1('111').hexdigest()}
     req_class.executeRequest.assert_called_once_with('init_p2p', expected_data)
 def test_refund_request(self, req_mock):
     req_class = Mock()
     req_class.executeRequest.return_value = None
     req_mock.return_value = req_class
     gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')
     initial_data = {'init_transaction_id': 1,
                     'amount_to_refund': 100,
                     'merchant_transaction_id': 'IDDQD-Payment-42DFSDF2d1',
                     'details': 'true'
                     }
     result_data = gate_client.refund(initial_data)
     expected_data = initial_data
     expected_data['pwd'] = hashlib.sha1('111').hexdigest()
     expected_data['guid'] = 'AAAA-AAAA-AAAA-AAAA'
     expected_data['account_guid'] = 'AAAA-AAAA-AAAA-AAAA'
     req_class.executeRequest.assert_called_once_with('refund', expected_data)
 def test_init_recurrent_p2p_request(self, req_mock):
     req_class = Mock()
     req_class.executeRequest.return_value = None
     req_mock.return_value = req_class
     gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')
     initial_data = {'original_init_id': '2250fcc6fd097e7b9df02aa9b95bf46baa7f8fea',
                     'merchant_transaction_id': 12121,
                     'rs': 'AAAA',
                     'amount': 100,
                     'description': 'Example: SDHC Memory card x 2'}
     result_data = gate_client.init_recurrent_p2p(initial_data)
     expected_data = initial_data
     expected_data['pwd'] = hashlib.sha1('111').hexdigest()
     expected_data['guid'] = 'AAAA-AAAA-AAAA-AAAA'
     expected_data['account_guid'] = 'AAAA-AAAA-AAAA-AAAA'
     req_class.executeRequest.assert_called_once_with('init_recurrent_p2p', expected_data)
 def test_do_credit_request(self, req_mock, validator_mock):
     validator_class = Mock()
     validator_class.execute.return_value = {}
     validator_mock.return_value = validator_class
     req_class = Mock()
     req_class.executeRequest.return_value = None
     req_mock.return_value = req_class
     gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')
     initial_data = {'f_extended': '5',
                     'init_transaction_id': '2250fcc6fd231231CXCZC563453sdada23233fea',
                     'cc': '1234123412341234',
                     'cvv': '666'}
     result_data = gate_client.do_credit(initial_data)
     expected_data = {'guid': 'AAAA-AAAA-AAAA-AAAA', 'account_guid': 'AAAA-AAAA-AAAA-AAAA',
                      'pwd': hashlib.sha1('111').hexdigest()}
     req_class.executeRequest.assert_called_once_with('do_credit', expected_data)
 def test_charge_request(self, req_mock):
     req_class = Mock()
     req_class.executeRequest.return_value = None
     req_mock.return_value = req_class
     gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')
     initial_data = {'init_transaction_id': 1,
                     'cc': '1234123412341234',
                     'cvv': '666',
                     'expire': '12/13',
                     'f_extended': 5,
                     'merchant_referring_url': 'http://payment.my-python-web.org'}
     result_data = gate_client.charge(initial_data)
     expected_data = initial_data
     expected_data['guid'] = 'AAAA-AAAA-AAAA-AAAA'
     expected_data['account_guid'] = 'AAAA-AAAA-AAAA-AAAA'
     expected_data['pwd'] = hashlib.sha1('111').hexdigest()
     req_class.executeRequest.assert_called_once_with('charge', expected_data)
 def setUp(self):
     self.gate_client = GateClient('https://www.payment-api.com', 'AAAA-AAAA-AAAA-AAAA', '111')