Jump to content

Paypal Button Code

Recommended Posts

Site URL: https://gatewaynaturepreserve.org/spring-into-art-sale

We are hosting a virtual art sale fundraiser for our organization. I used a code to add paypal pay buttons/credit card pay buttons to each item in the store. The payment goes through when someone makes an order but the item is not marked sold, in addition, it doesn't tell me which item was sold just the amount that was paid. Can you please help me solve this issue? Is there something I can add to the code to make it record the sold item as well as specify which item was paid for?

This is the code I used, just changed the value to reflect the price of each of the items:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Ensures optimal rendering on mobile devices. -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- Optimal Internet Explorer compatibility -->
  </head>

  <body>
    <script src="https://www.paypal.com/sdk/js?client-id=ATxUbt3GpgXOZ362Wh5NhG-hA5DJrXMLwxwvJxuo0TThwiJTuyUUAkpfTb6YYLJ_oJexD_lWAHElcNNL"> // Replace YOUR_CLIENT_ID with your sandbox client ID
    </script>

    <div id="paypal-button-container"></div>

    <!-- Add the checkout buttons, set up the order and approve the order -->
    <script>
      paypal.Buttons({
        createOrder: function(data, actions) {
          return actions.order.create({
            purchase_units: [{
              amount: {
                value: '0.01'
              }
            }]
          });
        },
        onApprove: function(data, actions) {
          return actions.order.capture().then(function(details) {
            alert('Transaction completed by ' + details.payer.name.given_name);
          });
        }
      }).render('#paypal-button-container'); // Display payment options on your web page
    </script>
  </body>
</html>

Link to comment
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

On 4/21/2021 at 8:42 PM, GatewayNaturePreserve said:

We are hosting a virtual art sale fundraiser for our organization. I used a code to add paypal pay buttons/credit card pay buttons to each item in the store. The payment goes through when someone makes an order but the item is not marked sold

It isn't possible to integrate a third-party payment method with Squarespace commerce. As you've found, if you use code to add a payment method, all the processing will happen on the third-party system. It will NOT happen on Squarespace, so you Squarespace won't be able to manage order processing, notifications, inventory management, shipping or anything else. 

Can you explain why you haven't used the built-in payment methods (PayPal and Stripe) to take payment? This doesn't require any code as it is built into Squarespace.

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

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.