def test_extract_gateway_response_no_transaction( braintree_error_response, braintree_error ): result = extract_gateway_response(braintree_error_response) assert result == { "errors": [{"code": braintree_error.code, "message": braintree_error.message}] }
def test_extract_gateway_response_no_transaction( braintree_error_response, braintree_error): result = extract_gateway_response(braintree_error_response) assert result == { 'errors': [ { 'code': braintree_error.code, 'message': braintree_error.message}]}
def test_extract_gateway_response_no_transaction(braintree_error_response, braintree_error): result = extract_gateway_response(braintree_error_response) assert result == { 'errors': [{ 'code': braintree_error.code, 'message': braintree_error.message }] }
def test_capture_incorrect_token(payment_txn_preauth, sandbox_braintree_gateway_config): payment_info = create_payment_information(payment_txn_preauth, "12345") with pytest.raises(BraintreeException) as e: response = capture(payment_info, sandbox_braintree_gateway_config) assert str(e.value) == DEFAULT_ERROR_MESSAGE assert response.raw_response == extract_gateway_response( braintree_error_response) assert not response.is_success assert response.error == DEFAULT_ERROR
def test_extract_gateway_response(braintree_success_response): result = extract_gateway_response(braintree_success_response) t = braintree_success_response.transaction expected_result = { 'currency': t.currency_iso_code, 'amount': t.amount, 'credit_card': t.credit_card, 'errors': [] } assert result == expected_result
def test_extract_gateway_response(braintree_success_response): result = extract_gateway_response(braintree_success_response) t = braintree_success_response.transaction expected_result = { 'currency': t.currency_iso_code, 'amount': t.amount, 'credit_card': t.credit_card, 'errors': [], 'transaction_id': t.id} assert result == expected_result
def test_extract_gateway_response(braintree_success_response): result = extract_gateway_response(braintree_success_response) t = braintree_success_response.transaction expected_result = { "currency": t.currency_iso_code, "amount": t.amount, "credit_card": t.credit_card, "errors": [], "transaction_id": t.id, } assert result == expected_result
def test_void_error_response(mock_gateway, payment_txn_preauth, braintree_error_response, gateway_config): payment = payment_txn_preauth mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock(transaction=Mock(void=mock_response)) payment_info = create_payment_information(payment) response = void(payment_info, gateway_config) assert response['raw_response'] == extract_gateway_response( braintree_error_response) assert not response['is_success'] assert response['error'] == DEFAULT_ERROR
def test_authorize_error_response( mock_gateway, payment_dummy, braintree_error_response, gateway_config): payment = payment_dummy payment_token = 'payment-token' mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock(transaction=Mock(sale=mock_response)) payment_info = create_payment_information(payment, payment_token) response = authorize(payment_info, gateway_config) assert response['raw_response'] == extract_gateway_response(braintree_error_response) assert not response['is_success'] assert response['error'] == DEFAULT_ERROR
def test_void_error_response(mock_gateway, payment_txn_preauth, braintree_error_response): payment = payment_txn_preauth mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock(transaction=Mock(void=mock_response)) txn, error = void(payment) assert txn.gateway_response == extract_gateway_response( braintree_error_response) assert not txn.is_success assert txn.amount == payment.total assert txn.currency == payment.currency assert error == DEFAULT_ERROR
def test_void_error_response( mock_gateway, payment_txn_preauth, braintree_error_response, gateway_config ): payment = payment_txn_preauth mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock(transaction=Mock(void=mock_response)) payment_info = create_payment_information(payment) response = void(payment_info, gateway_config) assert response.raw_response == extract_gateway_response(braintree_error_response) assert not response.is_success assert response.error == DEFAULT_ERROR
def test_capture_error_response(mock_gateway, payment_txn_preauth, braintree_error_response, gateway_config): payment = payment_txn_preauth mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock(transaction=Mock( submit_for_settlement=mock_response)) payment_info = create_payment_information(payment, 'token') response = capture(payment_info, gateway_config) assert response.raw_response == extract_gateway_response( braintree_error_response) assert not response.is_success assert response.error == DEFAULT_ERROR
def test_refund_error_response(mock_gateway, payment_txn_captured, braintree_error_response, gateway_config): payment = payment_txn_captured amount = Decimal('10.00') mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock(transaction=Mock(refund=mock_response)) payment_info = create_payment_information(payment, 'token', amount) response = refund(payment_info, gateway_config) assert response['raw_response'] == extract_gateway_response( braintree_error_response) assert not response['is_success'] assert response['error'] == DEFAULT_ERROR
def test_authorize_error_response(mock_gateway, payment_dummy, braintree_error_response, gateway_config): payment = payment_dummy payment_token = "payment-token" mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock(transaction=Mock(sale=mock_response)) payment_info = create_payment_information(payment, payment_token) response = authorize(payment_info, gateway_config) assert response.raw_response == extract_gateway_response( braintree_error_response) assert not response.is_success assert response.error == DEFAULT_ERROR
def test_refund_error_response(mock_gateway, payment_txn_captured, braintree_error_response): payment = payment_txn_captured amount = Decimal('10.00') mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock(transaction=Mock(refund=mock_response)) txn, error = refund(payment, amount) assert txn.gateway_response == extract_gateway_response( braintree_error_response) assert not txn.is_success assert txn.amount == amount assert txn.currency == payment.currency assert error == DEFAULT_ERROR
def test_authorize_error_response(mock_gateway, payment_dummy, braintree_error_response): payment = payment_dummy payment_token = 'payment-token' mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock(transaction=Mock(sale=mock_response)) txn, error = authorize(payment, payment_token) assert txn.gateway_response == extract_gateway_response( braintree_error_response) assert not txn.is_success assert txn.amount == payment.total assert txn.currency == payment.currency assert error == DEFAULT_ERROR
def test_refund_error_response( mock_gateway, payment_txn_captured, braintree_error_response, gateway_config ): payment = payment_txn_captured amount = Decimal("10.00") mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock(transaction=Mock(refund=mock_response)) payment_info = create_payment_information(payment, "token", amount) response = refund(payment_info, gateway_config) assert response.raw_response == extract_gateway_response(braintree_error_response) assert not response.is_success assert response.error == DEFAULT_ERROR
def test_capture_error_response(mock_gateway, payment_txn_preauth, braintree_error_response): payment = payment_txn_preauth amount = Decimal('10.00') mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock(transaction=Mock( submit_for_settlement=mock_response)) txn, error = capture(payment, amount) assert txn.gateway_response == extract_gateway_response( braintree_error_response) assert not txn.is_success assert txn.amount == amount assert txn.currency == payment.currency assert error == DEFAULT_ERROR
def test_capture_error_response( mock_gateway, payment_txn_preauth, braintree_error_response, gateway_config ): payment = payment_txn_preauth mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock( transaction=Mock(submit_for_settlement=mock_response) ) payment_info = create_payment_information(payment, "token") response = capture(payment_info, gateway_config) assert response.raw_response == extract_gateway_response(braintree_error_response) assert not response.is_success assert response.error == DEFAULT_ERROR
def test_capture_error_response( mock_gateway, payment_txn_preauth, braintree_error_response, gateway_config): payment = payment_txn_preauth amount = Decimal('10.00') mock_response = Mock(return_value=braintree_error_response) mock_gateway.return_value = Mock( transaction=Mock(submit_for_settlement=mock_response)) payment_info = create_payment_information(payment, 'token') response = capture(payment_info, gateway_config) assert response['raw_response'] == extract_gateway_response( braintree_error_response) assert not response['is_success'] assert response['error'] == DEFAULT_ERROR
def success_gateway_response(gateway_response): data = extract_gateway_response(gateway_response) data.pop("currency") data.pop("amount") return data
def success_gateway_response(gateway_response): data = extract_gateway_response(gateway_response) data.pop('currency') data.pop('amount') return data