Polar

Learn how to accept payments using the starter kit.

Nuxt Starter Kit uses Polar to accept payments. Polar is a simple and secure way to accept payments online. It provides a simple API for creating and managing subscriptions, invoices, and payments.

Getting Started

To get started with Polar, you need to create an account and set up your API keys. You can do this by following the instructions in the Polar documentation.

In your code, you need to set the following environment variables in your .env file:

NUXT_PRIVATE_POLAR_ACCESS_TOKEN=
NUXT_PRIVATE_POLAR_WEBHOOK_SECRET=
NUXT_PRIVATE_POLAR_ORGANIZATION_ID=
NUXT_PRIVATE_POLAR_SERVER=

NUXT_PRIVATE_POLAR_ACCESS_TOKEN

This is your Polar access token. You can generate one in your Polar account settings. This token is used to authenticate your requests to the Polar API.

NUXT_PRIVATE_POLAR_WEBHOOK_SECRET

Follow the Setup Webhooks guide to set up webhooks in your Polar account.

Here some important notes:

  1. Use the URL https://<YOUR_APP_URL/api/payment/webhook/polar
  2. Select all events
  3. Generate a webhook secret and use it for this environment variable.

NUXT_PRIVATE_POLAR_ORGANIZATION_ID

This is the ID of your Polar organization. You can find this in your Polar account settings. This ID is used to identify your organization when making requests to the Polar API.

NUXT_PRIVATE_POLAR_SERVER

This environment variable is used to specify the Polar server you want to use. Use sandbox for testing with your Sandbox or production for production.

Subscriptions & Life Time Deals

The starter kit is designed to support subscriptions (free & Pro) and life time deal.

You can configure everything in the layers/payment Nuxt layer. This layer is responsible for managing the payment process, including creating subscriptions, handling webhooks, and managing invoices.