Configuring One Off Payments
How to configure one-off payments in Makerkit for products that are not recurring in nature.
While not exactly a common SaaS billing mode, Makerkit offers support for one-off payments.
You can use the tables orders
and orders_items
to store single orders for products not recurring in nature. You can use this in two ways:
- Lifetime Access: for products that are not recurring but offer lifetime access.
- Multiple one-off payments: for products that are not recurring but can be purchased multiple times. For example, you have multiple add-ons that can be purchased separately.
Some of this will require custom code, but generally speaking, Makerkit does its best to support this use case in a broad sense. The specifics of your implementation will depend on your product and business model and may require additional customization.
Schema Definition
One-off payments are defined by the following fields:
export default createBillingSchema({ provider, products: [ { id: 'starter', name: 'Starter', description: 'The perfect plan to get started', currency: 'USD', badge: `Value`, plans: [ { name: 'Starter Monthly', id: 'starter-monthly', paymentType: 'one-time', lineItems: [ { id: 'price_1NNwYHI1i3VnbZTqI2UzaHIe', name: 'Addon 2', cost: 9.99, type: 'flat', }, ], } ], } ]});
Let's break down the fields:
- name: The name of the plan
- id: The unique identifier for the line item. This must match the price ID in the billing provider. The schema will validate this, but please remember to set it correctly.
- paymentType: The payment type (e.g.,
recurring
,one-time
). In this case, it'sone-time
. - lineItems: The line items for the plan
- id: The unique identifier for the line item. This must match the price ID in the billing provider. The schema will validate this, but please remember to set it correctly.
- name: The name of the line item
- cost: The cost of the line item
- type: The type of the line item (e.g.,
flat
). It can only beflat
for one-off payments.
When a products gets purchased, Makerkit will create an order in the orders
table and an order item in the orders_items
table. You can use this data to fulfill the order and grant access to the product.
If you would like to switch from subscriptions
to orders
as your primary billing mechanism, you can do so by setting the following environment variable:
BILLING_MODE=one-time
When this flags in set to one-time
, Makerkit's plan's page will be looking for a valid order in the orders
table instead of a subscription in the subscriptions
table. This means that the billing section will display one-off payments instead of subscriptions.
As mentioned - this is a best-effort implementation. You may need to customize the billing pages to fit your specific use case.