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
  • Views 1k
  • Created
  • Last Reply
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'm Paul, a SQSP user for over 18 yrs and a Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL, providing high quality original extensions to supercharge your Squarespace website. 
Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links.
Forum advice is completely free. You can thank me by selecting a feedback emoji below. Buying a coffee is optional.

Book paid help with domains: Connect a GoDaddy domain. Connect a Squarespace Domain. Domain assistance

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.