Jobs
Jobs are an asynchronous process that can be triggered manually or scheduled.
There are the following types of job:
- a billing run. Subscriptions generates an invoice when a billing run occurs. Billing runs generate invoices for the remaining billing cycles for each subscription. The invoice dates come from your pricing options. Billing runs are independent of payment runs.
- a tax run. Invoices where
tax_requiredistruewill not have payment taken until a tax run has added the required tax to the invoice. - a payment run. The payment run identifies invoices that are outstanding and attempts to take payment for them. If the payment succeeds the the invoice is no longer outstanding. If the payment fails for any reason, then the invoice remains outstanding and is picked up by the next payment run to retry the payment.
- a subscription update. A subscription update changes the prices of many subscriptions in one request. See Subscription Update Jobs.
By scheduling billing and payment runs, you automate the process, reducing manual intervention and ensuring the jobs are run in a timely manner. See Schedules.
Characteristics of Billing, Tax & Payments Jobs
Billing and payment jobs have the following characteristics.
- Jobs are asynchronous.
- Jobs have a different status, depending on where a job is in its lifecycle.
- Jobs report any errors to help you understand the reason for any failed jobs.
- Only one billing run and payment run is allowed per store at a time. Although billing and payments are constantly generated, the jobs are queued. Subscriptions looks for any jobs that have a status of PENDING and starts the job with the earliest created date. This process is repeated until all jobs are processed.
Billing, Tax & Payments Jobs Lifecycle
A job can have the following status types:
- PENDING - Subscriptions has received the request but is currently busy processing other requests.
- STARTED - Subscriptions has started processing the job.
- SUCCESS - The job has successfully completed.
- FAILED - The job has failed.
Billing, Tax & Payment Reports
You can track your Subscriptions billing, payment and tax operations using reports. There are three types of report:
BillingRunReport- This report provides invoice summaries such as invoices ready for payment, invoices that require tax, and invoice failures.TaxRunReport- This report provides invoice summaries such as invoices to which tax was successfully or unsuccessfully added.PaymentRunReport- This report provides invoice summaries such as invoices for which payment was attempted, failed payment attempts and totals collected by a payment run.NotificationRunReport- This report provides notification summaries such as notifications sent and failed to send.SubscriptionUpdateReport- This report provides subscription update summaries such as subscriptions that were updated successfully and failed updates.
Subscription Update Jobs
A subscription update job changes the plan prices and pricing option prices of a set of subscriptions. You create a subscription update job manually with Create a job and a job_type of subscription-update. You cannot schedule a subscription update job.
You select the subscriptions to update in one of these ways:
offering_id- updates all subscriptions for the offering. You can useexcluded_subscription_idsto leave specific subscriptions out of the update.subscription_ids- updates only the subscriptions in the list.
You must provide either offering_id or subscription_ids, but not both. You cannot use excluded_subscription_ids with subscription_ids.
The price_changes object contains the new prices. You must provide at least one price change.
plan_prices- a map of plan IDs to the new plan price in each currency.pricing_option_prices- a map of pricing option IDs to the new pricing option price. Each pricing option price contains either afixed_priceor abase_price_percentage, but not both.
{
"data": {
"type": "subscription_job",
"attributes": {
"job_type": "subscription-update",
"offering_id": "11111111-2222-3333-4444-555555555555",
"excluded_subscription_ids": ["22222222-3333-4444-5555-666666666666"],
"price_changes": {
"plan_prices": {
"197a11f4-d341-4594-9574-7fbfbe6a671d": {
"USD": { "amount": 1200, "includes_tax": true }
}
},
"pricing_option_prices": {
"83f6b8e3-031c-4f2a-a1d7-b1c83cb5ac3c": { "base_price_percentage": 90 }
}
}
}
}
}
A subscription update job does not change the price of the current billing period. The job stores the new prices on each subscription as a pending_price_change. The next billing run applies the pending price change when it creates the next invoice for the subscription. The billing run then adds the previous prices to the price_update_history of the subscription. Notifications and prorations that occur before the next invoice use the pending prices.
A subscription update job has the following characteristics:
- The job skips closed subscriptions. Cancelled, paused, and suspended subscriptions receive the pending price change, because they can be resumed. The pending price change stays on the subscription until the subscription is resumed and a billing run creates its next invoice.
- The job validates the price changes against each subscription. A plan ID or pricing option ID must exist in the offering of the subscription. After the change, every pricing option in the offering must have a price in the currency of the subscription. If a subscription fails validation, the job does not update that subscription and continues with the other subscriptions. The
SubscriptionUpdateReportcounts each failure insubscription_failures. - If a subscription already has a pending price change, a new subscription update job replaces it. The pending price changes are not merged.
- Each updated subscription generates a
subscription.updatedevent.
📄️ Create a job
Create a job
📄️ List jobs
Retrieves a list of all jobs.
📄️ Get job
Get job
📄️ Delete job
Delete job