How to keep item counts in sync?

Paul Singh's Avatar

Paul Singh

18 May, 2010 12:33 PM

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

  1. Support Staff 1 Posted by Marc Guyer on 18 May, 2010 02:28 PM

    Marc Guyer's Avatar

    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 than add-item-quantity which can only increment the quantity.

    https://cheddargetter.com/developers#set-item-quantity

    Does that answer your question?

  2. Marc Guyer closed this discussion on 18 May, 2010 02:28 PM.

  3. Paul Singh re-opened this discussion on 19 May, 2010 09:45 PM

  4. 2 Posted by Paul Singh on 19 May, 2010 09:45 PM

    Paul Singh's Avatar

    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.)

  5. Support Staff 3 Posted by Marc Guyer on 20 May, 2010 03:32 PM

    Marc Guyer's Avatar

    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.

  6. 4 Posted by Paul Singh on 20 May, 2010 08:02 PM

    Paul Singh's Avatar

    Ah, that's exactly what I wanted to know -- thanks! :)

  7. Marc Guyer closed this discussion on 20 May, 2010 08:05 PM.

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

Recent Discussions

28 Mar, 2024 10:45 PM
24 Jan, 2024 08:33 AM
11 Jan, 2024 07:13 AM
30 Nov, 2023 02:07 AM
22 Nov, 2023 08:41 AM