def process(self): """Attempts to process Verification with transaction details. Returns the values of ``gateway.Verification.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. """ verification_instance = gateway.Verification( save_token=self.save_token, django_user=self.django_user, **self.transaction_details) try: return verification_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( 'Verification complete, but errors occured while saving ' 'transaction to database') except helcim_exceptions.HelcimError as error: raise oscar_exceptions.GatewayError(str(error))
def test_process_error_response_verification(): verification_request = gateway.Verification() try: verification_request.process_error_response('') except helcim_exceptions.VerificationError: assert True else: assert False
def test_verification_processing(): details = { 'amount': 100.00, 'customer_code': 'CST1000', } verification = gateway.Verification(api_details=API_DETAILS, **details) transaction, _ = verification.process() assert isinstance(transaction, MockDjangoModel)
def test_process_with_save_token_disabled(): details = { 'amount': 100.00, 'token': 'abcdefghijklmnopqrstuvw', 'token_f4l4': '11119999', 'customer_code': 'CST1000', } verification = gateway.Verification(api_details=API_DETAILS, save_token=True, **details) _, token = verification.process() assert token is None
def test_process_with_save_token_enabled(django_user_model): details = { 'amount': 100.00, 'token': 'abcdefghijklmnopqrstuvw', 'token_f4l4': '11119999', 'customer_code': 'CST1000', } user = django_user_model.objects.create_user(username='******', password='******') verification = gateway.Verification(api_details=API_DETAILS, save_token=True, django_user=user, **details) _, token = verification.process() assert isinstance(token, MockDjangoModel)