How to get next invoice date?
I'm wondering if, for recurring payments, there is an optimal way of getting the next invoice date? We're using the hashrocket's mousetrap gem for our calls, and the best way I can see to get the next invoice is through the following convoluted method.
customer = Mousetrap::Customer[...] # looks like this is calling "/customers/CUSTOMERCODE"
subscription = customer.subscription
next_invoice = subscription.invoices['invoice'].delete_if { |invoice| !invoice["paidTransactionId"].nil? }.first
So essentially, it looks like the chain is: customer -> subscription -> invoices -> invoice -> find the only invoice with the null paidTransactionId.
If there is a better way of getting the same information, I'd
love to know! Also, if this is correct, can I assume that there
will there always be an invoice with an empty
paidTransactionId
for recurring payments?
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 06 May, 2011 09:12 PM
Hi Matt!
That does seem quite convoluted... but it appears to be a valid way to get it.
Yes, there will always be one invoice with an empty paidTransactionId.
2 Posted by Matt on 06 May, 2011 09:37 PM
Great, thanks for the speedy response!!
Marc Guyer closed this discussion on 06 May, 2011 09:43 PM.