How can I tell if a Subscription (or Tracked Item) is "paid" for (subscription still valid)

Clay Nichols's Avatar

Clay Nichols

02 Jul, 2018 03:50 AM

I've looked all through the API. I must be missing it.

USE CASE
I wantt to look up a Code (customer's ID) and see if a certain plan (or Tracked Item) is currently "paid" (i.e., still active), or expired (cancelled and beyond the last payment period).

It looks like maybe I'd use either:

  1. The hook: subscription[plan][items][][quantityIncluded]
    Or
  2. retrieve the customer info and parse through it an look for :

OR, IS IT SOMETHING ELSE?

  1. Support Staff 1 Posted by Marcela Poffald on 02 Jul, 2018 03:01 PM

    Marcela Poffald's Avatar

    Hi Clay,

    You should be able to get the information you need from the result of a customers/get call, which returns all of a customer's invoice history and subscription details. For example, have a look at this sample response.

    You can see that this customer's subscription is active, because there is no canceledDateTime (canceled customers will have a timestamp for canceledDateTime).

    As for the tracked items, all invoice details for a customer are shown in the response as well, and tracked items are shown under charges, as a charge with a type of "item". In the above example, we can see that this customer had 0 PROJECTS and 3 USERS on their last invoice:

     <invoice id="ab8fad6c-e6ab-11df-8728-40407c9117fd">
                <number>2658</number>
                <type>subscription</type>
                <vatRate/>
                <billingDatetime>2010-12-02T06:04:10+00:00</billingDatetime>
                <paidTransactionId/>
                <createdDatetime>2010-11-02T18:04:43+00:00</createdDatetime>
                <charges>
                  <charge id="" code="PAID_RECURRING">
                    <type>recurring</type>
                    <quantity>1</quantity>
                    <eachAmount>19.00</eachAmount>
                    <description/>
                    <createdDatetime>2010-12-02T06:04:10+00:00</createdDatetime>
                  </charge>
                  <charge id="" code="PROJECTS">
                    <type>item</type>
                    <quantity>0</quantity>
                    <eachAmount>4.00</eachAmount>
                    <description/>
                    <createdDatetime/>
                  </charge>
                  <charge id="" code="USERS">
                    <type>item</type>
                    <quantity>3</quantity>
                    <eachAmount>2.50</eachAmount>
                    <description/>
                    <createdDatetime/>
                  </charge>
                </charges>
    

    Hope this helps! Let me know if you have any other questions.

    Marcela

  2. 2 Posted by Clay Nichols on 02 Jul, 2018 03:52 PM

    Clay Nichols's Avatar

    If someone were Cancelled but they are within the period they paid for, then they are "still on a valid subscription", correct (*detailed use case below, FYI) ?
    The only way I see to check whether they are "canceled bu paid up for now" is :

    Check
    1. do they have a Cancelled Date?
    2. If so, was it more than a month ago?
    (So we'd have to assume everyone is a month long payment cycle. I think everyone is)

    • FYI: DETAILED USE CASE e.g., monthly subscription, prepaid each month, on the 1st.
      They cancel on the 5th.
      We check their status on the 10th and it shows "cancelled" but their subscription is still valid until the next 1st, correct?
  3. 3 Posted by Clay Nichols on 02 Jul, 2018 03:54 PM

    Clay Nichols's Avatar

    I suppose we could also look at this customer meta data to figure how how long they are paid up through, right?

    months
    1

    or is there an easier way?

  4. Support Staff 4 Posted by Marcela Poffald on 02 Jul, 2018 04:56 PM

    Marcela Poffald's Avatar

    Hi Clay,

    I think you're on the right track here:

    Check

    1. do they have a Cancelled Date?

    2. If so, was it more than a month ago?

    (So we'd have to assume everyone is a month long payment cycle. I think everyone is)

    When a customer is canceled in Cheddar, all that means to Cheddar is that we won't bill them anymore. Your application can use the data Cheddar provides to regulate access to your product in whatever way you need. You could use the data Cheddar sends in response to the customers/get call (such as canceledDateTime, cancelReason, and invoice history), your own custom metadata, and/or the subscriptionCanceled hook, and then build logic into your application that will extend their access for however long you'd like.

    Does that make sense? Let me know if you have any followup questions!

    Marcela

  5. Support Staff 5 Posted by Marcela Poffald on 11 Jul, 2018 03:22 PM

    Marcela Poffald's Avatar

    Hi Clay,

    We haven't heard from you in a while on this issue, so I'm going to go ahead and close this discussion. Feel free to reply and reopen it if you have any other questions!

    Marcela

  6. Marcela Poffald closed this discussion on 11 Jul, 2018 03:22 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac