Custom Configurations in Django - 22
What we're going to want to do is be able to establish the key we have from PayPal and create them using a custom configuration. Nothing could be easier.
mystore\mystore\settings.py
PAYPAL_CLIENT_ID = '<YOURCLIENTID>'
PAYPAL_SECRET = '<YOURSECRETID>'
PAYPAL_BASE_URL = 'https://api-m.sandbox.paypal.com' #'https://api-m.paypal.com'
The above configurations are the PayPal public/client and secret keys, which you must obtain from the PayPal developer portal presented above.
We also configure the base URL for development:
'https://api-m.sandbox.paypal.com'
And this would be the one we use in production, that is, to make real payments:
'https://api-m.paypal.com'
And references from the view:
mystore\elements\views.py
from django.conf import settings
***
def detail(request, pk):
element = Element.objects.get(id=pk)
return render(request,'elements/detail.html',
{'element': element, 'paypal_client_id':
settings.PAYPAL_CLIENT_ID})