6

I've properly integrated Braintree with my Rails 3.1 application, I'm just wondering what's the right way of generating PDF receipts so the users can download 'em from the application at anytime.

Braintree has the send-receipt after billing ability which is nice but It seems like they don't have receipt support in their API so, I guess I have to generate it by hand, probably checking the user transactions/subscriptions and their statuses, is that ok? is there a simpler way of doing this? any help would be appreciated, thanks!

coreyward
  • 77,547
  • 20
  • 137
  • 166
jpemberthy
  • 7,473
  • 8
  • 44
  • 52

1 Answers1

5

The way I handle it in my own applications is having a Invoice model. The invoice is the graphical representation for the payment. Users can view the invoice in html or download a version in PDF (generated using WickedPDF). You can either send them an invoice when a new payment is due or as a confirmation after you received the payment. With a little more information on your business I might be able to give you a more specific suggestion.

Maran
  • 2,751
  • 15
  • 12
  • Hey thanks for your answer, basically I have 2 membership levels each one associated with a Braintree subscription, in this specific case: "Basic" and "Premium", both are being paid monthly and they have different prices, I should generate a receipt every time their membership is successfully billed, besides that, there's a free membership, free members can buy stuff via a regular transaction too, so I'll need a receipt for this kind of situation. Thanks again!. – jpemberthy Jul 11 '11 at 15:38
  • 1
    I never worked with Braintree myself but it seems their API is kinda lacking notification-wise. It would be awesome if they could send your app a message once a subscription gets renewed, but it seems that's impossible. You could settle for saving the "billing_day_of_month" in your own database and check via the API one day after this date to check if the subscription has been paid. If it is paid for create the receipt in your app and send it to your customer. The manual transactions are easy since you can just create a receipt on an after_create callback. – Maran Jul 11 '11 at 17:58
  • 2
    Hey thanks again, I ended up implemented this by fetching all the `user.transactions` objects from Braintree, and then I do render those that have been successfully billed - cons => It does take a while since they're not being persisted. – jpemberthy Jul 11 '11 at 20:23
  • Yeah sounds like a good solution. Perhaps send a email to the Braintree team to suggest some kind of notification system. They advertise with the fact that they love developers. Let them proof it ;) – Maran Jul 12 '11 at 05:31