Get the api key
After you have created your account for Paddle, you will need to get the API key. You can do this by going to the API page in the dashboard. Here you will find the Secret key and the Publishable key. You will need the Secret key for the integration to work.Add environment variables
To use the Paddle integration, you need to define the following environment variables to your.env.local
as well as your production environment:
.env.local
In-App Purchases
You can use Paddle anywhere in your application by importing apaddle
object:
page.tsx
Creating a Checkout Session
We need to create a checkout session to charge your users , and you only need modify some code. It consists of two parts:- Client
/api/paddle/checkout
endpoint.
apps/web/[locale]/components/payment/price-form.tsx
- Server
apps/web/api/paddle/checkout/route.ts
.
If you want create a checkout session in client side, you can use the following code:
apps/web/[locale]/components/payment/price-form.tsx