定制 kenlas/mnb-qr-code-payment-generator-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

kenlas/mnb-qr-code-payment-generator-php

Composer 安装命令:

composer require kenlas/mnb-qr-code-payment-generator-php

包简介

PHP implementation of MNB's QR code payment generation algorithm

README 文档

README

PHP implementation of MNB's (Hungarian National Bank) QR code payment generation algorithm

The complete guide can be found here: https://www.mnb.hu/letoltes/qr-kod-utmutato-20190712.pdf

Uses endroid/qr-code for QR code image generation.

Requirements

PHP 7.2

Installation

composer require kenlas/mnb-qr-code-payment-generator-php

Example usage

$iban = MnbQrCodePayment\Utils::hungarianBbanToIban('11773016-11111018');

$generator = new MnbQrCodePayment\Generator();
$data = $generator
    ->setMethod('HCT')
    ->setBic('OTPVHUHB')
    ->setName('Szabó Jenő')
    ->setIban($iban)
    ->setAmount(1000)
    ->setExpiration(new DateTime('now + 30 minutes'))
    ->setPaymentSituation('GDSV')
    ->setMessage('hello')
    ->setShopId('1234')
    ->setDeviceId('POS')
    ->setInvoiceId('MY-2020/108')
    ->setCustomerId('4682')
    ->setTransactionId('4687-8765-9624-1245-2022')
    ->setLoyaltyId('4682')
    ->setNavVerificationCode('FXC4')
    ->generate();

$image = new MnbQrCodePayment\QrCodeImage($data);

You can send the generated QR code directly to the output:

$image->display();

You can save it as an image:

$image->saveTo('my.png');

Or you can get the QR code as base64 encoded data URI:

echo $image->asDataUri();

You can also use your own QR code renderer: (see https://github.com/endroid/qr-code for more examples)

$customRenderer = new Endroid\QrCode\QrCode();
$customRenderer->setSize(400);
$customRenderer->setMargin(20);
$customRenderer->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
$customRenderer->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
$image->setRenderer($customRenderer);

MnbQrCodePayment\Generator available setters

Method name Required/optional Maximum length Description
setMethod($code) Required 3 Must be HCT for transfer orders or RTP for payment request
setVersion($version) Optional 3 For future use only, defaults to 001
setCharacterSet($charset) Optional 1 For compatibility reasons only, defaults to 1
setBic($bic) Required 11 The bank's BIC/SWIFT code
setName($name) Required 70 The payer/beneficiary name
setIban($iban) Required 28 The payer/beneficiary IBAN account number
setAmount($amount) Optional 12 The payment amount in HUF, integers only
setExpiration($date) Required - PHP Date object for the expiration date
setPaymentSituation($purposeCode) Optional 4 Purpose code for the given payment situation (see https://www.iso20022.org/catalogue-messages/additional-content-messages/external-code-sets)
setMessage($message) Optional 70 Message
setShopId($value) Optional 35 Shop ID
setDeviceId($value) Optional 35 Device ID
setInvoiceId($value) Optional 35 Invoice ID
setCustomerId($value) Optional 35 Customer ID
setTransactionId($value) Optional 35 Transaction ID
setLoyaltyId($value) Optional 35 Loyalty ID
setNavVerificationCode($value) Optional 35 NAV verification code

MnbQrCodePayment\Utils available helper methods

Method name Description
hungarianBbanToIban($bban) Convert a hungarian BBAN (16 or 24 character lengths) to IBAN format

MnbQrCodePayment\QrCodeImage available methods

Method name Description
constructor Optionally initialize with a QR code string, generated by MnbQrCodePayment\Generator
setQrString($qrString) QR code string generated by MnbQrCodePayment\Generator
setRenderer($renderer) Set a new renderer - an instance of Endroid\QrCode\QrCode. Can be useful if you want to customize QR code's settings
display() Send appropriate headers and display QR code as an image (PNG format by default)
saveTo($path) Save QR code as an image file (PNG format by default)
asDataUri() Returns the QR code as a base64 encoded data URI - useful to pass to an img src attribute

Contact

If you have any questions feel free to contact me at kenlashu@gmail.com

kenlas/mnb-qr-code-payment-generator-php 适用场景与选型建议

kenlas/mnb-qr-code-payment-generator-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 134 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 10 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「generator」 「php」 「payment」 「qrcode」 「mnb」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 kenlas/mnb-qr-code-payment-generator-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 134
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-21