smhg/sepa-qr-data
Composer 安装命令:
composer require smhg/sepa-qr-data
包简介
Generate QR code data for SEPA payments
README 文档
README
Generates SEPA payment data for use in a QR code as defined in the European Payments Council's standard.
A QR code using this data can, for instance, be displayed on an invoice and be scanned by a mobile banking app.
Migrating from smhg/sepa-qr? Follow the steps below.
Installation
composer require smhg/sepa-qr-data
Usage
use SepaQr\SepaQrData;
$paymentData = (new SepaQrData()) ->setName('Name of the beneficiary') ->setIban('BE123456789123456789') ->setAmount(100); // The amount in Euro
After this, you can choose your preferred QR code library and use this data as the input. Below are 2 examples.
With endroid/qr-code
Installation
composer require endroid/qr-code
Usage
use Endroid\QrCode\Builder\Builder; use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelMedium;
Builder::create() ->data($paymentData) ->errorCorrectionLevel(new ErrorCorrectionLevelMedium()) // required by EPC standard ->build() ->saveToFile('payment.png');
Note: endroid/qr-code lists more ways to render.
With chillerlan/php-qrcode
Installation
composer require chillerlan/php-qrcode
Usage
use chillerlan\QRCode\QRCode; use chillerlan\QRCode\QROptions;
$qrOptions = new QROptions([ 'eccLevel' => QRCode::ECC_M // required by EPC standard ]); (new QRCode($qrOptions))->render($paymentData, 'payment.png');
Note: chillerlan/php-qrcode lists more ways to render.
API
setName($name)
Required. Set the name of the beneficiary.
setIban($iban)
Required. Set the account number of the beneficiary. Only IBAN is allowed.
setAmount($amount)
Set the amount of the credit transfer. Currently (?) only amounts in Euro are allowed.
setBic($bic)
Set the BIC of the beneficiary bank.
setRemittanceReference($remittanceReference)
Set the remittance information (structured). Creditor reference (ISO 11649) RF creditor reference may be used.
setRemittanceText($remittanceText)
Set the remittance information (unstructured).
setPurpose($purpose)
Set the purpose of the credit transfer.
setInformation($information)
Set the beneficiary to originator information.
setServiceTag($serviceTag = 'BCD')
Set the service tag. Currently (?) only one value is allowed: BCD.
setVersion($version = 2)
Set the SEPA QR standard version. In version 1 a BIC is mandatory. In version 2 a BIC is only mandatory outside EEA countries.
setCharacterSet($characterSet = SepaQrData::UTF_8)
Set the character set. Available constants are UTF_8, ISO8859_5, ISO8859_1, ISO8859_7, ISO8859_2, ISO8859_10, ISO8859_4 or ISO8859_15. Remember to also use/set this character set in the surrounding parts of your application (including endroid/qr-code).
setIdentification($identification = 'SCT')
Set the identification code. Currently (?) only one value is allowed: SCT.
Migration from smhg/sepa-qr
This project is a continuation of smhg/sepa-qr, decoupling QR code rendering. Different QR rendering libraries offer different features and support different PHP versions. This project now generates the appropriate QR code data, which can be supplied to the QR code rendering library of your choice.
Follow these steps to migrate:
1. Remove smhg/sepa-qr
composer remove smhg/sepa-qr
2. Install smhg/sepa-qr-data and endroid/qr-code
composer require smhg/sepa-qr-data endroid/qr-code
3. Replace/add use declarations
-use \SepaQr\SepaQr; +use \SepaQr\SepaQrData; +use \Endroid\QrCode\Builder\Builder; +use \Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelMedium;
4. Adapt QR code generation accordingly
$paymentData = new SepaQrData(); // $paymentData->set... Builder::create() ->errorCorrectionLevel(new ErrorCorrectionLevelMedium()) ->data($paymentData) ->build() ->saveToFile('payment.png');
smhg/sepa-qr-data 适用场景与选型建议
smhg/sepa-qr-data 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 843.45k 次下载、GitHub Stars 达 61, 最近一次更新时间为 2021 年 04 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 smhg/sepa-qr-data 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smhg/sepa-qr-data 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 843.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 61
- 点击次数: 26
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-16