Payments
Last updated
Last updated
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.
Create a Stripe Account https://dashboard.stripe.com/register
Install Stripe CLI https://stripe.com/docs/stripe-cli#install
Get the API key by revealing the test key https://dashboard.stripe.com/test/apikeys and paste it on your .env file.
Create a recurring product (for subscriptions) at https://dashboard.stripe.com/test/products
Click the product you created and copy the price ID
Replace the product ID on your table. (stripe_product_id_monthly
or stripe_product_id_yearly
)
Forward webhook events to your server by using the command below
stripe listen --forward-to localhost:3000/api/webhooks/payments/stripe
Try making a subscription order inside the customer app using the test cardshttps://docs.stripe.com/testing
Sign up for an account https://www.lemonsqueezy.com/
Create a new store
Add a new product https://app.lemonsqueezy.com/products
Copy the variant ID of your new product
Replace the price ID on your table. (lemonsqueezy_product_id_monthly
or lemonsqueezy_product_id_yearly
)
Create a new webhook event https://app.lemonsqueezy.com/settings/webhooks. Don't forget to create a secret key.
Create API Key https://app.lemonsqueezy.com/settings/api
Copy your store ID https://app.lemonsqueezy.com/settings/stores
Paste store ID, API Key, and webhook secret key to your .env file
Install ngrok https://ngrok.com/docs/getting-started/
Expose your local customer app using this command
ngrok http http://localhost:3000/api/webhooks/payments/lemonsqueezy
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.