Calculating next billing date from web hook
Hi,
Am I right in thinking I can calculate the next billing date by using subscription[invoice][createdDatetime] as the last billing date?
Thanks for your assistance in advance,
Rob McCann
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 Oct, 2012 02:31 PM
Hi Rob -- The invoice bill date is
subscription['invoice']['billingDatetime']
. If you want to know the next one, you can calculate it as long as it's a 'subscription' type invoice. Here's a PHP example:Rob McCann closed this discussion on 19 Oct, 2012 10:35 PM.
Rob McCann re-opened this discussion on 19 Oct, 2012 10:35 PM
2 Posted by Rob McCann on 19 Oct, 2012 10:35 PM
Thans for your help, exactly what I'm after :)
Rob McCann closed this discussion on 19 Oct, 2012 10:35 PM.
Rob McCann re-opened this discussion on 30 Oct, 2012 11:52 PM
3 Posted by Rob McCann on 30 Oct, 2012 11:52 PM
Hi Marc,
I'm having some trouble with this so I'll explain what I'm trying to do, what I'm actually doing and what is happening:
I'm trying to let a user set the day in the month that they're being billed on. There's no API method to just set the day so I'm calculating the next billing date if they want to be billed on that day. It needs to handle bi-monthly subscriptions too.
Here's the api calls I'm making:
1. User subscribes on 28th Oct.
2. User updates billing date via API to 29th Nov.
3. User updates billing date via API to 30th Nov.
The problem lies in how I calculate the date in (3).
After (2) a new invoice is created in the system (although unpaid). I can't then use subscription[0]['invoice']['billingDatetime'] to calculate the last billing date because it now reflects 29th Nov.
Am I making sense?
Support Staff 4 Posted by Marc Guyer on 31 Oct, 2012 01:05 PM
I don't think this is accurate. There's never more than one pending/current invoice.
Can you link me an example customer? It will help to know exactly what plan, etc, that we're talking about. It will also help if you describe the result you want to achieve and the hook type and data of the hook you're using.
5 Posted by Rob McCann on 31 Oct, 2012 01:29 PM
Hi Marc,
Thanks for your help in solving this, we'll get there eventually! It's much
appreciated :)
Here's the customer ID
e1183f74-20fd-11e2-9d18-40403c39f8d9
How do I calculate the next invoice date if there is a pending invoice? Is
there a way I can tell the difference between a pending and a paid invoice?
Rob
Support Staff 6 Posted by Marc Guyer on 31 Oct, 2012 01:52 PM
There is always a pending invoice. The
billingDatetime
of the pending invoice is the next invoice date.The pending invoice is always the first one in the list of the
customers/get
API response. A pending invoice is one that has abillingDatetime
in the future (or doesn't have abillingDatetime
).A paid invoice has a
paidTransactionId
. An "outstanding" invoice is one that has abillingDatetime
in the past and doesn't have apaidTransactionId
.Marc Guyer closed this discussion on 27 Nov, 2012 12:50 PM.