How to keep item counts in sync?
Hey guys,
I'm using CG on a product that depends on the notion of including a certain number of items per month and then charging an overage fee for anything above your included number of items.
Is there a "best practice" method for keeping the number of items used/available in sync between my app and CG? Right now, I'm just making a ton of API calls whenever my user wants to do something but I wonder if there's a better way...
Paul
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 18 May, 2010 02:28 PM
Each different item code requires a separate call but if you're updating the same item for the same subscription, you can use
customers/set-item-quantity
to set the current level rather thanadd-item-quantity
which can only increment the quantity.https://cheddargetter.com/developers#set-item-quantity
Does that answer your question?
Marc Guyer closed this discussion on 18 May, 2010 02:28 PM.
Paul Singh re-opened this discussion on 19 May, 2010 09:45 PM
2 Posted by Paul Singh on 19 May, 2010 09:45 PM
Yeah, that works. Though, that wasn't really what I was asking. :)
Is it better to keep a full copy of the latest CG data and sync it every X seconds to my app (to give my users a better experience)? Or is it better to only synchronize my data with CG when the user logs in, etc?
(ie, I want to show the customer the last four digits of their CC, last invoice, next invoice date, etc.)
Support Staff 3 Posted by Marc Guyer on 20 May, 2010 03:32 PM
I suppose that depends on the nature of your app and when you want to show the information. Most of the stuff we've done only polls the CG API on the 'my account' page. In the case where the information is displayed all over the place, it's cached in the session and only updated if the customer changes their subscription or item quantity changes.
4 Posted by Paul Singh on 20 May, 2010 08:02 PM
Ah, that's exactly what I wanted to know -- thanks! :)
Marc Guyer closed this discussion on 20 May, 2010 08:05 PM.