I'm working with recurly for billing my customers. But how can I get an invoice pdf?
What I have so far is a table with the invoices. I show the state, plan, started date, ended date of the invoice. Then I also have a link like this:
/user/invoicepdf/invoicenr/1502
The link goes to my invoicepdfaction and sends the invoicenr parameter.
In my invoicepdfaction I have this:
public function invoicepdfAction() {
header('Content-Type:', 'application/pdf');
header('Content-Disposition:', 'inline;');
$request = $this->getRequest();
$invoice_number = $request->getParam('invoicenr');
try {
$pdf = Recurly_Invoice::getInvoicePdf($invoice_number, 'en-US');
var_dump($pdf);
} catch (Recurly_NotFoundError $e) {
print "Invoice not found.\n";
}
}
My var_dump shows this.
But how can I show the pdf in the browser? (Or download it directly)
This usually works for me:
$request = $this->getRequest();
$invoice_number = $request->getParam('invoicenr');
try {
header('Content-type: application/pdf');
header('Accept-Language: en-US');
header('Content-Disposition: attachment; filename="downloaded.pdf"');
$pdf = Recurly_Invoice::getInvoicePdf($invoice_number, 'en-US');
print($pdf);
} catch (Recurly_NotFoundError $e) {
print "Invoice not found.\n";
}
You can always submit a support ticket to support@recurly.com as they provide support for all their client libraries.