Jump to content

Duplicating PayPal code blocks - only one of them works

Recommended Posts

I'd like to use the below paypal code in a multiple spots on the one page, but they seem to cancel each other out. When I view the live page, only one instance of the code works.

How can I use the same code several times on one page without it cancelling itself out? I've tried changing the div id for each instance.

<div id="paypal-button-container-P-0N639951XH242245SMFZ55JI"></div> <script src="https://www.paypal.com/sdk/js?client-id=AVK6OAb9FUfrk9nOyAnPy5SKpT-jtF9yGVAXqaDjpONPYhQbUspycoO3XvsLq0V-GQnzr11Vu9Rr3MUV&vault=true&intent=subscription" data-sdk-integration-source="button-factory"></script> <script> paypal.Buttons({ style: { shape: 'pill', color: 'blue', layout: 'vertical', label: 'subscribe' }, createSubscription: function(data, actions) { return actions.subscription.create({ /* Creates the subscription */ plan_id: 'P-0N639951XH242245SMFZ55JI' }); }, onApprove: function(data, actions) { alert(data.subscriptionID); // You can add optional success message for the subscriber here } }).render('#paypal-button-container-P-0N639951XH242245SMFZ55JI'); // Renders the PayPal button </script>

Thanks!

 
 
 
Edited by darth_morgan
Link to comment
  • Replies 3
  • Views 363
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 month later...
On 12/9/2021 at 1:28 AM, mccartio said:

I am having the same issue and could use some more detail on tuanphan's answer. Are you saying to simply change the DIV id? Thanks for any clarification. 

I meant try remove this line from Code Block 2

<script src="https://www.paypal.com/sdk/js?client-id=AVK6OAb9FUfrk9nOyAnPy5SKpT-jtF9yGVAXqaDjpONPYhQbUspycoO3XvsLq0V-GQnzr11Vu9Rr3MUV&vault=true&intent=subscription" data-sdk-integration-source="button-factory"></script>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.