Esempio n. 1
0
    def process(self):
        """Makes a purchase request.

            Returns:
                tuple: The saved HelcimTransaction model
                    instance and HelcimToken model.
        """
        self.validate_fields()
        self.configure_test_transaction()
        self.determine_card_details()

        purchase_data = conversions.process_request_fields(
            self.api, self.cleaned, {
                'transactionType': 'purchase',
            })
        self.post(purchase_data)

        purchase = self.save_transaction('s')

        if self.save_token:
            token = self.save_token_to_vault()
        else:
            token = None

        return purchase, token
Esempio n. 2
0
def test_process_request_fields_invalid_api():
    api = {
        'account_id': '1',
        'terminal_id': '3',
    }
    cleaned = {
        'cc_cvv': '100.00',
    }
    additional = {
        'transactionType': 'purchase',
    }

    try:
        conversions.process_request_fields(api, cleaned, additional)
    except KeyError as error:
        assert str(error) == "'token'"
    else:
        assert False
Esempio n. 3
0
    def process(self):
        """Completes a capture request."""
        self.validate_fields()
        self.validate_preauth_transaction()
        self.configure_test_transaction()

        capture_data = conversions.process_request_fields(
            self.api, self.cleaned, {
                'transactionType': 'capture',
            })

        self.post(capture_data)
        capture = self.save_transaction('c')

        return capture
Esempio n. 4
0
    def process(self):
        """Makes a verification request to Helcim Commerce API."""
        self.validate_fields()
        self.configure_test_transaction()
        self.determine_card_details()

        verification_data = conversions.process_request_fields(
            self.api, self.cleaned, {
                'transactionType': 'verify',
            })
        self.post(verification_data)

        verification = self.save_transaction('v')
        token = self.save_token_to_vault()

        return verification, token
Esempio n. 5
0
    def process(self):
        """Makes a pre-authorization request."""
        self.validate_fields()
        self.configure_test_transaction()
        self.determine_card_details()

        preauth_data = conversions.process_request_fields(
            self.api, self.cleaned, {
                'transactionType': 'preauth',
            })
        self.post(preauth_data)

        preauth = self.save_transaction('p')
        token = self.save_token_to_vault()

        return preauth, token
Esempio n. 6
0
def test_process_request_fields_valid_no_additional():
    api = {
        'account_id': '1',
        'token': '2',
        'terminal_id': '3',
    }
    cleaned = {
        'cc_cvv': '100.00',
    }

    data = conversions.process_request_fields(api, cleaned)

    assert 'accountId' in data
    assert 'apiToken' in data
    assert 'terminalId' in data
    assert 'cardCVV' in data
    assert len(data) == 4
Esempio n. 7
0
def test__process_request_fields__valid_no_additional():
    """Confirms handling of Python data conversion with no extra details."""
    api = {
        'account_id': '1',
        'token': '2',
        'terminal_id': '3',
    }
    cleaned = {
        'cc_cvv': '100.00',
    }

    data = conversions.process_request_fields(api, cleaned)

    assert 'accountId' in data
    assert 'apiToken' in data
    assert 'terminalId' in data
    assert 'cardCVV' in data
    assert len(data) == 4
Esempio n. 8
0
    def process(self):
        """Makes a refund request to Helcim Commerce API."""
        self.validate_fields()
        self.configure_test_transaction()
        self.determine_card_details()

        refund_data = conversions.process_request_fields(
            self.api, self.cleaned, {
                'transactionType': 'refund',
            })
        self.post(refund_data)
        refund = self.save_transaction('r')

        if self.save_token:
            token = self.save_token_to_vault()
        else:
            token = None

        return refund, token
Esempio n. 9
0
def test_process_request_fields_valid():
    api = {
        'account_id': '1',
        'token': '2',
        'terminal_id': '3',
    }
    cleaned = {
        'cc_cvv': '100.00',
    }
    additional = {
        'transactionType': 'purchase',
    }

    data = conversions.process_request_fields(api, cleaned, additional)

    assert 'accountId' in data
    assert 'apiToken' in data
    assert 'terminalId' in data
    assert 'cardCVV' in data
    assert 'transactionType' in data
    assert len(data) == 5
Esempio n. 10
0
def test__process_request_fields__valid():
    """Confirms handling of Python data to Helcim API data."""
    api = {
        'account_id': '1',
        'token': '2',
        'terminal_id': '3',
    }
    cleaned = {
        'cc_cvv': '100.00',
    }
    additional = {
        'transactionType': 'purchase',
    }

    data = conversions.process_request_fields(api, cleaned, additional)

    assert 'accountId' in data
    assert 'apiToken' in data
    assert 'terminalId' in data
    assert 'cardCVV' in data
    assert 'transactionType' in data
    assert len(data) == 5