POST
/
billing_templates
/
{id}
/
add_subscriber
/
curl --request POST \
  --url https://gate.chip-in.asia/api/v1/billing_templates/{id}/add_subscriber/ \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "client_id": "b79d3df6-2f69-4426-acee-eda049d83e18"
}'
{
  "billing_template_client": {
    "created_on": 1619740800,
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "type": "<string>",
    "updated_on": 1619740800,
    "client_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "payment_method_whitelist": [
      "<string>"
    ],
    "send_invoice_on_add_subscriber": true,
    "send_invoice_on_charge_failure": true,
    "send_receipt": true,
    "status": "pending",
    "subscription_billing_scheduled_on": "2020-04-30"
  },
  "purchase": {
    "created_on": 1619740800,
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "type": "<string>",
    "updated_on": 1619740800,
    "billing_template_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "brand_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "cancel_redirect": "<string>",
    "checkout_url": "<string>",
    "client": {
      "bank_account": "<string>",
      "bank_code": "<string>",
      "bcc": [
        "jsmith@example.com"
      ],
      "brand_name": "<string>",
      "cc": [
        "jsmith@example.com"
      ],
      "city": "<string>",
      "country": "<string>",
      "email": "jsmith@example.com",
      "full_name": "<string>",
      "legal_name": "<string>",
      "personal_code": "<string>",
      "phone": "+44 45643564564",
      "registration_number": "<string>",
      "shipping_city": "<string>",
      "shipping_country": "<string>",
      "shipping_state": "<string>",
      "shipping_street_address": "<string>",
      "shipping_zip_code": "<string>",
      "state": "<string>",
      "street_address": "<string>",
      "tax_number": "<string>",
      "zip_code": "<string>"
    },
    "client_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "company_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "created_from_ip": "<string>",
    "creator_agent": "<string>",
    "currency_conversion": {
      "exchange_rate": 123,
      "original_amount": 123,
      "original_currency": "<string>"
    },
    "direct_post_url": "<string>",
    "due": 1619740800,
    "failure_redirect": "<string>",
    "force_recurring": true,
    "invoice_url": "<string>",
    "is_recurring_token": true,
    "is_test": true,
    "issued": "2020-04-30",
    "issuer_details": {
      "bank_accounts": [
        {
          "bank_account": "<string>",
          "bank_code": "<string>"
        }
      ],
      "brand_name": "<string>",
      "legal_city": "<string>",
      "legal_country": "<string>",
      "legal_name": "<string>",
      "legal_street_address": "<string>",
      "legal_zip_code": "<string>",
      "registration_number": "<string>",
      "tax_number": "<string>",
      "website": "<string>"
    },
    "marked_as_paid": true,
    "order_id": "<string>",
    "payment": {
      "amount": 123,
      "currency": "<string>",
      "description": "<string>",
      "fee_amount": 123,
      "is_outgoing": true,
      "net_amount": 123,
      "paid_on": 1619740800,
      "payment_type": "purchase",
      "pending_amount": 123,
      "pending_unfreeze_on": 1619740800,
      "remote_paid_on": 1619740800
    },
    "payment_method_whitelist": [
      "<string>"
    ],
    "platform": "web",
    "product": "purchases",
    "purchase": {
      "currency": "<string>",
      "debt": 123,
      "due_strict": true,
      "email_message": "<string>",
      "language": "<string>",
      "notes": "<string>",
      "products": [
        {
          "category": "<string>",
          "discount": 123,
          "name": "<string>",
          "price": 123,
          "quantity": "<string>",
          "tax_percent": "<string>"
        }
      ],
      "request_client_details": [
        "email"
      ],
      "subtotal_override": 123,
      "timezone": "Europe/Oslo",
      "total": 123,
      "total_discount_override": 123,
      "total_override": 123,
      "total_tax_override": 123
    },
    "recurring_token": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "reference": "<string>",
    "reference_generated": "<string>",
    "refund_availability": "all",
    "refundable_amount": 123,
    "send_receipt": true,
    "skip_capture": true,
    "status": "created",
    "status_history": [
      {
        "related_object": {
          "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "type": "<string>"
        },
        "status": "created",
        "timestamp": 1619740800
      }
    ],
    "success_callback": "<string>",
    "success_redirect": "<string>",
    "transaction_data": {
      "attempts": [
        {
          "client_ip": "<string>",
          "country": "<string>",
          "error": {
            "code": "<string>",
            "message": "<string>"
          },
          "extra": {},
          "payment_method": "<string>",
          "processing_time": 1619740800,
          "successful": true,
          "type": "execute"
        }
      ],
      "country": "<string>",
      "extra": {},
      "payment_method": "<string>"
    },
    "user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "viewed_on": 1619740800
  }
}

Use this request with a BillingTemplate having is_subscription == true. Two scenarios are possible:

• If subscription_charge_period_end == true and/or subscription_trial_periods > 0 (first billing should happen after 1 or more billing periods, not today), the request will create a BillingTemplateClient and start trial/schedule billing for it (as required by subscription settings). Successful response will be of form {billing_template_client: <BillingTemplateClient object created>, purchase: null}: no Purchase is created, BillingTemplateClient.status is active immediately.

• If subscription_charge_period_end == false and subscription_trial_periods == 0 (first billing should occur today), the request will create a BillingTemplateClient with status == pending and create a Purchase. When such a Purchase is paid, the respective BillingTemplateClient will have its’ subscription activated (starting from the day of payment), with its status changing to active. Successful response will be of form {billing_template_client: <BillingTemplateClient object created>, purchase: <Purchase object created>}: you should redirect your client to purchase.checkout_url for him to pay immediately (as you do with POST /purchases/).

Authorizations

Authorization
string
headerrequired

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required

Object ID (UUID)

Body

application/json
client_id
string
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.

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).

send_invoice_on_add_subscriber
boolean
default: false

Sends invoice when POST /billing_templates/{id}/add_subscriber/ is called if this is true

send_invoice_on_charge_failure
boolean
default: true

Sends invoice when subscription charge fails if this is true

send_receipt
boolean
default: true

Sends receipt when subscription charge succeeds if this is true

status
enum<string>
default: inactive

For subscriptions, you can edit (PATCH /billing_templates/{id}/clients/{id}/) this status between active and subscription_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.

Read-only if the BillingTemplateClient is in inactive (internal status not managed through public API) or pending (see documentation for POST /billing_templates/{id}/add_subscriber/) statuses.

Available options:
pending,
inactive,
active,
subscription_paused

Response

200 - application/json
billing_template_client
object

Connects a Client object to a BillingTemplate having is_subscription = true to store information about a single subscriber.

You will be able to pause an individual subscription client's cycle by PATCH-ing its' status field to the value of subscription_paused.

purchase
object

Nullable in POST /billing_templates/{id}/add_subscriber/ response.