Ejemplo n.º 1
0
    def process(self):
        """Attempts to process Capture with transaction details.

            Returns the values of ``gateway.Capture.process``.

            Raises:
                GatewayError: An Oscar error raised when there was an
                    error with the payment API.
                PaymentError: An Oscar error raised when there was an
                    error processing the payment.
        """

        capture_instance = gateway.Capture(**self.transaction_details)

        try:
            return capture_instance.process()
        except helcim_exceptions.ProcessingError as error:
            raise oscar_exceptions.GatewayError(str(error))
        except helcim_exceptions.PaymentError as error:
            raise oscar_exceptions.PaymentError(str(error))
        except helcim_exceptions.DjangoError:
            LOG.exception('Capture complete, but errors occured while saving '
                          'transaction to database')
            return None
        except helcim_exceptions.HelcimError as error:
            raise oscar_exceptions.GatewayError(str(error))
Ejemplo n.º 2
0
def test_validate_preauth_transaction_invalid():
    capture = gateway.Capture(api_details=API_DETAILS, **{})

    try:
        capture.validate_preauth_transaction()
    except helcim_exceptions.PaymentError:
        assert True
    else:
        assert False
Ejemplo n.º 3
0
def test_process_error_response_capture():
    capture_request = gateway.Capture()

    try:
        capture_request.process_error_response('')
    except helcim_exceptions.PaymentError:
        assert True
    else:
        assert False
Ejemplo n.º 4
0
def test_capture_processing():
    details = {
        'transaction_id': 1,
    }

    capture = gateway.Capture(api_details=API_DETAILS, **details)
    response = capture.process()

    assert isinstance(response, MockDjangoModel)
Ejemplo n.º 5
0
    def capture(self):
        """Processes a capture transaction."""
        transaction = self.get_object()

        capture = gateway.Capture({
            'transaction_type': 'c',
            'transaction_id': transaction.transaction_id,
        })

        try:
            capture.process()
        except exceptions.PaymentError:
            messages.error(self.request, 'Unable to capture transaction')
        else:
            messages.success(self.request, 'Transaction captured')

        return HttpResponseRedirect(
            reverse('helcim_transaction_detail',
                    kwargs={'transaction_id': transaction.id}))