Integrating the payment gateway

The checkout process will work as follows:

  1. Add items to the shopping cart
  2. Check out the shopping cart
  3. Enter credit card details and pay

We are going to create a new application to manage payments. Create a new application in your project using the following command:

python manage.py startapp payment

Edit the settings.py file of your project and add the new application to the INSTALLED_APPS setting as follows:

INSTALLED_APPS = [    # ...    'payment.apps.PaymentConfig',]

The payment application is now active.

After clients place an order, we need to redirect them to the payment process. Edit the views.py file of the orders application and include the following imports:

from django.urls import reversefrom django.shortcuts ...

Get Django 2 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.