Subscription Plans

With the next request, you can get all info about the subscription plans:

method: GET
URL: /user_groups.json

PARAMETERS:
{
  “media_page”: “NUMBER” # Pagination, starting on 1 (if 0 or null, no pagination) 
}
RETURN:
{
  "page": "user_groups",
  "user_groups": [
    {
      “SUBSCRIPTION PLAN INFO"
    }
  ],
  "pagination": {
    "current": “NUMBER”, # Current page
    "last": true/false # If last page, true
  }
}

Using the subscription plan ID, you can get more detailed information:

method: GET
URL: /user_groups/ID.json # ID Format NUMBER-TEXT

PARAMETERS:
RETURN:
{
  "page": "user_group",
  “user_group”:
    {
      "id": "ID",
      "name": "NAME",
      "description": "DESCRIPTION",
      "html_description": "HTML ADDITIONAL DESCRIPTION",
      "promote": true/false, # Promote on Home Page
      "demote": true/false, # Do not show on Home
      "plans": {
        ["monthly"|"quarterly"|"triannually"|"semiannual"|"annual"|"biennial"|"perpetual"]: {
          "price": "PRICE”
          "installments": [ # If "installment" = true
            {
              "number": NUMBER,
              "price": "PRICE"
            }
          ]
        }
      },
      "recurrent": true/false,
      "installment": true/false,
      "max_installments": NUMBER,
      "coupon": true/false,
      "coupon_required": true/false,
      "payment_methods": ["card", "boleto","coupon"],
      "subscribed": true/false, # If current user has subscription for this plan
      "trial": true/false,
      "trial_days": NUMBER,
      "trial_user": true/false
    },
  "channels": [
    {
      “CHANNEL INFO” # Return info of all channels associated with this plan
    }
    "pagination": {
      "current": “NUMBER”, # Current page
      "last": true/false # If last page, true
    }
  ]
}

After get all info about the plans, you can subscribe an user with a specific TOKEN:

method: POST
URL: /user_groups/ID/subscribe.json # ID Format NUMBER-TEXT

PARAMETERS:
{
  “payment_method”: [“card”|”boleto”|”coupon”] 
  “card_token”: [“TOKEN”|"default"] # If “payment_method” = “card”
  “installments”: NUMBER # If “payment_method” = “card”
  "payer": { # If “payment_method” = “boleto”
    "name": "NAME",
    "cpf_cnpj": "CPF/CNPJ",
    "address": {
      "street": "STREET",
      "number": "NUMBER",
      "complement": "COMPLEMENT"
      "zip_code": "ZIP CODE"
      "city": "CITY"
      "state": "STATE"
      "country": "COUNTRY"
    }
  },
  “coupon”: "CODE", 
  “reload”: true, # To reload price using coupon
  “duration”: “DURATION”
}
RETURN:
{
  "status": true/false, # status_code 200/400
  "user_group": {
    "USER GROUP INFO"
  }, # If "reload" = true
  "coupon": {
    "id": "ID",
    "code": "CODE",
    "description": "DESCRIPTION",
  }, # If "reload" = true
  "errors": { # If "status" = false
    "user_group": {
      "FIELD": [ 
        "ERROR MESSAGE"
      ]
    }
  }
}

You can also subscribe using only the unique coupon code:

method: POST
URL: /code_redeems.json

PARAMETERS:
{
  “coupon”: {
    "code": "CODE"
  }
}
RETURN:
{
  "status": true/false, # status_code 200/400
  "user_group_id": "ID" # If logged in (coupon will only be validated if not logged in)
  "errors": { # If "status" = false
    "coupon": {
      "FIELD": [ 
        "ERROR MESSAGE"
      ]
    }
  }
}

Following, we show how to get a specific content thumbnail:

URL: /user_groups/[ID]/retrieve?format=thumb
ID: format NUMBER-TEXT

<< Previous topic Next topic >>