def test_void_error_response(stripe_payment, sandbox_gateway_config): INVALID_INTENT = "THIS_INTENT_DOES_NOT_EXISTS" payment_info = create_payment_information(stripe_payment, INVALID_INTENT) response = void(payment_info, sandbox_gateway_config) assert response.error == "No such payment_intent: " + INVALID_INTENT assert response.transaction_id == INVALID_INTENT assert response.kind == TransactionKind.VOID assert not response.is_success assert response.amount == stripe_payment.total assert response.currency == stripe_payment.currency
def test_void_not_authorized(stripe_payment, gateway_params): payment = stripe_payment txn, error = void(payment, **gateway_params) assert error == ORDER_NOT_AUTHORIZED assert txn.payment == payment assert txn.token == '' assert txn.kind == TransactionKind.VOID assert not txn.is_success assert txn.amount == payment.total assert txn.currency == TRANSACTION_CURRENCY assert txn.gateway_response == {}
def test_void(stripe_paid_payment, sandbox_gateway_config): # Get id from sandbox for succedeed payment INTENT_ID = "pi_1F5BsOIUmJaD6Oqvmh5vBJIA" payment_info = create_payment_information(stripe_paid_payment, payment_token=INTENT_ID) response = void(payment_info, sandbox_gateway_config) assert not response.error assert response.transaction_id == INTENT_ID assert response.kind == TransactionKind.VOID assert response.is_success assert isclose(response.amount, TRANSACTION_AMOUNT) assert response.currency == TRANSACTION_CURRENCY
def test_void_error_response(mock_charge_retrieve, mock_refund_create, stripe_authorized_payment, gateway_params): payment = stripe_authorized_payment payment_info = create_payment_information(payment, TRANSACTION_TOKEN) mock_charge_retrieve.return_value = Mock(id='') stripe_error = stripe.error.InvalidRequestError(message=ERROR_MESSAGE, param=None) mock_refund_create.side_effect = stripe_error response = void(payment_info, gateway_params) assert response.error == ERROR_MESSAGE assert response.transaction_id == TRANSACTION_TOKEN assert response.kind == TransactionKind.VOID assert not response.is_success assert response.amount == payment.total assert response.currency == TRANSACTION_CURRENCY assert response.raw_response == {}
def test_void(mock_charge_retrieve, mock_refund_create, stripe_authorized_payment, gateway_params, stripe_refund_success_response): payment = stripe_authorized_payment payment_info = create_payment_information(payment, TRANSACTION_TOKEN) response = stripe_refund_success_response mock_charge_retrieve.return_value = Mock(id='') mock_refund_create.return_value = response response = void(payment_info, gateway_params) assert not response.error assert response.transaction_id == TRANSACTION_TOKEN assert response.kind == TransactionKind.VOID assert response.is_success assert isclose(response.amount, TRANSACTION_REFUND_AMOUNT) assert response.currency == TRANSACTION_CURRENCY assert response.raw_response == stripe_refund_success_response
def test_void_error_response(mock_charge_retrieve, mock_refund_create, stripe_authorized_payment, gateway_params): payment = stripe_authorized_payment mock_charge_retrieve.return_value = Mock(id='') stripe_error = stripe.error.InvalidRequestError(message=ERROR_MESSAGE, param=None) mock_refund_create.side_effect = stripe_error txn, error = void(payment, **gateway_params) assert error == ERROR_MESSAGE assert txn.payment == payment assert txn.token == '' assert txn.kind == TransactionKind.VOID assert not txn.is_success assert txn.amount == payment.total assert txn.currency == TRANSACTION_CURRENCY assert txn.gateway_response == _get_error_response_from_exc(stripe_error)
def test_void(mock_charge_retrieve, mock_refund_create, stripe_authorized_payment, gateway_params, stripe_refund_success_response): payment = stripe_authorized_payment response = stripe_refund_success_response mock_charge_retrieve.return_value = Mock(id='') mock_refund_create.return_value = response txn, error = void(payment, **gateway_params) assert not error assert txn.payment == payment assert txn.token == TRANSACTION_TOKEN assert txn.kind == TransactionKind.VOID assert txn.is_success assert isclose(txn.amount, TRANSACTION_REFUND_AMOUNT) assert txn.currency == TRANSACTION_CURRENCY assert txn.gateway_response == response
def test_void_error_response( mock_charge_retrieve, mock_refund_create, stripe_authorized_payment, gateway_config ): payment = stripe_authorized_payment payment_info = create_payment_information(payment, TRANSACTION_TOKEN) mock_charge_retrieve.return_value = Mock(id="") stripe_error = stripe.error.InvalidRequestError(message=ERROR_MESSAGE, param=None) mock_refund_create.side_effect = stripe_error response = void(payment_info, gateway_config) assert response.error == ERROR_MESSAGE assert response.transaction_id == TRANSACTION_TOKEN assert response.kind == TransactionKind.VOID assert not response.is_success assert response.amount == payment.total assert response.currency == TRANSACTION_CURRENCY assert response.raw_response == {}
def test_void( mock_charge_retrieve, mock_refund_create, stripe_authorized_payment, gateway_params, stripe_refund_success_response): payment = stripe_authorized_payment payment_info = create_payment_information(payment, TRANSACTION_TOKEN) response = stripe_refund_success_response mock_charge_retrieve.return_value = Mock(id='') mock_refund_create.return_value = response response = void(payment_info, gateway_params) assert not response['error'] assert response['transaction_id'] == TRANSACTION_TOKEN assert response['kind'] == TransactionKind.VOID assert response['is_success'] assert isclose(response['amount'], TRANSACTION_REFUND_AMOUNT) assert response['currency'] == TRANSACTION_CURRENCY assert response['raw_response'] == stripe_refund_success_response
def test_void( mock_charge_retrieve, mock_refund_create, stripe_authorized_payment, gateway_config, stripe_refund_success_response, ): payment = stripe_authorized_payment payment_info = create_payment_information(payment, TRANSACTION_TOKEN) response = stripe_refund_success_response mock_charge_retrieve.return_value = Mock(id="") mock_refund_create.return_value = response response = void(payment_info, gateway_config) assert not response.error assert response.transaction_id == TRANSACTION_TOKEN assert response.kind == TransactionKind.VOID assert response.is_success assert isclose(response.amount, TRANSACTION_REFUND_AMOUNT) assert response.currency == TRANSACTION_CURRENCY assert response.raw_response == stripe_refund_success_response