laravel / cashier-mollie

MIT License
375 stars 63 forks source link

downloadInvoice is not defined #110

Closed Reached closed 4 years ago

Reached commented 4 years ago

Hi there,

Great job on this package!

I am trying to download invoices for my users, however I keep getting undefined method downloadInvoice. Anything obvious I am missing here?

Function to call the invoice download:

Route::get('user/invoice/{invoice}/download', function (Request $request, $invoiceId) {
        return $request->user()->downloadInvoice($invoiceId, [
            'vendor' => config('app.name'),
            'product' => 'Audome',
        ]);
    });

This is my user model where I include the trait:

<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Cashier\Billable;
use Laravel\Cashier\Order\Contracts\ProvidesInvoiceInformation;
use Mpociot\VatCalculator\VatCalculator;

class User extends Authenticatable implements ProvidesInvoiceInformation
{
    use Notifiable, Billable;

    /**
     * Get the receiver information for the invoice.
     * Typically includes the name and some sort of (E-mail/physical) address.
     *
     * @return array An array of strings
     */
    public function getInvoiceInformation()
    {
        return [$this->name, $this->email];
    }

    /**
     * Get additional information to be displayed on the invoice. Typically a note provided by the customer.
     *
     * @return string|null
     */
    public function getExtraBillingInformation()
    {
        return $this->vat;
    }

}

    ...
sandervanhooft commented 4 years ago

Hi @Reached,

Thanks for the ❤️ !

Cashier Mollie is not a 1:1 port of Cashier Stripe. The downloadInvoice method for example is not available in this package.

You could access the same functionality using:

$order->invoice()->download();

Feel free to submit a PR to add the downloadInvoice method on the billable trait. I'm closing this issue for now, let me know if it should be reopened.

Reached commented 4 years ago

Thanks for getting back to me @sandervanhooft ! I might make a PR for that, and thanks again for making this package :)

sandervanhooft commented 4 years ago

No problem, enjoy!

sandervanhooft commented 4 years ago

Running into the same issue with Spark Mollie now, so preparing a patch for this.

sandervanhooft commented 4 years ago

https://github.com/laravel/cashier-mollie/commit/f1b2d86ae865140abce2c2b130c451bf0018e2d4

Will be included in next release (later this week probably)

Reached commented 4 years ago

Amazing, well done once again @sandervanhooft :)