定制 hubipe/huqrpayment 二次开发

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

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

hubipe/huqrpayment

最新稳定版本:v1.1.1

Composer 安装命令:

composer require hubipe/huqrpayment

包简介

QR payment library for Hungary (according to the Magyar Nemzeti Bank standard version 001)

README 文档

README

Library to generate QR payment codes for Hungarian banks (standard by Hungarian national bank (MNB)). This library was copied and modified from the rikudou's EU QR Payment

See the standard

See also QR code payment generator for Czech, Slovak or European Union accounts.

Installation

Via composer: composer require hubipe/huqrpayment

Usage

In the constructor you must supply IBAN which may be a string or an instance of hubipe\HuQrPayment\Iban\IbanInterface.

Example with string:

<?php

use hubipe\HuQrPayment\QrPayment;

$payment = new QrPayment('HU42117730161111101800000000');

Example with base IBAN class:

<?php

use hubipe\HuQrPayment\QrPayment;
use hubipe\HuQrPayment\Iban\IBAN;

$payment = new QrPayment(new IBAN('HU42117730161111101800000000'));

The IbanInterface is useful in case you want to create an adapter that transforms your local format (BBAN) to IBAN.

This package already contains Adapter for Hungarian account numbers:

<?php

use hubipe\HuQrPayment\QrPayment;
use Rikudou\Iban\Iban\HungarianIbanAdapter;

$payment = new QrPayment(new HungarianIbanAdapter('11773016-11111018-00000000'));

Setting payment details

All payment details can be set via setters:

<?php

use hubipe\HuQrPayment\Enums\CharacterSet;
use hubipe\HuQrPayment\Enums\IdCode;
use hubipe\HuQrPayment\Enums\Purpose;
use hubipe\HuQrPayment\QrPayment;

$payment = new QrPayment('HU42117730161111101800000000');
$payment
    ->setIdCode(IdCode::TRANSFER_ORDER)
    ->setCharacterSet(CharacterSet::UTF_8)
    ->setBic('OTPVHUHB')
    ->setName('My company name')
    ->setAmount(53250)
    ->setCurrency('HUF')
    ->setDueDate(new DateTimeImmutable('+3 days'))
    ->setPaymentSituationIdentifier(Purpose::PURCHASE_SALE_OF_GOODS)
    ->setRemittance('Payment for goods')
    ->setShopId('SHOP1')
    ->setMerchantDeviceId('Terminal 1')
    ->setReceiptId('1234984657S')
    ->setPayeeInternalId('Payee internal identification')
    ->setLoyaltyId('GOLDEN_CUSTOMER')
    ->setNavVerificationCode('FXC4');

QR Code image

This library provides many implementations of QR code image using its sister library rikudou/qr-payment-qr-code-provider. If any supported QR code generating library is installed, the method getQrCode() will return an instance of \Rikudou\QrPaymentQrCodeProvider\QrCode which can be used to get an image containing the generated QR payment data.

<?php

use hubipe\HuQrPayment\QrPayment;
use Endroid\QrCode\QrCode;

$payment = new QrPayment(...);

$qrCode = $payment->getQrCode();

// get the raw image data and display them in the browser
header('Content-Type: image/png');
echo $qrCode->getRawString();

// use in an img html tag
echo "<img src='{$qrCode->getDataUri()}'>";

// write to a file
$qrCode->writeToFile('/tmp/some-file.png');

// get the raw object from the underlying system
$raw = $qrCode->getRawObject();
// let's assume we're using endroid/qr-code v4
assert($raw instanceof QrCode);
// do some custom transformations
$raw->setLabelFontSize(15);
// the object is still referenced by the adapter, meaning we can now render it the same way as before
echo "<img src='{$qrCode->getDataUri()}'>";

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-30