composite / invoice-wrapper
Szamlazz.hu和Billingo发票集成简易解决方案
1.1.4
2024-05-27 08:46 UTC
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^8|^9|^10
README
使用Laravel的发票魔杖释放计费魔法!🪄📜
这个神秘的包只需轻轻一挥,开发者就能创造出发票,将发票生成的枯燥任务转化为数字魔法的愉悦展示。无论你是用Billingo计费还是召唤出Szamlazz.hu的账单,这个迷人的工具包都能让数字为你起舞。不再有繁重的手工工作,只需像魔术师的帽子里兔子一样突然出现的闪亮发票!🐇💫
📦 安装
要安装此包,请在您的Laravel项目中运行以下命令
composer require composite/invoice-wrapper
使用以下命令发布配置文件
php artisan vendor:publish --provider="Composite\InvoiceWrapper\InvoiceWrapperServiceProvider"
⚙️ 配置
发布配置文件后,您应在.env文件中设置环境变量
INVOICING_PROVIDER=billingo # Billingo Configuration BILLINGO_BASE_URL=https://api.billingo.hu/v3/ BILLINGO_API_KEY=your-billingo-api-key BILLINGO_BLOCK_ID=your-billingo-block-id # Szamlazz.hu Configuration SZAMLAZZHU_API_KEY=your-szamlazzhu-api-key
请确保将your-billingo-api-key、your-billingo-block-id和your-szamlazzhu-api-key替换为您的实际API密钥和配置详细信息。
🛠 使用
要发出发票,您可以使用InvoiceWrapper外观与所需的发票负载。以下是一个示例
use Composite\InvoiceWrapper\Facades\InvoiceWrapper; use Carbon\Carbon; $invoicePayload = [ // Your invoice payload here ]; // Issue the invoice using the selected provider $invoice = InvoiceWrapper::issueInvoice($invoicePayload);
或者,如果没有外观,作为服务(当您想使用多个提供者时,这可能很有用)
use Composite\InvoiceWrapper\InvoiceWrapper; use Carbon\Carbon; $config = [ 'selected_provider' => env('INVOICING_PROVIDER'), 'providers' => [ 'billingo' => [ 'name' => 'Billingo', 'base_url' => env('BILLINGO_BASE_URL', 'https://api.billingo.hu/v3/'), 'api_key' => env('BILLINGO_API_KEY'), 'block_id' => env('BILLINGO_BLOCK_ID', 0), ], 'szamlazzhu' => [ 'name' => 'Szamlazz.hu', 'api_key' => env('SZAMLAZZHU_API_KEY'), ] ], ]; $invoicePayload = [ // Your invoice payload here ]; // Issue the invoice using the selected provider $invoiceWrapper = new InvoiceWrapper( \Composite\InvoiceWrapper\Factories\InvoiceGatewayFactory::create($config) ); $invoiceWrapper->issueInvoice($invoicePayload);
示例发票负载
$invoicePayload = [ 'partner' => [ 'id' => null, // for billingo required 'name' => 'Test Partner', 'address' => [ 'country_code' => 'HU', 'post_code' => '1111', 'city' => 'Budapest', 'address' => 'Test utca 1.', ], 'tax_type' => 'NO_TAX_NUMBER', //"HAS_TAX_NUMBER" : "NO_TAX_NUMBER", 'taxcode' => 'HU29168950', 'email' => 'btamba@composite.hu', // if email sending is true it is required 'send_email' => true, ], 'invoice' => [ // 'type' => 'invoice', // not handled yet 'fulfillment_date' => Carbon::now()->format('Y-m-d'), 'due_date' => Carbon::now()->format('Y-m-d'), 'payment_method' => 'bankcard', //'bankcard','cash','wire_transfer','cash_on_delivery','paypal','szep_card', 'language' => 'hu', // 'hu', 'en' 'currency' => 'HUF', // 'HUF', 'EUR' 'paid' => false, 'items' => [ [ 'name' => 'Test product', 'unit_price' => 1000, 'unit_price_type' => 'net', // net, gross 'quantity' => 1, 'unit' => 'db', 'vat' => '5', // '0%','5%','18%','27%','27%' ], [ 'name' => 'Test product 2', 'unit_price' => 2000, 'unit_price_type' => 'gross', // net, gross 'quantity' => 1, 'unit' => 'db', 'vat' => '27', // '0%','5%','18%','27%','27%' ], [ 'name' => 'Test product 3', 'unit_price' => 2000, 'unit_price_type' => 'net', // net, gross 'quantity' => 2, 'unit' => 'db', 'vat' => '27', // '0%','5%','18%','27%','27%' ] ], // 'conversion_rate' => 1, // Not handled yet 'comment' => 'It is a comment', ], ];
要检索发票
$invoiceId = 'invoice-id-here'; $invoice = InvoiceWrapper::getInvoice($invoiceId);
要下载发票
$invoiceId = 'invoice-id-here'; $invoice = InvoiceWrapper::downloadInvoice($invoiceId);
确保处理可能由于API错误或配置问题而抛出的任何异常。
📝✨未来增强功能的待办事项列表
以下是Invoice Wrapper未来旅程的奇妙任务清单
- 🧙️ 创建Invoice Wrapper - 完成!
- 🧞 Implementing Szamlazz.hu Service - 完成!
- 🧞 Implementing Billingo Service - "精灵已逃出瓶子!"(意指已完成)
- 📩 下载发票 - 正在等待魔法咒语!
- 🔗 获取下载链接 - 即将召唤出数字以太中的东西!
🤝 支持
有关问题、问题和贡献,请使用此存储库的GitHub问题部分。
🌟 致谢
此包是由以下组织提供的
- 🏢 Composite Solutions - 提供创新解决方案和专用支持。
- 👨💻 Bence Tamba - 代码魔法的幕后天才。
向所有贡献者和支持者致以崇高的敬意!您的反馈和贡献使这个项目每天都在变得更好。🚀🙌
感谢您成为这个旅程的一部分!🎉👏
📜 更新日志
对此项目的所有显著更改将记录在CHANGELOG.md文件中。
📜 许可证
此包是开源软件,许可协议为MIT许可。