Payments

Introduction

Choosing a payment provider is not a tech decision, each of them follows the same tech pattern. Send an order event via their API, receive a webhook event, and then process it. Simple.

The most popular payment providers right now are Stripe and Lemonsqueezy. Stripe acquired Lemonsqueezy, so I guess it's just Stripe right now. lol. To compare these two check this article https://medium.com/@support_46288/stripe-and-lemon-squeezy-choosing-the-right-payment-processing-platform-honest-comparison-8c896ec4f7ba

You can check other payment providers like Paddle https://www.paddle.com/. I can provide a list of payment providers here but it depends on your business and the country where you're from. I've built products that use Lemonsqueezy because the company that owns the product resides outside the US, for that reason, if you plan to use Stripe it will require you to establish an LLC inside the US.

This template implements Stripe and Lemonsqueezy, just use what fits your needs.

NOTE: Make sure to set up the database first before doing the steps below.

Set up Stripe

  1. Create a recurring product (for subscriptions) at https://dashboard.stripe.com/test/products

  1. Click the product you created and copy the price ID

  1. Replace the product ID on your table. (stripe_product_id_monthly or stripe_product_id_yearly)

  1. Forward webhook events to your server by using the command below

stripe listen --forward-to localhost:3000/api/webhooks/payments/stripe

  1. Try making a subscription order inside the customer app using the test cardshttps://docs.stripe.com/testing

Set up Lemonsqueezy

  1. Sign up for an account https://www.lemonsqueezy.com/

  2. Create a new store

  1. Copy the variant ID of your new product

  1. Replace the price ID on your table. (lemonsqueezy_product_id_monthly or lemonsqueezy_product_id_yearly)

  1. Create a new webhook event https://app.lemonsqueezy.com/settings/webhooks. Don't forget to create a secret key.

  1. Paste store ID, API Key, and webhook secret key to your .env file

  2. Expose your local customer app using this command

ngrok http http://localhost:3000/api/webhooks/payments/lemonsqueezy

  1. Try making a subscription order inside the customer app using the test cardshttps://docs.stripe.com/testing . Yes they share the same test cards since Lemonsqueezy is like a Stripe wrapper.

Last updated