DjangoPayPal (3) – Server Side Django.How

Author avatar wrote on 01/06/2022

WAY 3 PayPal Server Side

+ Migrate is not needed – no changes to DB
– You need a client key not just the email
– Package must be installed
– PayPal app should be created in PayPal

1. Create sandbox account -for testing
  • one for pesonal
  • one for business
  • https://developer.paypal.com/developer/accounts/create
  • 2. Create business app in paypal

    https://developer.paypal.com/developer

    3. Install

    pip install paypal-checkout-serversdk

    4. Update settings

    PAYPAL_CLIENT_ID = “client id here”
    PAYPAL_SECRET_ID = “secret id here”

    5. Get client id from server-side
    learn/views.py
    
    def pay(request, pk):
        client_id = settings.PAYPAL_CLIENT_ID
        course = get_object_or_404(Course, pk=pk)
        return render(request, 'pay.html', {'course':course, 'client_id':client_id })
    

    6. Temaple learn/templates/pay.html

    Resource
  • https://abderrahmane.hashnode.dev/the-basics-of-adding-paypal-payments-to-django-server-and-client-side
  • CRUDgen Django CRUD generator