Send an invoice to one or several clients
https://gate.qorepay.com/api/v1/billing/
Use this endpoint to send a one time invoice(-s). Provide all data of a BillingTemplate (see Schemas below) and, additionally, an array of one or more BillingTemplateClients in clients . Purchases will be created and invoices sent, one for every Client you have specified.
A BillingTemplate won't be created; if you need to be able to issue repeated, similar invoices, see POST /billing_templates/ and POST /billing_templates/{id}/send_invoice/ .
Note that unlike for other requests where you can send BillingTemplate data (like POST /billing_templates/ ), title andis_subscription are read-only for POST /billing/.
HEADER PARAMS
authorizationString
required
Set value to
BEARER SECRET_KEYcontent-typeString
required
Set value to
JSON
REQUEST BODY
clientsObject
required
Contains details about the clients you're sending this invoice to.
CLIENT OBJECT
client_idstring
required
ID of the Client object to add to the BillingTemplate. Read-only after the BillingTemplateClient has been created. Note that the same Client can be added to a BillingTemplate several times.
descriptionstring
Connects a Client object to a BillingTemplate having
is_subscription=trueto store information about a single subscriber. You will be able to pause an individual subscription client's cycle by PATCH-ing its'statusfield to the value ofsubscription_paused.invoice_referencestring
When present overrides reference for invoices generated for this client
statusenum
[pending, inactive, active, subscription_paused]default =
inactiveFor subscriptions, you can edit (
PATCH/billing_templates/{id}/clients/{id}/) this status betweenactiveandsubscription_pausedvalues to pause the client's subscription. Paused subscriptions run as normal, except for purchases not being created and invoices sent for them. It means that if you pause a BillingTemplateClient's monthly subscription cycle a day before the billing date, the next day the invoice will not be issued; but, if you unpause the client a day after the planned billing would have taken place, the planned billing in a month (minus one day) will happen as usual.payment_method_whiteliststring
An optional whitelist of payment methods availble for purchases generated for this BillingTemplateClient. Copied 1:1 to
Purchase.payment_method_whitelistfield on created Purchases (see its description).Payment method name as returned by
GET/payment_methods/.send_invoice_on_charge_failureboolean
default:
trueSends invoice when subscription charge fails if this is
truesend_invoice_on_add_subscriberboolean
default:
falseSends invoice when
POST/billing_templates/{id}/add_subscriber/is called if this is truesend_receiptboolean
default:
trueSends receipt when subscription charge succeeds if this is
truepurchaseObject
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
number_of_billing_cyclesinteger
Limits number of billing cycles for each client if set to a non-zero value
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
200OK
400Invalid data submitted or request processing error
Query
Body
{
"clients": [
{
"client_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"invoice_reference": "string",
"status": "inactive",
"payment_method_whitelist": [
"string"
],
"send_invoice_on_charge_failure": true,
"send_invoice_on_add_subscriber": false,
"send_receipt": true
}
],
"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,
}
Sample Response
JSON
[
"720e2c96-ef94-4baa-90b6-d61ef6fd675a"
]