def it_should_void(process, netaxept_payment): mock_process_response = ProcessResponse( response_code='OK', raw_response={ 'status_code': 200, 'url': 'https://test.epayment.nets.eu/Netaxept/Register.aspx', 'encoding': 'ISO-8859-1', 'reason': 'OK', 'text': 'some xml' }) process.return_value = mock_process_response payment_info = create_payment_information( payment=netaxept_payment, payment_token='1111111111114cf693a1cf86123e0d8f', amount=Money(10, 'CHF')) void_result = void(config=_gateway_config, payment_information=payment_info) assert void_result == GatewayResponse( is_success=True, kind=TransactionKind.VOID, amount=Decimal('10'), currency='CHF', transaction_id='1111111111114cf693a1cf86123e0d8f', error=None, raw_response=mock_process_response.raw_response) process.assert_called_once_with( config=_netaxept_config, amount=Decimal('10'), transaction_id='1111111111114cf693a1cf86123e0d8f', operation=NetaxeptOperation.ANNUL)
def it_should_not_capture_when_protocol_error(process, netaxept_payment): process.side_effect = NetaxeptProtocolError(error='some error', raw_response={}) payment_info = create_payment_information( payment=netaxept_payment, payment_token='1111111111114cf693a1cf86123e0d8f', amount=Money(10, 'CHF')) capture_result = capture(config=_gateway_config, payment_information=payment_info) assert capture_result == GatewayResponse( is_success=False, kind=TransactionKind.CAPTURE, amount=Decimal('10'), currency='CHF', transaction_id='1111111111114cf693a1cf86123e0d8f', error='some error', raw_response={}) process.assert_called_once_with( config=_netaxept_config, amount=Decimal('10'), transaction_id='1111111111114cf693a1cf86123e0d8f', operation=NetaxeptOperation.CAPTURE)