Send an invoice, generating a purchase from billing template data
https://gate.qorepay.com/api/v1/billing_templates/{id}/send_invoice
Use this request with a BillingTemplate having is_subscription
==
false
. Specify the BillingTemplateClient data (only client_id
field is needed) in the request body. The request will issue a Purchase by combining data of BillingTemplate.purchase
and BillingTemplateClient.client
and will send an invoice to your Client. Response will contain data of a created Purchase. The BillingTemplateClient will not be saved.
HEADER PARAMS
authorization
String
required
Set value to
BEARER SECRET_KEY
content-type
String
required
Set value to
JSON
PATH PARAMS
id
string
required
ID associated with the billing template.
REQUEST BODY
client_id
string(ID)
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.
invoice_reference
string
maxLength:
128
When present overrides reference for invoices generated for this client
status
string
[pending, inactive, active, subscription_paused]
default:
inactive
For subscriptions, you can edit (
PATCH
/billing_templates/{id}/clients/{id}/
) this status betweenactive
andsubscription_paused
values 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_whitelist
string
An optional whitelist of payment methods availble for purchases generated for this BillingTemplateClient. Copied 1:1 to
Purchase.payment_method_whitelist
field on created Purchases (see its description).Payment method name as returned by
GET
/payment_methods/
.send_invoice_on_charge_failure
boolean
Sends invoice when subscription charge fails if this is
true
send_invoice_on_add_subscriber
boolean
Sends invoice when
POST
/billing_templates/{id}/add_subscriber/
is called if this istrue
send_receipt
boolean
Sends receipt when subscription charge succeeds if this is
true
RESPONSES
200
OK
400
Invalid data submitted or request processing error
Query
Body
const options = {
method: 'POST',
headers: {
accept: 'application/json'
},
body: {
"client_id": "b79d3df6-2f69-4426-acee-eda049d83e18"
}
};
fetch('https://gate.qorepay.com/api/v1/billing_templates/{id}/send_invoice', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
Sample Response
JSON
{
"type": "string",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"created_on": 1619740800,
"updated_on": 1619740800,
"client": {
"bank_account": "string",
"bank_code": "string",
"email": "[email protected]",
"phone": "+44 45643564564",
"full_name": "string",
"personal_code": "string",
"street_address": "string",
"country": "st",
"city": "string",
"zip_code": "string",
"state": "string",
"shipping_street_address": "string",
"shipping_country": "st",
"shipping_city": "string",
"shipping_zip_code": "string",
"shipping_state": "string",
"cc": [
"[email protected]"
],
"bcc": [
"[email protected]"
],
"legal_name": "string",
"brand_name": "string",
"registration_number": "string",
"tax_number": "string"
},
"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"
},
"payment": {
"is_outgoing": false,
"payment_type": "purchase",
"amount": 0,
"currency": "str",
"net_amount": 0,
"fee_amount": 0,
"pending_amount": 0,
"pending_unfreeze_on": 1619740800,
"description": "string",
"paid_on": 1619740800,
"remote_paid_on": 1619740800
},
"issuer_details": {
"website": "string",
"legal_street_address": "string",
"legal_country": "st",
"legal_city": "string",
"legal_zip_code": "string",
"bank_accounts": [
{
"bank_account": "string",
"bank_code": "string"
}
],
"legal_name": "string",
"brand_name": "string",
"registration_number": "string",
"tax_number": "string"
},
"transaction_data": {
"payment_method": "string",
"extra": {},
"country": "string",
"attempts": [
{
"type": "execute",
"successful": true,
"payment_method": "string",
"extra": {},
"country": "string",
"client_ip": "string",
"processing_time": 1619740800,
"error": {
"code": "string",
"message": "string"
}
}
]
},
"status": "created",
"status_history": [
{
"status": "created",
"timestamp": 1619740800,
"related_object": {
"type": "string",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
}
],
"viewed_on": 1619740800,
"company_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"is_test": true,
"user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"brand_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"billing_template_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"client_id": null,
"send_receipt": false,
"is_recurring_token": true,
"recurring_token": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"skip_capture": false,
"force_recurring": false,
"reference_generated": "string",
"reference": "string",
"issued": "2020-04-30",
"due": 1619740800,
"refund_availability": "all",
"refundable_amount": 0,
"currency_conversion": {
"original_currency": "string",
"original_amount": 0,
"exchange_rate": 0
},
"payment_method_whitelist": [
"string"
],
"success_redirect": "string",
"failure_redirect": "string",
"cancel_redirect": "string",
"success_callback": "string",
"creator_agent": "string",
"platform": "web",
"product": "purchases",
"created_from_ip": "string",
"invoice_url": "string",
"checkout_url": "string",
"direct_post_url": "string",
"marked_as_paid": true,
"order_id": "string",
"upsell_campaigns": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"referral_campaign_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"referral_code": "string",
"referral_code_generated": "string",
"referral_code_details": {
"campaign_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"reward_type": "gift",
"discount_amount": 0,
"discount_percent": 0
},
"retain_level_details": {
"campaign_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"discount_amount": 0,
"discount_percent": 0
}
}