Cashier-stripe: Invoice download can change file name

Created on 25 Jul 2019  路  3Comments  路  Source: laravel/cashier-stripe

Could you please allow to change file name (.pdf) in download invoice or can I custom the name of the download file, Now it's like fixed file name .
https://github.com/laravel/cashier/blob/9.0/src/Invoice.php#L269

many thanks.

enhancement

Most helpful comment

I've sent in a PR for this here: https://github.com/laravel/cashier/pull/723

All 3 comments

@4UForever download method returns Response object, so you can just change a header:

use Illuminate\Http\Request;

Route::get('user/invoice/{invoice}', function (Request $request, $invoiceId) {
    $response = $request->user()->downloadInvoice($invoiceId, [
        'vendor'  => 'Your Company',
        'product' => 'Your Product',
    ]);

    $filename = 'custom.pdf';

    $response->headers->set('Content-Disposition', 'attachment; filename="'.$filename.'"');

    return $response;
});

@Sti3bas many thanks for your advise and your sample code is so helpful for me. :)

I've sent in a PR for this here: https://github.com/laravel/cashier/pull/723

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MarGul picture MarGul  路  5Comments

VirtualDesignFactory picture VirtualDesignFactory  路  4Comments

adrianoGaspar picture adrianoGaspar  路  5Comments

tania-pets picture tania-pets  路  3Comments

mcteo picture mcteo  路  3Comments