Why does the API return multiple subscriptions per customer?
Hello,
I am doing some integration with the developer API and I am confused on one point. Why does the API return an array of subscriptions for a single customer? Other discussions on here seem to indicate that a customer has a one to one relationship with a subscription (at least currently).
Is it currently possible to get a result where a single customer record returns multiple subscriptions? If so, what API calls would I make to create such a customer?
Thanks,
Jason
Discussions are closed to public comments.
If you need help with Cheddar please
start a new discussion.
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
Support Staff 1 Posted by Marc Guyer on 19 Nov, 2011 09:55 PM
If there's more than one subscription in the response, you're seeing a history of plan changes.
>
2 Posted by George on 20 Nov, 2011 05:55 PM
I had the same question as Jason. all plans (history changes) show isActive a true. What's the best and simple way to check if a customer's subscription has expired and therefore should not be allowed to use the service?
thanks
Support Staff 3 Posted by Marc Guyer on 21 Nov, 2011 01:32 PM
I guys.
isActive
simply indicates whether or not the subscription is canceled.What do you mean by "expired"? Maybe this will help: the "current" subscription is the latest one. It just so happens to be the first one in the list returned by the API. If the current subscription
isActive
then the subscription is in good standing as far as CG is concerned.4 Posted by George on 21 Nov, 2011 05:33 PM
I created a new customer with paid subscription plan 'A', I then changed it to plan 'B'. Then I cancelled the account.
Now if I query the customer, I get BOTH subscriptions with isActive = 1
what I would like to do is find a a way to query the customer record on CG to determine if the customer should be allowed to use my site. in other words I need to determine they still have a valid subscription plan. By valid i mean, the subscription was paid and wasn't cancelled.
hope this clarifies what I'm doing.
thanks.
5 Posted by Jason MacInnes on 21 Nov, 2011 05:34 PM
Thanks for the clarification, Marc. Follow up question - what about multiple plans returned by a subscription? Is the first one on the list the current plan and the others are the ones that the customer used to subscribe to?
6 Posted by George on 22 Nov, 2011 07:17 PM
Hey Marc, any thoughts on querying the customer to find out out if they have an active/valid subscription?
thanks
Support Staff 7 Posted by Marc Guyer on 22 Nov, 2011 09:30 PM
That's exactly correct.
There are two ways to do that. One is quite rudimentary and is documented here: http://support.cheddargetter.com/kb/hosted-payment-pages/hosted-pay.... That would only be relevant if you're using hosted pages.
The other way is to simply pull the customer data from the API and check the first subscription
isActive
node. You could also check for acanceledDatetime
.8 Posted by George on 23 Nov, 2011 01:55 AM
Hi Marc, here are my results based on your feedback. btw, i'm not using hosted pages, so all of the following is done through the APIs.
-Created a customer (using the APIs)
-Queried the customer (using curl): isActive is set to 1. No value for canceledDatetime. (this is done using /customers/get/)
-Canceled the customer (using the APIs)
-Queried the customer (using curl): isActive is still set to 1. canceledDatetime has a value.
So either there is a bug causing isActive to be always 1 or I'm still missing something. I can use the canceledDatetime but this strikes me as an odd way of validating a subscription.
Does this mean i have to do this validation as described in the link you provided like this: $status = file_get_contents('https://yoursite.chargevault.com/status?key=a1b2c3d4e6&code=you...');
How is everyone else doing it using the APIs then?
thanks
9 Posted by George on 24 Nov, 2011 05:29 PM
Marc, any thoughts on how I can achieve that using the APIs rather than using the store URL?
Support Staff 10 Posted by Marc Guyer on 25 Nov, 2011 11:21 PM
I checked to verify but didn't find any customers in your account. Can you replicate this and let me take a look?
A subscription being active is somewhat subjective. As such, we do not intend for CG to be the ultimate authority on whether or not a customer has access to your system. We do provide several conveniences but you need to decide how to put it together. For example, even a subscription with a canceledDatetime might be considered active (maybe the customer paid through the end of the current period, for example).
Maybe we're confusing this with the
plans->plan->isActive
node. Could that be?Have you looked at the API wrappers? The PHP wrapper, for example, has the following method:
Marc Guyer closed this discussion on 05 Dec, 2011 05:04 PM.