How do I get a paypal button on one of my pages?

Xarzu

New member
Registered
Joined
Jul 2, 2020
Messages
4
Points
1
So, first of all, I have a paypal account. I logged into paypal and I asked them to give me the code for a button.
The problem is that after I copied the generated code into my clip board and then pasted it into my text editor, what I got was a whole lot of nothing. It has some <div> tags and some <script> tags but there is absolutely nothing that tells me that the code there points to my account or anything.
There must be a whole lot of page data I am missing.
Is there anyone who can suggest what I should do?
When I put this into an html page, the browser just ignores everything.
It is as if it is a generic thing and not specified to me.
HTML:
<div id="paypal-button-container"></div>
<script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD" data-sdk-integration-source="button-factory"></script>
<script>
  paypal.Buttons({
      style: {
          shape: 'pill',
          color: 'gold',
          layout: 'vertical',
          label: 'pay',
          
      },
      createOrder: function(data, actions) {
          return actions.order.create({
              purchase_units: [{
                  amount: {
                      value: '1'
                  }
              }]
          });
      },
      onApprove: function(data, actions) {
          return actions.order.capture().then(function(details) {
              alert('Transaction completed by ' + details.payer.name.given_name + '!');
          });
      }
  }).render('#paypal-button-container');
</script>
 

David Beroff

Well-known member
Registered
Joined
Jun 14, 2016
Messages
1,488
Points
63
When I put this into an html page, the browser just ignores everything.
When I put your code into a html page, it showed a Paypal button

paypal-button.jpg
 

Xarzu

New member
Registered
Joined
Jul 2, 2020
Messages
4
Points
1
Xarzu
I use textpad to make a page with just<html> and <body> tags. Do you have more than that which I must be missing? Do you have a <header> which somehow enables javascript or a <html> tag with more information in it?
 

Xarzu

New member
Registered
Joined
Jul 2, 2020
Messages
4
Points
1
ok, so I noticed that I too can use these buttons as long as there is enough space on the html page to allow for a drop down. So I gave these buttons a test and I found that they linked to a sandbox URL.

The code, itself has a line where the client-id is set to "sb" which I assume means "sand box"
Code:
<script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD" data-sdk-integration-source="button-factory"></script>
So I looked around at the paypal web site, and I found I could generate a client id, which I did,
I also set it such that an online url coudl abve associated with my paypal account.
So, then I replaced the id in the html sdcript to be this client id instead of "sb""
and ftp uploaded the html page to my website to try it.
It didn't seem to work though

Any suggestions?
 
Last edited:

Xarzu

New member
Registered
Joined
Jul 2, 2020
Messages
4
Points
1
I settled on using the old school button
 
Older Threads
Newer Threads
Replies
5
Views
1,760
Replies
0
Views
987
Replies
2
Views
1,599
Replies
11
Views
2,171
Replies
2
Views
1,027
Recommended Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top