vanegeek
vanegeek

Reputation: 713

Can you run server side code on Squarespace?

I need to build a custom form to collect card details using Stripe.

The form will allow users to enroll in a free trial. The form will collect customers card information without immediately charging them. Then after 7 days, we will charge them the full course amount.


Current behavior:


  1. Visitors select the course 
2) Create an account
  2. They are redirected to the free course page



Desired behavior: 
1) Visitors select the course 
2) Create an account 3) Enter their payment info (here the custom form collects payment info, creates a new customer on stripe with their card info) 
4) They are redirected to the free course page
 5) after 7 days if customer hasn’t cancelled trial we bill then the full course amount.

Here is a Stripe guide for how to save clients payment info: https://stripe.com/docs/payments/quickstart?lang=node

Here is Squarespace Development Platform: https://developers.squarespace.com/quick-start

Upvotes: 0

Views: 178

Answers (1)

Brandon
Brandon

Reputation: 3697

Squarespace doesn't support any server-side/back-end code; it only supports the front-end addition of HTML, CSS and Javascript within Code Injection, Code Blocks, and Developer Mode.

Squarespace can host the custom form itself which, along with your Stripe API publishable key, can be added via HTML, CSS and JavaScript, either via Code Injection, Dev. Mode or Code Block. But you'd need another server/cloud-function setup outside of Squarespace which would communicate with the Stripe API using your secret key to create sessions, customers, etc. You cannot do that part securely from the front-end alone (and since Squarespace doesn't support server-side/back-end code, you must have another service available to do that).

As an aside, putting a website in Developer Mode (A.K.A using the Developer Platform) does not enable the use of server-side code. It just gives a bit more access to the "surrounding" front-end template files.

Upvotes: 1

Related Questions