PayPal: Client-Side Integration - JavaScript CDN: Getting Started - 21
Now that we know what we have to do to get the PayPal keys for Django, that is, the developer mode in PayPal as I showed you in the previous video, to continue with this class you have to have both the client and the Secret, especially now the client, which is the one we are going to use, we will use the Secret later, so to expand this integration we are going to use a plugin that I am going to leave somewhere in life.
https://www.npmjs.com/package/@paypal/paypal-js
It is possible to use it through Node or the CDN, which is the one we are going to use:
<script src="https://www.paypal.com/sdk/js?client-id=test"></script>
Having clarified this a little, let's start what we are going to do first to separate things, I am going to place it here in the editor, we are going to create a new template, a new template that I am going to place:
mystore\elements\templates\partials\paypal.html
<div id="buttonPayPal"></div>
<script>
paypal.Buttons().render('#buttonPayPal');
</script>
And on the detail page, we load the JS:
mystore\elements\templates\elements\detail.html
{% block content %}
<script src="https://www.paypal.com/sdk/js?client-id=<YOURCLIENTID>"></script>
***
<div class="card-body">
{% include "partials/paypal.html" %}
***
Where it says <YOURCLIENTID>, you could enter your PayPal-provided password, but we'll create a more modular layout in the next section.
But with the code above, you should be able to see the PayPal buttons from your website.