Subscriptions

Return a Subscription.

Parameters
  • idpath integerRequired

    Return a Subscription by specific id.

GETGET /api/v1/subscriptions/{id}

{
  const res = await fetch(`${BASE_URL}GET /api/v1/subscriptions/${id}`, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)});

  const data = await res.json();
}

RESPONSE


Request Object

The required Request Object used for CRUD. The only difference is with Update you need to provide a Subscriptions id.

REQUEST OBJECT

{
  "data": {
    "type": "subscriptions",
    "attributes": {
      "stripe_token": ""
    },
    "relationships": {
      "business": {
        "id": "62a05bd2-2f0e-4bac-8f8b-63947f4df16f",
        "type": "business"
      },
      "stripe_plan": {
        "id": "62a05bd2-2f0e-4bac-8f8b-63947f4df16f",
        "type": "stripe_plan"
      }
    }
  }
}

Create Subscription

Create a subscription.

Parameters
  • dataformData, objectRequired

    Form Data needed when creating a new Subscription.

    • typestringRequired

      Provide Subscription type. Current selection is only subscriptions.

    • attributesformData, objectRequired

      Attributes object.

      • stripe_tokenstringRequired

        Stripe token.

    • relationshipsformData, objectRequired

      Relationships object with business object.

      • businessformData, objectRequired

        Add a Business relationships link.

        • idstringRequired

          Related Business id.

        • typestringRequired

          Business type; business.

      • stripe_planformData, objectRequired

        Add a Stripe Plan relationships link.

        • idstringRequired

          Related Stripe Plan id.

        • typestringRequired

          Stripe Plan type; stripe_plan.

POST/api/v1/subscriptions

{
  const res = await fetch(`${BASE_URL}/api/v1/subscriptions`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)});

  const data = await res.json();
}

RESPONSE


Change Plan

Change plan of a subscription.

Parameters
  • idpath integerRequired

    Update a Subscription by specific id.

  • dataformData, objectRequired

    Form Data needed when changing plan of a subscription.

    • idstringRequired

      Provide Subscription id.

    • typestringRequired

      Provide Subscription type. Current selection is only subscriptions.

    • attributesformData, object

      Attributes object.

      • stripe_plan_idstring

        Stripe Plan slug or UUID.

PATCH/api/v1/subscriptions/{id}/change_plan

{
  const res = await fetch(`${BASE_URL}/api/v1/subscriptions/${id}/change_plan`, {
    method: 'PATCH',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)});

  const data = await res.json();
}

RESPONSE


Change Card

Change card assigned to subscription.

Parameters
  • idpath integerRequired

    Update a Subscription by specific id.

  • dataformData, objectRequired

    Form Data needed when changing plan of a subscription.

    • idstringRequired

      Provide Subscription id.

    • typestringRequired

      Provide Subscription type. Current selection is only subscriptions.

    • attributesformData, object

      Attributes object.

      • stripe_tokenstring

        Stripe Setup Intent ID.

PATCH/api/v1/subscriptions/{id}/change_card

{
  const res = await fetch(`${BASE_URL}/api/v1/subscriptions/${id}/change_card`, {
    method: 'PATCH',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)});

  const data = await res.json();
}

RESPONSE


Cancel

Cancel a Subscription.

Parameters
  • idpath integerRequired

    Cancel a Subscription by specific id.

PATCH/api/v1/subscriptions/{id}/cancel

{
  const res = await fetch(`${BASE_URL}/api/v1/subscriptions/${id}/cancel`, {
    method: 'PATCH',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)});

  const data = await res.json();
}

RESPONSE