POST https://gate.reviopay.com/api/v1/billing_templates/{id}/add_subscriber/Description
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: , 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: , purchase: }: you should redirect your client to purchase.checkout_url for him to pay immediately (as you do with POST /purchases/).
Request body
| Field | Type | Required | Description |
|---|---|---|---|
status | string | no | 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. One of: pending, inactive, active, subscription_paused |
client_id | string (uuid) | yes | 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. |
send_receipt | boolean | no | Sends receipt when subscription charge succeeds if this is true |
invoice_reference | string | no | When present overrides reference for invoices generated for this client |
payment_method_whitelist | string[] | no | 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 | no | Sends invoice when POST /billing_templates/{id}/add_subscriber/ is called if this is true |
send_invoice_on_charge_failure | boolean | no | Sends invoice when subscription charge fails if this is true |
number_of_billing_cycles_passed | integer | no | Only used together with number_of_billing_cycles on BillingTemplate. Shows number of billing cycles passed when number of cycles is limited |
subscription_billing_scheduled_on | object | no | If not null, reports the date when the next billing is scheduled for this client. |
id | string (uuid) | no | |
type | string | no | Object type identifier |
created_on | object | no | Object creation time |
updated_on | object | no | Object last modification time |
Example
curl -X POST https://gate.reviopay.com/api/v1/billing_templates/{id}/add_subscriber/ \
-H 'Authorization: Bearer <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"client_id": "b79d3df6-2f69-4426-acee-eda049d83e18"
}'Responses
| Status | Description |
|---|---|
200 | OK |
400 | Invalid data submitted or request processing error |