How to get next invoice date?

Matt's Avatar

Matt

06 May, 2011 09:01 PM

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. Support Staff 1 Posted by Marc Guyer on 06 May, 2011 09:12 PM

    Marc Guyer's Avatar

    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. 2 Posted by Matt on 06 May, 2011 09:37 PM

    Matt's Avatar

    Great, thanks for the speedy response!!

  3. Marc Guyer closed this discussion on 06 May, 2011 09:43 PM.

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

Recent Discussions

28 Mar, 2024 10:45 PM
24 Jan, 2024 08:33 AM
11 Jan, 2024 07:13 AM
30 Nov, 2023 02:07 AM
22 Nov, 2023 08:41 AM