Billing Users

Gigs Billing is a flexible billing engine that you can use to bill your users. When billing is enabled, subscriptions are managed through invoices. These invoices contain the final price to charge, including any taxes and fees, and can be collected using your own payment integration. You have full control over how you handle the collection process.

When to use Billing

We designed Gigs Billing to allow you to:

  • Use our billing engine to manage your own payments
  • Stay compliant with U.S. tax regulations
  • Use Gigs Connect with your preferred payment provider

How Billing works

When a subscription is created or renewed, an invoice is generated for the user. For new subscriptions, the invoice must be paid to activate the subscription, while for renewals, payment ensures continued service. You can subscribe to the invoice.finalized event to trigger payment processing with your payment provider and notify us upon completion.

Quotes

Quotes represent the amount a user will likely pay for a subscription period, including any taxes and fees.

Invoices

Invoices represent the amount a user must pay for a subscription period, including any taxes and fees. They are automatically generated for billed subscriptions and can have one of the following statuses:

StatusDescriptionPossible Actions
draftThe invoice is still being generated.No action required.
finalizedThe invoice is awaiting payment.Change its status to paid.
paidThe invoice payment was collected.No further action.
voidedThe invoice was canceled.No further action.

Credit Notes

Credit Notes represent adjustments to a paid invoice. They are commonly used to represent refunds, allowing you to reduce your taxes owed, and reflect them on invoice PDFs. While credit notes can cover the full amount of an invoice, certain taxes and fees may remain non-refundable and still need to be remitted to tax authorities.

StatusDescriptionPossible Actions
issuedThe credit note was created.Change its status to voided.
voidedThe credit note was canceled.No further action.

Creating billed subscriptions

Billing is configured at the time your project is created. Once enabled, creating a new subscription will automatically generate an invoice. The subscription will remain in the initiated status until the invoice is paid.

Creating a subscription

curl --request POST \
  --url "https://api.gigs.com/projects/${GIGS_PROJECT}/subscriptions" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer ${GIGS_TOKEN}" \
  --header "Content-Type: application/json" \
  --data '{
    "plan": "pln_0SNlurA049MEWV3V0q7gjQbM4EVo",
    "sim": "auto",
    "user": "usr_0SNlurA049MEWV4OpCwsNyC9Kn2d"
  }'

Subscriptions don't contain references to their invoices, but you can easily find them by listing invoices filtered by subscription. To find the first invoice for a subscription, you can also filter by reason using the value subscriptionCreation.

Finding the first invoice for a subscription

curl --request GET \
  --url "https://api.gigs.com/projects/${GIGS_PROJECT}/invoices?subscription=sub_0SNlurA049MEWV2gSfSxi00xlPIi&reason=subscriptionCreation" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer ${GIGS_TOKEN}"

Previewing taxes and fees

Before creating a subscription, you can create a Quote to preview the total cost of a plan or add-on, including taxes and fees. This way you don't have to create a subscription to see the final price on the invoice.

Depending on plan configuration in your project, you may be required to provide user's address to calculate the taxes. Consult the address field in requirements property of the plan resource.

Creating a Quote for a plan

curl --request POST \
  --url "https://api.gigs.com/projects/${GIGS_PROJECT}/quotes" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer ${GIGS_TOKEN}" \
  --header "Content-Type: application/json" \
  --data '{
    "plan": "pln_0SNlurA049MEWV3V0q7gjQbM4EVo",
    "user": "usr_0SNlurA049MEWV4OpCwsNyC9Kn2d",
    "address": "adr_0SuxrVXR1PC5fj4Hrzy5TJp8BBlr"
  }'

Collecting payments for invoices

The collection of payments for invoices is fully under your control. This is an asynchronous process that depends on the way you are handling them. Generally, for new subscriptions it's common to collect the initial payment when the subscription is created, while for renewals you would likely do it in response to our invoice.finalized event.

After confirming that the payment was successful, you need to mark the invoice as paid in Gigs. This action will trigger the activation process for new subscriptions or prevent the subscription from being ended on the next renewal.

Marking an invoice as paid

curl --request POST \
  --url "https://api.gigs.com/projects/${GIGS_PROJECT}/invoices/inv_0SNlurA049MEWV1QTRqvd18YuG25/pay" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer ${GIGS_TOKEN}"

When your integration does not require payment confirmation, you can configure invoices at the project level to automatically transition to paid when they are finalized. If the amount due on an invoice is zero (for example, because of a full discount or a free plan), the invoice automatically transitions to paid as well.

Failing to collect funds

When an invoice is finalized, it is your responsibility to ensure that the payment is collected and the invoice is marked as paid. The consequences of not marking it as paid depend on the type of the invoice:

  • For new subscriptions, not marking the first invoice as paid results in the subscription remaining in the initiated status indefinitely, or until it is explicitly ended.

  • For subscription renewals, not marking the renewal invoice as paid will eventually prevent the subscription to renew according the behavior defined by your invoice overdue settings. See the next section Invoicing users in advance to know more about the moment the invoice gets created and the section Invoice overdue settings to know more about the moment the invoice becomes overdue.

Invoicing users in advance

By default, invoices for subscription renewals are created after the subscription renews. This approach may result in unrecoverable costs for the renewal period if funds cannot be collected. To mitigate this risk, you can configure invoices to be created several days before the renewal date. When these invoices remain unpaid at the renewal time, the subscriptions will not renew and will be ended instead, protecting you from potential losses.

Invoice overdue settings

When a renewal invoice is created, your overdue settings determine what happens if the invoice isn't paid. These settings control when an invoice is considered overdue and what action to take when that happens.

You can configure these two settings at both Project and Subscription levels:

  1. Invoice Overdue Days: Specifies how many days after renewal an unpaid invoice can remain before being considered overdue. Setting this to 0 means the invoice becomes overdue immediately at renewal, while a higher value (e.g., 3) provides a grace period.

  2. Invoice Overdue Action: Determines what happens when an invoice becomes overdue:

    • none: The subscription remains active until the next renewal period.
    • end: The subscription ends immediately when the invoice becomes overdue.

These settings are configurable at the project level to apply to all subscriptions. For specific subscriptions requiring different behavior, you can override these settings when creating the subscription.

By default, projects are configured with invoice overdue days as 0 and invoice overdue action as end, which means that unpaid invoices become overdue immediately at renewal and subscriptions are ended when that happens.

If no action is taken to mark an overdue invoice as paid, subscriptions will be ended according to these settings, or at the very latest by the next renewal period.

Choosing the right invoicing window

When combining advance invoicing and invoice overdue settings, you can create flexible billing scenarios. For example:

  • Creating invoices 3 days before renewal with no grace period
  • Creating invoices at renewal with a 3-day grace period
  • Creating invoices 5 days before renewal with a 2-day grace period
  • Creating invoices at renewal with no grace period but without ending the subscription

To decide how many days in advance to create invoices, how long the grace period should be and which action to take when an invoice overdues, consider the following factors:

  • Estimate the average time it takes to collect funds from your users, ensuring that you have ample time to process payments.
  • Account for any potential delays, such as unexpected downtime or issues in processing the invoice.finalized webhook events.
  • Consider how much time your users typically need to resolve payment issues, balancing generous grace periods against the risk of unpaid service usage.
  • Assess how subscription termination impacts your user experience, weighing immediate ending against maintaining service until the next renewal period.

Crediting existing invoices

You can adjust the amount of a paid invoice by creating a Credit Note. At present, only full-amount credits are supported. To create a credit note, simply specify the invoice you want to credit. Once issued, the credit note will automatically adjust your tax calculations to reflect the reduced revenue.

Creating a credit note

curl --request POST \
  --url "https://api.gigs.com/projects/${GIGS_PROJECT}/creditNotes" \
  --header "Accept: application/json" \
  --header "Authorization: Bearer ${GIGS_TOKEN}" \
  --header "Content-Type: application/json" \
  --data '{
    "invoice": "inv_0SNlurA049MEWV1QTRqvd18YuG25"
  }'