Example #1
0
def test_dummy_payment_form(kind, charge_status, payment_dummy):
    payment = payment_dummy
    data = {"charge_status": charge_status}

    form = gateway.create_payment_form(payment=payment, data=data)
    assert form.is_valid()
    gateway.process_payment(payment=payment, token=form.get_payment_token())
    payment.refresh_from_db()
    assert payment.transactions.last().kind == kind
def test_process_payment(mock_payment_interface, payment_txn_preauth):
    PAYMENT_DATA = create_payment_information(payment=payment_txn_preauth,
                                              payment_token=TOKEN)
    mock_payment_interface.process_payment.return_value = PROCESS_PAYMENT_RESPONSE

    transaction = gateway.process_payment(payment=payment_txn_preauth,
                                          token=TOKEN)

    mock_payment_interface.process_payment.assert_called_once_with(
        USED_GATEWAY, PAYMENT_DATA)
    assert transaction.amount == PROCESS_PAYMENT_RESPONSE.amount
    assert transaction.kind == TransactionKind.CAPTURE
    assert transaction.currency == "usd"
    assert transaction.gateway_response == RAW_RESPONSE
def test_store_source_when_processing_payment(mock_payment_interface,
                                              payment_txn_preauth):
    PAYMENT_DATA = create_payment_information(payment=payment_txn_preauth,
                                              payment_token=TOKEN,
                                              store_source=True)
    mock_payment_interface.process_payment.return_value = PROCESS_PAYMENT_RESPONSE

    transaction = gateway.process_payment(payment=payment_txn_preauth,
                                          token=TOKEN,
                                          store_source=True)

    mock_payment_interface.process_payment.assert_called_once_with(
        USED_GATEWAY, PAYMENT_DATA)
    assert transaction.customer_id == PROCESS_PAYMENT_RESPONSE.customer_id