Jump to content

JayEnglish

Member
  • Posts

    1
  • Joined

  • Last visited

Everything posted by JayEnglish

  1. I have a code that produces a pay later button on squarespace. My site is retreat based and so there are multiple payment options. The pay later button is designed to split the ONE price on the page into 4 payments. Thats one part of it. The other part is....I need to be able to have multiple pricing options using the pay later feature. This is so that I can create a pay later button for each product option on the same page (other wise I will have to create a different page for every product that offers this feature, which would be about 50 separate pages just for this feature to work for me) HERE IS the paypal code im using in a code block that produces the pay later button <!DOCTYPE html> <html lang="en"> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>PayPal Standard Payments Integration | Client Demo</title> </head> <body> <div id="paypal-button-container"></div> <!-- Sample PayPal credentials (client-id) are included --> <script src="https://www.paypal.com/sdk/js?client-id=test&currency=USD&intent=capture" data-sdk-integration-source="integrationbuilder"></script> <script> const fundingSources = [ paypal.FUNDING.PAYLATER ] for (const fundingSource of fundingSources) { const paypalButtonsComponent = paypal.Buttons({ fundingSource: fundingSource, // optional styling for buttons // https://developer.paypal.com/docs/checkout/standard/customize/buttons-style-guide/ style: { shape: 'rect', height: 40, }, // set up the transaction createOrder: (data, actions) => { // pass in any options from the v2 orders create call: // https://developer.paypal.com/api/orders/v2/#orders-create-request-body const createOrderPayload = { purchase_units: [ { amount: { value: '88.44', }, }, ], } return actions.order.create(createOrderPayload) }, // finalize the transaction onApprove: (data, actions) => { const captureOrderHandler = (details) => { const payerName = details.payer.name.given_name console.log('Transaction completed!') } return actions.order.capture().then(captureOrderHandler) }, // handle unrecoverable errors onError: (err) => { console.error( 'An error prevented the buyer from checking out with PayPal', ) }, }) if (paypalButtonsComponent.isEligible()) { paypalButtonsComponent .render('#paypal-button-container') .catch((err) => { console.error('PayPal Buttons failed to render') }) } else { console.log('The funding source is ineligible') } } </script> </body> </html> Paypal does have a feature with the options built in, its called the Buy now button. Im thinking a merger of the two codes could produce the results im looking for.
×
×
  • 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.