def test_refund_invalid_data( mocked_gateway, mocked_logger, charged_payment, razorpay_success_response, gateway_config, ): # Assign the side effect to the gateway's `refund()` method, # that should trigger the expected error. mocked_gateway.return_value.payment.refund.side_effect = ServerError() # Attempt charging payment_info = create_payment_information(charged_payment, amount=TRANSACTION_AMOUNT) response = refund(payment_info, gateway_config) # Ensure a error was returned assert response.error == errors.SERVER_ERROR assert not response.is_success # Ensure the transaction is correctly set assert response.kind == TransactionKind.REFUND # Ensure the HTTP error was logged assert mocked_logger.call_count == 1
def test_refund_invalid_data( mocked_gateway, mocked_logger, charged_payment, razorpay_success_response, gateway_config, ): # Assign the side effect to the gateway's `refund()` method, # that should trigger the expected error. mocked_gateway.return_value.payment.refund.side_effect = ServerError() # Attempt charging payment_info = create_payment_information( charged_payment, amount=TRANSACTION_AMOUNT ) response = refund(payment_info, gateway_config) # Ensure a error was returned assert response.error == errors.SERVER_ERROR assert not response.is_success # Ensure the transaction is correctly set assert response.kind == TransactionKind.REFUND # Ensure the HTTP error was logged assert mocked_logger.call_count == 1
def test_refund( mocked_gateway, charged_payment, razorpay_success_response, gateway_params): # Mock the gateway response to a success response mocked_gateway.return_value.payment.refund.return_value = ( razorpay_success_response) payment_info = create_payment_information( charged_payment, amount=TRANSACTION_AMOUNT) # Attempt charging response = refund(payment_info, gateway_params) # Ensure the was no error returned assert not response['error'] assert response['is_success'] assert response['kind'] == TransactionKind.REFUND assert response['amount'] == TRANSACTION_AMOUNT assert response['currency'] == razorpay_success_response['currency'] assert response['raw_response'] == razorpay_success_response assert response['transaction_id'] == razorpay_success_response['id']
def test_refund_unsupported_currency(razorpay_payment, charged_payment, gateway_params): # Set the payment currency to an unsupported currency razorpay_payment.currency = 'USD' # Attempt charging txn, error = refund(razorpay_payment, TRANSACTION_AMOUNT, **gateway_params) # Ensure a error was returned assert error == errors.UNSUPPORTED_CURRENCY % {'currency': 'USD'} assert not txn.is_success # Ensure the transaction is correctly set assert txn.payment == razorpay_payment assert txn.kind == TransactionKind.REFUND
def test_refund_not_paid(mocked_gateway, razorpay_payment, razorpay_success_response, gateway_params): # Mock the gateway response to a success response mocked_gateway.return_value.payment.refund.return_value = ( razorpay_success_response) # Attempt charging txn, error = refund(razorpay_payment, TRANSACTION_AMOUNT, **gateway_params) # Ensure a error was returned assert error == errors.ORDER_NOT_CHARGED assert not txn.is_success # Ensure the transaction is correctly set assert txn.payment == razorpay_payment assert txn.kind == TransactionKind.REFUND
def test_refund_unsupported_currency(razorpay_payment, charged_payment, gateway_config): # Set the payment currency to an unsupported currency razorpay_payment.currency = "MXN" payment_info = create_payment_information( razorpay_payment, amount=TRANSACTION_AMOUNT ) # Attempt charging response = refund(payment_info, gateway_config) # Ensure a error was returned assert response.error == (errors.UNSUPPORTED_CURRENCY % {"currency": "MXN"}) assert not response.is_success # Ensure the kind is correctly set assert response.kind == TransactionKind.REFUND
def test_refund_unsupported_currency(razorpay_payment, charged_payment, gateway_config): # Set the payment currency to an unsupported currency razorpay_payment.currency = "USD" payment_info = create_payment_information( razorpay_payment, amount=TRANSACTION_AMOUNT ) # Attempt charging response = refund(payment_info, gateway_config) # Ensure a error was returned assert response.error == (errors.UNSUPPORTED_CURRENCY % {"currency": "USD"}) assert not response.is_success # Ensure the kind is correctly set assert response.kind == TransactionKind.REFUND
def test_refund_unsupported_currency( razorpay_payment, charged_payment, gateway_params): # Set the payment currency to an unsupported currency razorpay_payment.currency = 'USD' payment_info = create_payment_information( razorpay_payment, amount=TRANSACTION_AMOUNT) # Attempt charging response = refund(payment_info, gateway_params) # Ensure a error was returned assert response['error'] == ( errors.UNSUPPORTED_CURRENCY % {'currency': 'USD'}) assert not response['is_success'] # Ensure the kind is correctly set assert response['kind'] == TransactionKind.REFUND
def test_refund_invalid_data(mocked_gateway, mocked_logger, charged_payment, razorpay_success_response, gateway_params): # Assign the side effect to the gateway's `refund()` method, # that should trigger the expected error. mocked_gateway.return_value.payment.refund.side_effect = ServerError() # Attempt charging txn, error = refund(charged_payment, TRANSACTION_AMOUNT, **gateway_params) # Ensure a error was returned assert error == errors.SERVER_ERROR assert not txn.is_success # Ensure the transaction is correctly set assert txn.payment == charged_payment assert txn.kind == TransactionKind.REFUND # Ensure the HTTP error was logged assert mocked_logger.call_count == 1
def test_refund(mocked_gateway, charged_payment, razorpay_success_response, gateway_params): # Mock the gateway response to a success response mocked_gateway.return_value.payment.refund.return_value = ( razorpay_success_response) # Attempt charging txn, error = refund(charged_payment, TRANSACTION_AMOUNT, **gateway_params) # Ensure the was no error returned assert not error assert txn.is_success assert txn.payment == charged_payment assert txn.kind == TransactionKind.REFUND assert txn.amount == TRANSACTION_AMOUNT assert txn.currency == razorpay_success_response['currency'] assert txn.gateway_response == {} assert txn.token == razorpay_success_response['id']
def test_refund(mocked_gateway, charged_payment, razorpay_success_response, gateway_config): # Mock the gateway response to a success response mocked_gateway.return_value.payment.refund.return_value = razorpay_success_response payment_info = create_payment_information(charged_payment, amount=TRANSACTION_AMOUNT) # Attempt charging response = refund(payment_info, gateway_config) # Ensure the was no error returned assert not response.error assert response.is_success assert response.kind == TransactionKind.REFUND assert response.amount == TRANSACTION_AMOUNT assert response.currency == razorpay_success_response["currency"] assert response.raw_response == razorpay_success_response assert response.transaction_id == razorpay_success_response["id"]
def test_refund( mocked_gateway, charged_payment, razorpay_success_response, gateway_config ): # Mock the gateway response to a success response mocked_gateway.return_value.payment.refund.return_value = razorpay_success_response payment_info = create_payment_information( charged_payment, amount=TRANSACTION_AMOUNT ) # Attempt charging response = refund(payment_info, gateway_config) # Ensure the was no error returned assert not response.error assert response.is_success assert response.kind == TransactionKind.REFUND assert response.amount == TRANSACTION_AMOUNT assert response.currency == razorpay_success_response["currency"] assert response.raw_response == razorpay_success_response assert response.transaction_id == razorpay_success_response["id"]