Checkout

https://gitlab.com/kb/checkout

Note

This app replaces the old pay

forms.py:

from checkout.forms import CheckoutForm

class JobCheckoutForm(CheckoutForm):

    class Meta:
        model = Job
        fields = (
            'action',
        )

views.py:

from checkout.views import CheckoutMixin

class JobCheckoutView(
    PageFormMixin, CheckoutMixin, BaseMixin, UpdateView):

    model = Job
    form_class = JobCheckoutForm

In the html template:

{% include '_form.html' with submit='Checkout' form_id='id_checkout_form' %}

{% block script %}
  {{ block.super }}
  {% include 'checkout/_stripe.js.html' %}
{% endblock script %}

In your .private file, add your test keys for Stripe:

export STRIPE_PUBLISH_KEY="pk_test_123"
export STRIPE_SECRET_KEY="sk_test_456"

Testing:

from checkout.tests.helper import check_checkout

@pytest.mark.django_db
def test_checkout():
    obj = JobFactory()
    check_checkout(obj)

Stripe

To set-up Stripe, tick Payment reviews in Emails (Settings). Stripe will send email notifications for new payments placed in the review queue.

Testing

If you are using a copy of the live data set and you want to run test payments, then you might get a No such customer error. This is because the customer numbers on the live system will not match the customer numbers on your test system.

To remove the customer records on the live system:

from checkout.models import Customer
Customer.objects.all().delete()