简单归档/laravel-cashier-microdata

为您的Laravel Cashier发票添加Microdata

v2.0.0 2022-06-08 19:55 UTC

This package is auto-updated.

Last update: 2024-09-09 00:50:48 UTC


README

Software License

此包提供了一种简单的方法,将Microdata(JSON-LD格式)添加到您的Laravel Cashier发票中。

要求

PHP 7.0 及以上。

安装

您可以通过Composer安装此包。运行以下命令

composer require einfacharchiv/laravel-cashier-microdata

使用方法

将以下代码片段添加到您的发票通知 toMail 方法中,并根据您的环境调整值。 $this->invoice 是您的 \Laravel\Cashier\Invoice(或可替换为 \Stripe\Invoice)。方法 setSellersetBuyersetUrl 是可选的。

// ...

public function toMail($notifiable)
{
    \einfachArchiv\LaravelCashierMicrodata\Invoice::getInstance()
        ->setInvoice($this->invoice)
        ->setSeller([
            'company' => config('app.vendor.company'),
            'first_name' => config('app.vendor.first_name'),
            'last_name' => config('app.vendor.last_name'),
            'street_address' => config('app.vendor.street_address'),
            'city' => config('app.vendor.city'),
            'zip' => config('app.vendor.zip'),
            'state' => config('app.vendor.state'),
            'country' => config('app.vendor.country'),
            'vat_id' => config('app.vendor.vat_id'),
            'email' => config('app.vendor.email'),
            'website' => config('app.vendor.website'),
        ])
        ->setBuyer([
            'company' => $notifiable->billing_company,
            'first_name' => $notifiable->billing_first_name,
            'last_name' => $notifiable->billing_last_name,
            'street_address' => $notifiable->billing_street_address,
            'city' => $notifiable->billing_city,
            'zip' => $notifiable->billing_zip,
            'state' => $notifiable->billing_state,
            'country' => $notifiable->billing_country,
            'vat_id' => $notifiable->vat_id,
            'email' => $notifiable->email,
            'website' => $notifiable->website,
        ])
        ->setUrl(route('invoices.show', $this->invoice->id));

    // return (new MailMessage())...
}

// ...

并将以下代码片段添加到您的 resources/views/vendor/mail/html/layout.blade.php 文件的 </body> 标签之前。

    <!-- ... -->

    {!! \einfachArchiv\LaravelCashierMicrodata\Invoice::getInstance() !!}
</body>
</html>

贡献

贡献是 欢迎 的。

我们通过Github上的拉取请求接受贡献。

在使用此包时遇到困难?发现了错误?您有任何一般性问题或改进建议吗?请随时在GitHub上创建问题,我们将尽快处理。

如果您发现了一个安全问题,请通过support@einfacharchiv.com发送电子邮件,而不是使用问题跟踪器。

编码愉快!

致谢

许可

MIT 许可证(MIT)。有关更多信息,请参阅许可文件