Subscriptions (Create, List and Fetch Single)

Description

This route allows you to create and list subscriptions for customers.

Endpoint

  • Route: /subscriptions/

Accepted Methods

  • GET: Retrieve list of subscriptions or an active subscription of a customer.
  • POST: Create a new subscription.

Request Body/Params

GET Request

  • Method: GET
  • Description: Retrieve a list of customers or single customer.

Query Parameters

Sample Response

  • Status Code: 200 OK

  • Response Body:

      {
          "type": "success",
          "data": [
              {
                  "id": 549233,
                  "domain": "test",
                  "status": "active",
                  "start": 1693486798,
                  "quantity": 1,
                  "subscription_code": "SUB_pcwv2f4oezep21u",
                  "email_token": "crfn69kk148ncyy",
                  "amount": 20000,
                  "cron_expression": "59 12 28 * *",
                  "next_payment_date": "2023-09-28T12:59:00.000Z",
                  "open_invoice": null,
                  "createdAt": "2023-08-31T12:59:58.000Z",
                  "integration": 1045462,
                  "plan": {
                      "id": 893041,
                      "domain": "test",
                      "name": "Student Premium+ Test",
                      "plan_code": "PLN_yknqiafdpgxnney",
                      "description": null,
                      "amount": 20000,
                      "interval": "monthly",
                      "send_invoices": true,
                      "send_sms": true,
                      "currency": "NGN",
                      "integration": 1045462,
                      "createdAt": "2023-08-24T09:30:40.000Z",
                      "updatedAt": "2023-08-24T09:30:40.000Z"
                  },
                  "authorization": {
                      "authorization_code": "AUTH_oj8c0h875t",
                      "bin": "408408",
                      "last4": "4081",
                      "exp_month": "12",
                      "exp_year": "2030",
                      "channel": "card",
                      "card_type": "visa ",
                      "bank": "TEST BANK",
                      "country_code": "NG",
                      "brand": "visa",
                      "reusable": 1,
                      "signature": "SIG_XqSMcvLkTIkuBwiby5OP",
                      "account_name": null
                  },
                  "customer": {
                      "id": 135961664,
                      "first_name": "Tamunokorite",
                      "last_name": "Briggs",
                      "email": "[email protected]",
                      "customer_code": "CUS_hp6kzraf29bhysw",
                      "phone": null,
                      "metadata": null,
                      "risk_action": "default",
                      "international_format_phone": null
                  },
                  "invoice_limit": 0,
                  "split_code": null,
                  "payments_count": 1,
                  "most_recent_invoice": {
                      "subscription": 549233,
                      "integration": 1045462,
                      "domain": "test",
                      "invoice_code": "INV_6426r3iooh5taxs",
                      "customer": 135961664,
                      "transaction": 3071861414,
                      "amount": 20000,
                      "period_start": "2023-08-28T12:59:00.000Z",
                      "period_end": "2023-09-28T12:58:59.000Z",
                      "status": "success",
                      "paid": 1,
                      "retries": 1,
                      "authorization": 615253824,
                      "paid_at": "2023-08-31T13:00:32.000Z",
                      "next_notification": "2023-09-25T12:58:59.000Z",
                      "notification_flag": null,
                      "description": null,
                      "id": 8053624,
                      "created_at": "2023-08-31T13:00:28.000Z",
                      "updated_at": "2023-08-31T13:00:33.000Z"
                  }
              },
              ...
          ]
      }

    Or (for a single active subscription request)

    {
      "type": "success",
      "data": {
        "id": 549233,
        "domain": "test",
        "status": "active",
        "start": 1693486798,
        "quantity": 1,
        "subscription_code": "SUB_pcwv2f4oezep21u",
        "email_token": "crfn69kk148ncyy",
        "amount": 20000,
        "cron_expression": "59 12 28 * *",
        "next_payment_date": "2023-09-28T12:59:00.000Z",
        "open_invoice": null,
        "createdAt": "2023-08-31T12:59:58.000Z",
        "integration": 1045462,
        "plan": {
          "id": 893041,
          "domain": "test",
          "name": "Student Premium+ Test",
          "plan_code": "PLN_yknqiafdpgxnney",
          "description": null,
          "amount": 20000,
          "interval": "monthly",
          "send_invoices": true,
          "send_sms": true,
          "currency": "NGN",
          "integration": 1045462,
          "createdAt": "2023-08-24T09:30:40.000Z",
          "updatedAt": "2023-08-24T09:30:40.000Z"
        },
        "authorization": {
          "authorization_code": "AUTH_oj8c0h875t",
          "bin": "408408",
          "last4": "4081",
          "exp_month": "12",
          "exp_year": "2030",
          "channel": "card",
          "card_type": "visa ",
          "bank": "TEST BANK",
          "country_code": "NG",
          "brand": "visa",
          "reusable": 1,
          "signature": "SIG_XqSMcvLkTIkuBwiby5OP",
          "account_name": null
        },
        "customer": {
          "id": 135961664,
          "first_name": "Tamunokorite",
          "last_name": "Briggs",
          "email": "[email protected]",
          "customer_code": "CUS_hp6kzraf29bhysw",
          "phone": null,
          "metadata": null,
          "risk_action": "default",
          "international_format_phone": null
        },
        "invoice_limit": 0,
        "split_code": null,
        "payments_count": 1,
        "most_recent_invoice": {
          "subscription": 549233,
          "integration": 1045462,
          "domain": "test",
          "invoice_code": "INV_6426r3iooh5taxs",
          "customer": 135961664,
          "transaction": 3071861414,
          "amount": 20000,
          "period_start": "2023-08-28T12:59:00.000Z",
          "period_end": "2023-09-28T12:58:59.000Z",
          "status": "success",
          "paid": 1,
          "retries": 1,
          "authorization": 615253824,
          "paid_at": "2023-08-31T13:00:32.000Z",
          "next_notification": "2023-09-25T12:58:59.000Z",
          "notification_flag": null,
          "description": null,
          "id": 8053624,
          "created_at": "2023-08-31T13:00:28.000Z",
          "updated_at": "2023-08-31T13:00:33.000Z"
        }
      }
    }

POST Request (Create a new subscription)

  • Method: POST

  • Description: Create a new customer.

  • Request Body:

    {
      "email": "[email protected]",
      "plan": "PLN_igbo9c1eqgxxnt1",
      "amount": "10000"
    }

Sample Response

  • Status Code: 201 CREATED
  • Response Body:
{
  "type": "success",
  "data": {
    "transactions": [],
    "subscriptions": [],
    "authorizations": [],
    "email": "[email protected]",
    "integration": 1045462,
    "domain": "test",
    "customer_code": "CUS_2kwvb3rbaazd22k",
    "risk_action": "default",
    "id": 137750345,
    "createdAt": "2023-09-06T15:24:51.573Z",
    "updatedAt": "2023-09-06T15:24:51.573Z",
    "identified": false,
    "identifications": null
  }
}