QorePay logo
QorePay logo

Create a template to issue repeated invoices from in the future, with or without a subscription

POST

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

  • authorization

    String

    required

    Set value to BEARER SECRET_KEY

  • content-type

    String

    required

    Set value to JSON

REQUEST BODY

  • purchase

    Object

    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_subscription

    boolean

    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 specify subscription_* fields and invoice_* fields are read-only, and vice-versa.

  • brand_id

    string

    string ID of the brand to create this BillingTemplate for. You can copy it down in the API section.

  • title

    string

  • invoice_issued

    string($ISO 8601 (YYYY-MM-DD))

    Sets issued on the Purchase objects generated. Generated from current day in purchase.timezone if not provided. Read-only if is_subscription == true.

  • invoice_due

    integer($Unix timestamp (seconds)))

    e.g :1619740800

    Sets due on the Purchase objects generated. Required ifis_subscription == false, read-only otherwise.

  • invoice_send_receipt

    boolean

    default: false

    Sets send_receipt on the Purchase objects generated. true by default (unlike in Purchases API, where by default receipts are not sent). Read-only if is_subscription == true.

  • subscription_period

    integer

    min: 1 max: 256

    Defines how often are the subscription Purchases generated. Used together with subscription_period_units: to issue Purchases once a month, use "...period" : 1 and"...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 == true as 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 if is_subscription == false.

  • subscription_period_units

    string

    [ days, weeks, months ]

    default: months

    See subscription_period.

  • subscription_due_period

    integer

    min: 1 max: 256

    default: 7

    Used to generate due on the Purchase objects generated. Used together with subscription_due_period_units: to set the final Purchase.due to a week after it's generated/invoice is sent, use "...period" : 1 and"...period_units" == "weeks". Required if is_subscription == true, read-only otherwise.

  • subscription_due_period_units

    string

    [ days, weeks, months ]

    default: days

    See subscription_due_period.

  • subscription_charge_period_end

    boolean

    default: false

    If 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 to false , he will receive first invoice today, otherwise - after a single billing period (defined bysubscription_period / subscription_period_units) passes.

    Required when creating a BillingTemplate withis_subscription == true/editing a BillingTemplate withis_subscription == true as long as there aren't any launched subscribers; read-only otherwise, whether it's BillingTemplate's editing when there already are clients activated or if is_subscription == false.

  • subscription_trial_periods

    integer

    minimum: 0maximum: 256

    How 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 onsubscription_charge_period_end: 3 months after the subscriber was launched for false, 4 for true)."subscription_trial_periods": 0 disables this feature.

    Required when creating a BillingTemplate withis_subscription == true/editing a BillingTemplate withis_subscription == true as long as there aren't any launched subscribers; read-only otherwise, whether it's BillingTemplate's editing when there already are clients activated or if is_subscription == false.

  • subscription_active

    boolean

    default: false

    Whether this subscription is paused. Has the same effect as setting "status": "subscription_paused" for every BillingTemplateClient launched for this subscription, see the description of status on BillingTemplateClient for more details.

    ignore (read-only) if is_subscription == false.

  • force_recurring

    boolean

    default: false

    If 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

  • 201

    OK

  • 400

    Invalid 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, 
}