##### 安裝
`https://github.com/piggly-dev/php-pix`
#### 操作類
`<?php
namespace app\common\library;
use Piggly\Pix\Exceptions\QRCodeNotSupported;
use Piggly\Pix\Parser;
use Piggly\Pix\StaticPayload;
use think\Exception;
/**
* Class PixPayCode
* @package app\common\library
*/
class PixPayCode
{
/*
*
* $payload = (new \app\common\library\PixPayCode())
->setAmount($amount)
//->setTid($tid)
//->setDescription($description)
//->setPixKey($keyValue)
//->setMerchantName($merchantName)
//->setMerchantCity($merchantCity)
->getPixQrCodeValue();
*/
/**
* @var string
*/
private $pixKey='c51bf4e8-16bc-4e-9016-abeb0fc48d91';
/**
* @var string
*/
private $description;
/**
* @var string
*/
private $merchantName='ZH - ELRONICOS LA';
/**
* @var string
*/
private $merchantCity='?o ulo';
/**
* @var string
*/
private $txid;
/**
* @var
*/
private $amount;
/**
* @var StaticPayload
*/
private $payload;
/**
* PixPayCode constructor.
*/
public function __construct()
{
$this->payload = new StaticPayload();
$this->txid = Parser::getRandom();
$this->description = '';
}
/**
* @param string $pixKey
* @return $this
*/
public function setPixKey(string $pixKey)
{
$this->pixKey = $pixKey;
return $this;
}
/**
* @param float $amount
* @return $this
*/
public function setAmount(float $amount)
{
$this->amount = (string)number_format($amount, 2, '.', '');
return $this;
}
/**
* @param string $description
* @return $this
*/
public function setDescription(string $description)
{
$this->description = $description;
return $this;
}
/**
* @param string $merchantName
* @return $this
*/
public function setMerchantName(string $merchantName)
{
$this->merchantName = $merchantName;
return $this;
}
/**
* @param string $merchantCity
* @return $this
*/
public function setMerchantCity(string $merchantCity)
{
$this->merchantCity = $merchantCity;
return $this;
}
/**
* @param string $txid
* @return $this
*/
public function setTid(string $txid)
{
$this->txid = $txid;
return $this;
}
/**
* @return array
* @throws Exception
*/
public function getPixQrCodeValue()
{
$payload = $this->payload
->setAmount($this->amount)
->setTid($this->txid)
->setDescription($this->description)
->setPixKey(Parser::KEY_TYPE_RANDOM, $this->pixKey)
->setMerchantName($this->merchantName)
->setMerchantCity($this->merchantCity);
try {
return ['image' => $payload->getQRCode(), 'pix' => $payload->getPixCode()];
} catch (QRCodeNotSupported $e) {
throw new Exception($e->getMessage());
}
}
}
`
- 空白目錄
- thinkphp5
- tools-常用類庫
- redis類庫
- Excel類庫
- File文件操作類庫
- Http請求類庫
- Maile郵件發送
- Hooks行為鉤子
- 七牛云
- 隨機數和字符串生成
- 字符串處理
- 時間類處理
- tree型轉換
- 工具類庫
- 文件打包下載
- 常用功能
- 文件上傳
- php生成word文檔
- elasticsearch 基本搜索
- 使用jwt開發API接口
- 安裝模及搭建
- ApiCheck.php
- ApiCheckLogin.php
- common.php
- Login.php
- Comment.php
- 漢字轉拼音
- 安裝使用
- Pinyin類
- elasticsearch操作
- 常用方法
- 數據源生成layui-select
- 獲取自定義配置項
- 百度編輯器
- 格式化文件大小
- 多語言設置
- hook監聽
- 域名綁定到模塊
- thinkphp6
- 文件上傳
- tp5totp6
- 創建路徑
- 獲取類所有方法
- password_hash加密驗證
- 生成 qrcode
- 郵件發送
- 獲取QQ信息
- GoogleAuthenticator
- redis限流
- redis 加鎖
- 百度翻譯
- QueryList爬取數據
- 獲取時間類
- 命令
- Git常用命令
- easyswoole
- pix_qrcode
- 驗證 cpf,cnpj
- php常用方法
- 日志
- 卡通頭像
- 兩位小數
- 圖片轉base64
- auth加密解密
- phpoffice/phpspreadsheet導入導出
- fastadmin
- 樹結構
- 單選框
- 復選框
- 二級搜索
- select選擇框
- selectpage選中回調事件
- 標簽添加
- 修改where條件
- 表格列表中添加input框
- selectpage事件
- fieldlist
- js操作
- test_js
- 多表格
- template模板