Installing the Braintree Python module

Braintree provides a Python module that simplifies dealing with its API. The source code is located at https://github.com/braintree/braintree_python. We are going to integrate the payment gateway into our project using the braintree module.

Install the braintree module from the shell using the following command:

pip install braintree==3.45.0

Add the following settings to the settings.py file of your project:

# Braintree settingsBRAINTREE_MERCHANT_ID = 'XXX'  # Merchant IDBRAINTREE_PUBLIC_KEY = 'XXX'   # Public KeyBRAINTREE_PRIVATE_KEY = 'XXX'  # Private keyfrom braintree import Configuration, EnvironmentConfiguration.configure(    Environment.Sandbox,    BRAINTREE_MERCHANT_ID,    BRAINTREE_PUBLIC_KEY, BRAINTREE_PRIVATE_KEY ...

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.