Adding monthly quota renewal.. not 30 days, monthly


#1

Imported Google Group message. Original thread at: https://groups.google.com/forum/#!topic/tyk-community-support/rzPGWo7rWXo Import Date: 2016-01-19 21:03:07 +0000.
Sender:Gopi Aravind.
Date:Thursday, 27 November 2014 16:06:08 UTC.

We have an API that customers pay for monthly / yearly; if they start on the 2nd of this month, Paypal charges them again on the 2nd of next month and their ‘quota’ is renewed. If it’s the 30th of Jan, they’re charged / renewed on the 28th/29th of Feb and so on. The seconds-based quota renewal feature of Tyk may not help in this scenario, and we’d really like to use this for the next version of our API. Any hacks you can think of to adapt Tyk to this case?

Thanks,
Gopi


#2

Imported Google Group message.
Sender:Martin Buhr.
Date:Thursday, 27 November 2014 16:31:21 UTC.

Hi Gopi,

Currently, it’s not directly supported, however, you could use the REST API to reset the quota’s on the payday for the key and manually reset the seconds countdown.

So you get a payment notification from Paypal, you call the Tyk API to get the key details, you could then modify the key to reset the quota and the quota_renews time to the seconds when you expect the next pay-day and then send the key back to Tyk.

Tyk won’t be doing the renewal logic for you (well, it will, and you will keep it in check each time a payment comes in), but it will still enforce the quota’s if they go over, which is probably more important for a commercial API.

What do you think?

Cheers,
Martin

P.S. If you’d like to see this feature in an upcoming release - or would like to take it on yourself :wink: - please raise an issue on the github page so we can track it.