You can accept payments in Val Town with Stripe. This guide teaches you the simplest method: Stripe Payment Links. Here’s how it works:
When users click to pay on your site, you redirect them to your Stripe Payment Link.
They pay with Stripe.
Stripe redirects them back to your site, where you can now store their payment information in a database, and thank them for their payment.
Try it out
1. Create a Payment Link
Head over to Payment Links in the Stripe dashboard and click the “create payment link” button.
2. Configure your Payment Link
On the Payment page tab, we’ll need to create a new product for our 1.00 tip.
On the After payment tab, we need to select Don't show confirmation page and fill out the input with our val’s /success endpoint so we can redirect users there after a successful transaction.
3. Repeat for each tip amount
Repeat steps 1 - 2 for each tip amount that will be used in the app. Here’s how we handle all the payment links in the app:
4. Handling successful transactions
After configuring and creating your Payment Links, we need to give our val the ability to handle successful transactions. Here’s the code used in the example val above:
Take it further
Congratulations 🥳! You can now use Stripe in Val Town with Payment Links!
What if we wanted to allow users to tip custom amounts though? In order to give users the ability to tip custom amounts, we must use the more customizable Stripe Checkout.