Create a template to issue repeated invoices from in the future, with or without a subscription
https://gate.qorepay.com/api/v1/billing_templates
BillingTemplate generates Purchase objects, either to issue one-time invoices or in a subscription.
It does so by copying over its' PurchaseDetails, one of itsBillingTemplateClient-s and generating other fields from BillingTemplate's fields as necessary into a new Purchase object.
If is_subscription is true, it is considered to be a subscription's BillingTemplate. You will need to specify subscription_* fields like subscription_period when creating it and add BillingTemplateClient objects to its billing cycle (POST /billing_templates/{id}/add_subscriber/). After that the clients will receive recurring invoices (that will be paid for automatically if client saves their card) according to the BillingTemplate settings you have specified.
If is_subscription is false, this BillingTemplate is used to send one-time invoices. After creating it and specifying invoice_* fields, use POST /billing_templates/{id}/send_invoice/ request to send the actual invoices. BillingTemplateClients for non-subscription BillingTemplates are not saved.
HEADER PARAMS
authorizationString
required
Set value to
BEARER SECRET_KEYcontent-typeString
required
Set value to
JSON
REQUEST BODY
purchaseObject
required
Core information about the Purchase, including the products, total, currency and invoice fields. If you're using invoicing via
/billing/or/billing_templates/, this object will be copied 1:1 from BillingTemplate you specify to the resulting Purchases (also to subscription Purchases).is_subscriptionboolean
required
Defines whether this BillingTemplate issues invoices in a recurring manner - it's a subscription - or it sends invoices only once. You can't change this parameter when you edit the BillingTemplate. If this field is
true, you will need to specifysubscription_*fields andinvoice_*fields are read-only, and vice-versa.brand_idstring
string ID of the brand to create this BillingTemplate for. You can copy it down in the API section.
titlestring
invoice_issuedstring($ISO 8601 (YYYY-MM-DD))Sets
issuedon the Purchase objects generated. Generated from current day inpurchase.timezoneif not provided. Read-only ifis_subscription==true.invoice_dueinteger($Unix timestamp (seconds)))e.g :1619740800Sets due on the Purchase objects generated. Required if
is_subscription==false, read-only otherwise.invoice_send_receiptboolean
default:
falseSets
send_receipton the Purchase objects generated.trueby default (unlike in Purchases API, where by default receipts are not sent). Read-only ifis_subscription==true.subscription_periodinteger
min:
1max:256Defines how often are the subscription Purchases generated. Used together with
subscription_period_units: to issue Purchases once a month, use"...period": 1and"...period_units"=="months".Variable number of days in a month is respected; e.g. if subscription has a period of 1 month, a client had its billing cycle activated on January 30 and there are 28 days in February that year - billing scheduled for February will happen on 28th.
Both fields are required when creating a BillingTemplate with
is_subscription==true/editing a BillingTemplate withis_subscription==trueas long as there aren't any launched subscribers; they are read-only otherwise, whether it's BillingTemplate's editing when there already are clients activated or ifis_subscription==false.subscription_period_unitsstring
[ days, weeks, months ]default:
monthsSee
subscription_period.subscription_due_periodinteger
min:
1max:256default:
7Used to generate due on the Purchase objects generated. Used together with subscription_due_period_units: to set the final
Purchase.dueto a week after it's generated/invoice is sent, use"...period": 1and"...period_units"=="weeks". Required ifis_subscription==true, read-only otherwise.subscription_due_period_unitsstring
[ days, weeks, months ]default:
daysSee
subscription_due_period.subscription_charge_period_endboolean
default:
falseIf this is
true, clients are charged at the end of billing periods, and vice-versa. E.g. if you add a subscriber client to a BillingTemplate, with this value being set tofalse, he will receive first invoice today, otherwise - after a single billing period (defined bysubscription_period/subscription_period_units) passes.Required when creating a BillingTemplate with
is_subscription==true/editing a BillingTemplate withis_subscription==trueas long as there aren't any launched subscribers; read-only otherwise, whether it's BillingTemplate's editing when there already are clients activated or ifis_subscription==false.subscription_trial_periodsinteger
minimum:
0maximum:256How many trial periods to give the client prior to starting his billing cycle. If billing period is 1 month and you set this value to 2, subscription will automatically adjust to giving your client 2 months without payments and then charging him for the 3rd month (when exactly depends on
subscription_charge_period_end: 3 months after the subscriber was launched forfalse, 4 fortrue)."subscription_trial_periods": 0 disables this feature.Required when creating a BillingTemplate with
is_subscription==true/editing a BillingTemplate withis_subscription==trueas long as there aren't any launched subscribers; read-only otherwise, whether it's BillingTemplate's editing when there already are clients activated or ifis_subscription==false.subscription_activeboolean
default:
falseWhether this subscription is paused. Has the same effect as setting
"status":"subscription_paused"for every BillingTemplateClient launched for this subscription, see the description ofstatuson BillingTemplateClient for more details.ignore (read-only) if
is_subscription==false.force_recurringboolean
default:
falseIf the used payment method supports recurring payment functionality, forces the customer's payment credentials to be saved for possible later recurring payments, without giving the customer a choice in the matter.
RESPONSES
201OK
400Invalid data submitted or request processing error
Query
Body
{
"purchase": {
"currency": "str",
"products": [
{
"name": "string",
"quantity": "1",
"price": 0,
"discount": 0,
"tax_percent": "0",
"category": "string"
}
],
"language": "en",
"notes": "string",
"debt": 0,
"subtotal_override": null,
"total_tax_override": null,
"total_discount_override": null,
"total_override": null,
"request_client_details": [],
"timezone": "Europe/Oslo",
"due_strict": false
},
"number_of_billing_cycles": 0,
"brand_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"title": "string",
"is_subscription": true,
"invoice_issued": "2020-04-30",
"invoice_due": 1619740800,
"invoice_skip_capture": false,
"invoice_send_receipt": false,
"subscription_period": 1,
"subscription_period_units": "months",
"subscription_due_period": 7,
"subscription_due_period_units": "days",
"subscription_charge_period_end": false,
"subscription_trial_periods": 0,
"subscription_active": false,
"force_recurring": false,
"upsell_campaigns": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"referral_campaign_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
Sample Response
JSON
{
"type": "string",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"created_on": 1619740800,
"updated_on": 1619740800,
"purchase": {
"currency": "str",
"products": [
{
"name": "string",
"quantity": "1",
"price": 0,
"discount": 0,
"tax_percent": "0",
"category": "string"
}
],
"total": 0,
"language": "en",
"notes": "string",
"debt": 0,
"subtotal_override": null,
"total_tax_override": null,
"total_discount_override": null,
"total_override": null,
"request_client_details": [],
"timezone": "Europe/Oslo",
"due_strict": false,
"email_message": "string"
},
"company_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"number_of_billing_cycles": 0,
"is_test": true,
"user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"brand_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"title": "string",
"is_subscription": true,
"invoice_issued": "2020-04-30",
"invoice_due": 1619740800,
"invoice_skip_capture": false,
"invoice_send_receipt": false,
"subscription_period": 1,
"subscription_period_units": "months",
"subscription_due_period": 7,
"subscription_due_period_units": "days",
"subscription_charge_period_end": false,
"subscription_trial_periods": 0,
"subscription_active": false,
"subscription_has_active_clients": true,
"force_recurring": false,
}