Esempio n. 1
0
def test_dummy_payment_form(kind, charge_status, payment_dummy):
    payment = payment_dummy
    data = {'charge_status': charge_status}
    payment_gateway, gateway_params = get_payment_gateway(payment.gateway)
    payment_info = create_payment_information(payment)

    form = payment_gateway.create_form(
        data=data, payment_information=payment_info,
        connection_params=gateway_params)
    assert form.is_valid()
    gateway_process_payment(
        payment=payment, payment_token=form.get_payment_token())
    payment.refresh_from_db()
    assert payment.transactions.last().kind == kind
Esempio n. 2
0
def test_dummy_payment_form(kind, charge_status, settings, payment_dummy):
    payment = payment_dummy
    data = {'charge_status': charge_status}
    payment_gateway, gateway_params = get_payment_gateway(payment.gateway)
    payment_info = create_payment_information(payment)

    form = payment_gateway.create_form(data=data,
                                       payment_information=payment_info,
                                       connection_params=gateway_params)
    assert form.is_valid()
    gateway_process_payment(payment=payment,
                            payment_token=form.get_payment_token())
    payment.refresh_from_db()
    assert payment.transactions.last().kind == kind
Esempio n. 3
0
def test_gateway_process_payment(
        mock_get_payment_gateway, payment_txn_preauth, gateway_params,
        transaction_token, dummy_response):
    payment_token = transaction_token
    payment = payment_txn_preauth
    mock_process_payment = Mock(return_value=dummy_response)
    mock_get_payment_gateway.return_value = (
        Mock(process_payment=mock_process_payment), gateway_params)

    payment_info = create_payment_information(payment, payment_token)
    gateway_process_payment(payment, payment_token)

    mock_get_payment_gateway.assert_called_with(payment.gateway)
    mock_process_payment.assert_called_once_with(
        payment_information=payment_info, connection_params=gateway_params)
Esempio n. 4
0
def test_gateway_process_payment(
        mock_get_payment_gateway, payment_txn_preauth, gateway_params,
        transaction_token, dummy_response):
    payment_token = transaction_token
    payment = payment_txn_preauth
    mock_process_payment = Mock(return_value=[dummy_response, dummy_response])
    mock_get_payment_gateway.return_value = (
        Mock(process_payment=mock_process_payment), gateway_params)

    payment_info = create_payment_information(payment, payment_token)
    gateway_process_payment(payment, payment_token)

    mock_get_payment_gateway.assert_called_with(payment.gateway)
    mock_process_payment.assert_called_once_with(
        payment_information=payment_info, connection_params=gateway_params)