composite/invoice-wrapper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

composite/invoice-wrapper

Composer 安装命令:

composer require composite/invoice-wrapper

包简介

Easy solution for Szamlazz.hu and Billingo invoicing integration

README 文档

README

Unleash the alchemy of billing with Invoice Magic Wand for Laravel! 🪄📜

This mystical package conjures up invoices with a flick of your developer's wrist, transforming the mundane task of invoice generation into a delightful display of digital wizardry. Whether you're billing with Billingo or summoning statements with Szamlazz.hu, this enchanting toolkit makes the numbers dance to your tune. No more grunt work, just sparkling invoices popping out like rabbits from a magician's hat! 🐇💫

📦 Installation

To install the package, run the following command in your Laravel project:

composer require composite/invoice-wrapper

Publish the configuration file with:

php artisan vendor:publish --provider="Composite\InvoiceWrapper\InvoiceWrapperServiceProvider"

⚙️ Configuration

After publishing the config file, you should set your environment variables in your .env file:

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
BILLINGO_WAYBILL_BLOCK_ID=your-billingo-waybill-block-id

# Szamlazz.hu Configuration
SZAMLAZZHU_API_KEY=your-szamlazzhu-api-key

Make sure to replace your-billingo-api-key, your-billingo-block-id, and your-szamlazzhu-api-key with your actual API keys and configuration details.

🛠 Usage

To issue an invoice, you can use the InvoiceWrapper facade with the desired invoice payload. Here's an example:

use Composite\InvoiceWrapper\Facades\InvoiceWrapper;
use Carbon\Carbon;

$invoicePayload = [
    // Your invoice payload here
];

// Issue the invoice using the selected provider
$invoice = InvoiceWrapper::issueInvoice($invoicePayload);

or without Facade, as a service (it can be useful, when you want to use multiple providers):

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),
            'waybill_block_id' => env('BILLINGO_WAYBILL_BLOCK_ID', 0),
        ],
        'szamlazzhu' => [
            'name' => 'Szamlazz.hu',
            'api_key' => env('SZAMLAZZHU_API_KEY'),            
            'proforma_prefix'=>env('SZAMLAZZHU_PROFORMA_PREFIX','ORDER'),
        ]
    ],
];

$invoicePayload = [
    // Your invoice payload here
];

// Issue the invoice using the selected provider
$invoiceWrapper = new InvoiceWrapper(
 \Composite\InvoiceWrapper\Factories\InvoiceGatewayFactory::create($config)
);

$invoiceWrapper->issueInvoice($invoicePayload);

Sample invoice payload:

$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',
    ],
];

To retrieve an invoice:

$invoiceId = 'invoice-id-here';
$invoice = InvoiceWrapper::getInvoice($invoiceId);

To download an invoice:

$invoiceId = 'invoice-id-here';
$invoice = InvoiceWrapper::downloadInvoice($invoiceId);

Make sure to handle any exceptions that may be thrown due to API errors or configuration issues.

📝✨To-Do List for Future Enhancements

Here's a whimsical checklist of tasks for the Invoice Wrapper's journey ahead:

  • 🧙‍️ Creating the Invoice Wrapper - Done!
  • 🧞‍ Implementing Szamlazz.hu Service - Done!
  • 🧞‍ Implementing Billingo Service - "The Genie is out of the bottle!"
  • 📩 Downloading Invoice - Awaiting the magic spell!
  • 🔗 Getting Download Links - Soon to be summoned from the digital ether!

🤝 Support

For issues, questions, and contributions, please use the GitHub issues section of this repository.

🌟 Credits

This package is proudly brought to you by:

A huge shout-out to all contributors and supporters! Your feedback and contributions make this project better every day. 🚀🙌

Thank you for being part of this journey! 🎉👏

📜 Changelog

All notable changes to this project will be documented in the CHANGELOG.md file.

📜 License

This package is open-source software licensed under the MIT license.

config/logging.php

        'szamlazzhu' => [
            'driver' => 'daily',
            'path' => storage_path('logs/szamlazzhu.log'),
            'level' => env('LOG_LEVEL', 'debug'),
            'days' => env('LOG_DAILY_DAYS', 14),
            'replace_placeholders' => true,
        ],

composite/invoice-wrapper 适用场景与选型建议

composite/invoice-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 143 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 11 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 composite/invoice-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 composite/invoice-wrapper 我们能提供哪些服务?
定制开发 / 二次开发

基于 composite/invoice-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 143
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-10