def test_invoice_data():
    checkout = CheckoutFactory(
        action=CheckoutAction.objects.invoice,
        content_object=SalesLedgerFactory(),
    )
    CheckoutAdditionalFactory(
        checkout=checkout,
        company_name='KB',
        email='*****@*****.**',
    )
    assert ('KB', '*****@*****.**') == tuple(checkout.invoice_data)
def test_get(client):
    CheckoutSettingsFactory()
    obj = SalesLedgerFactory()
    _set_session(client, obj.pk)
    obj = CheckoutFactory(
        action=CheckoutAction.objects.payment_plan,
        content_object=obj,
        total=Decimal('20'),
    )
    url = reverse('example.sales.ledger.checkout.success', args=[obj.pk])
    response = client.get(url)
    assert 200 == response.status_code
Exemple #3
0
def check_checkout(model_instance):
    """The 'Checkout' model links to generic content."""
    # @property list valid of actions e.g. ``return [CheckoutAction.PAYMENT]``
    model_instance.checkout_actions
    # @property check the model is in the correct state for taking payment
    model_instance.checkout_can_charge
    # @property the email address of the person who is paying
    model_instance.checkout_email
    # @property ``list`` of strings
    model_instance.checkout_description
    # method called on success, passing in the checkout action
    # model_instance.checkout_mail(CheckoutAction.objects.payment)
    # @property the name of the person who is paying
    model_instance.checkout_name
    # @property the total payment
    model_instance.checkout_total
    # ``method`` to update the object to record the payment failure.
    # Called from within a transaction so you can update the model.
    # Note: This method should update the ``model_instance`` AND ``save`` it.
    model_instance.checkout_fail()
    # method returning a url
    model_instance.checkout_fail_url(1)
    # Update the object to record the payment success.
    # Called from within a transaction so you can update the model.
    # Note: This method should update the ``model_instance`` AND ``save`` it.
    # We pass in the 'checkout' so the model instance can send an email etc.
    checkout = CheckoutFactory(
        action=CheckoutAction.objects.payment,
        content_object=model_instance,
        state=CheckoutState.objects.success,
        total=Decimal('123.45'),
    )
    model_instance.checkout_success(checkout)
    # method returning a url
    model_instance.checkout_success_url(1)
    model_instance.get_absolute_url()
    clean_and_save(model_instance)
def test_invoice_data_none():
    checkout = CheckoutFactory(
        action=CheckoutAction.objects.charge,
        content_object=SalesLedgerFactory(),
    )
    assert () == tuple(checkout.invoice_data)
def test_is_payment_plan_not():
    checkout = CheckoutFactory(
        action=CheckoutAction.objects.payment,
        content_object=SalesLedgerFactory(),
    )
    assert False == bool(checkout.is_payment_plan)
def test_no_content_object():
    """Payments must be linked to a content object."""
    with pytest.raises(IntegrityError):
        CheckoutFactory()