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?

#1 Posted by Marc Guyer Support staff 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.