Pro rata billing
I have attempted to create an API call that mixes in a future-dated initialBillDate so that the customer will get billed on the first of every month for his subscription, but also added a charge in the same call to bill him right now for the days remaining of the current month (i.e. pro rata). It seems that the initialBillDate was set correctly but the charge i included was not.
Is this expected behaviour and if so, how can I work around this limitation? The initialBillDate MUST be the first of every month for all our customers, but we don't want to force people to have to wait until the start of a new month before they can use their services.
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
1 Posted by Gareth on 23 Mar, 2011 11:27 AM
Just a quick correction, the charge was added to be billed on the first of the month along with the plan subscription when we want the charge to be done immediately instead and only the plan subscription on the 1st.
2 Posted by Gareth on 23 Mar, 2011 12:12 PM
Ok, so if anyone else is looking for an answer to this (before confirmation comes from support staff), I have found a way to do this in a kind of backward way. If support can just confirm this is the best way:
Create the customer as usual but calculate the number of days already passed in the current month, and using the monthly charge of the plan, calculate the daily charge for the current month.
Now, what you want to do is actually refund the customer for the days of the month already passed. You can use the CG charge parameter for this in your data array:
Submit the API call to CG to create customer and they get billed immediately for the recurring fee, minus the credit for the days already passed.
Create a new data array and send an API call to edit a customer subscription with only one parameter:
Send this API call and now the next invoice date is reset to the 1st of next month.
Support Staff 3 Posted by Marc Guyer on 23 Mar, 2011 02:35 PM
That's exactly correct!
However, I think your logic is a bit off in (5) since the next month number could be 1 (January) which would make the year wrong (January of last year). Maybe something like this (untested):
$firstBillDate = date('Y-m-d', mktime(0,0,0,date('n')+1,1));
mktime() should handle for month number 13 appropriately.
4 Posted by Gareth on 24 Mar, 2011 09:58 AM
Sure, nice catch, but personally I would use strtotime as it is a little bit clearer:
$firstBillDate = date('Y-m-d', strtotime(date('Y-m-d') . " +1 month"));
;)
Support Staff 5 Posted by Marc Guyer on 24 Mar, 2011 07:09 PM
Yeah, but don't you want it on the first of the month?
Dean closed this discussion on 16 Jan, 2013 04:22 PM.