lee-ratinan / emv-qr
这是一个PHP类,用于读取和生成EMV QR码,这是通过移动支付平台进行支付时使用的QR码。
V0.9.1
2021-10-25 10:25 UTC
This package is auto-updated.
Last update: 2024-09-10 10:03:41 UTC
README
此仓库用于读取和生成各国EMV QR码,目前支持以下国家:
- 新加坡
- 泰国
可能扩展:印度尼西亚、马来西亚、香港、印度。
EMVCo QR码规范 - 商户展示QR码
EMVCo QR码规范定义为字符串块:[ID, 长度, 值]。ID和长度由两个数字组成,范围从'00'到'99',值是ID标识的项目值。例如,'000201'是ID '00'(有效负载格式指示符)的字符串块,其值的长度为'02'(2个字符长),因此值为'01',这是长度后面的两个字符。下表描述了ID、长度及其描述。
备注
- 格式
- N = 数字
- ANS = 数字和特殊字符字符串(ASCII 32-126)
- S = 任何Unicode字符的字符串
- 存在
- M = 必需的
- O = 可选的
- C = 条件的
表1:QR码根下的数据对象
ID 02-51是为商户账户信息保留的,其中ID 26-51可供私人使用。每个账户的长度最多为99。
表2:商户账户信息分配(ID 26-51)
表3:附加数据字段模板的数据对象(ID 62)
表4:其他语言中的商户信息数据对象(ID 64)(此库不支持)
表5:每个商户账户的数据对象
- 全局唯一标识符可以是应用标识符(AID)、无连字符的分隔符UUID或反向域名。
如何使用
1 EmvMerchant
1.1 类公共属性
表6:类公共属性
2 EmvMerchantDecoder
2.1 描述
接收从QR码中读取的字符串并将其结构化为表6中所示的对象格式。
2.2 如何使用
- 使用参数
$string
(这是从QR码中读取的字符串,可选)创建类EmvMerchantDecoder
的一个对象。 - 如果在前一步中没有将
$string
传递给构造函数,请调用decode($string)
函数来传递参数。 - 类
EmvMerchantDecoder
的公共属性将填充从QR码中读取的数据。如果$string
输入有问题,将填充数组errors
和/或warnings
。
2.3 示例
$string = '00020101021126490009SG.PAYNOW010120210202012345X0301104082021123151820007SG.SGQR0113202012345X123020701.000103068286710402010503123060400000708201912315204000053037025802SG5911RATINAN LEE6009SINGAPORE610682876162140110987654321X630429FD'; $emv = new \EMVQR\EmvMerchantDecoder($string); $json = json_encode($emv, JSON_PRETTY_PRINT);
结果
{ "mode": "DECODE", "qr_string": "00020101021126490009SG.PAYNOW010120210202012345X0301104082021123151820007SG.SGQR0113202012345X123020701.000103068286710402010503123060400000708201912315204000053037025802SG5911RATINAN LEE6009SINGAPORE610682876162140110987654321X630429FD", "payload_format_indicator": "01", "point_of_initiation": "STATIC", "accounts": { "SG.PAYNOW": { "original_id": 26, "reverse_domain": "SG.PAYNOW", "proxy_type": "UEN", "proxy_value": "202012345X", "amount_editable": true }, "SG.SGQR": { "original_id": 51, "reverse_domain": "SG.SGQR", "sgqr_id_number": "202012345X123", "version": "01.0001", "postal_code": "828671", "level": "01", "unit_number": "123", "miscellaneous": "0000", "new_version_date": "20191231" } }, "merchant_category_code": { "code": "0000", "value": "Generic" }, "transaction_currency": "SGD", "transaction_amount": null, "tip_or_convenience_fee_indicator": null, "convenience_fee_fixed": null, "convenience_fee_percentage": null, "country_code": "SG", "merchant_name": "RATINAN LEE", "merchant_city": "SINGAPORE", "merchant_postal_code": "828761", "additional_fields": { "bill_number": "987654321X" }, "crc": "29FD", "errors": [], "warnings": [] }
3 EmvMerchantGenerator
3.1 描述
建设中。
3.2 函数和参数
建设中。
3.3 返回值
建设中。
3.4 示例
建设中。
4 账户模板
4.1 新加坡
PayNow
{ "SG.PAYNOW": { "original_id": 26, "reverse_domain": "SG.PAYNOW", "proxy_type": "UEN", "proxy_value": "202012345X", "amount_editable": true, "expiry_date": "2099-12-31" } }
FavePay
{ "FavePay": { "original_id": 27, "channel": "FavePay", "reverse_domain": "COM.MYFAVE", "url": "https://myfave.com/qr/xxxxxx" } }
SGQR
{ "SG.SGQR": { "original_id": 51, "reverse_domain": "SG.SGQR", "sgqr_id_number": "202012345X123", "version": "01.0001", "postal_code": "828671", "level": "01", "unit_number": "123", "miscellaneous": "0000", "new_version_date": "20191231" } }
4.2 泰国
PromptPay
{ "TH.PROMPTPAY": { "original_id": 29, "channel_name": "TH.PROMPTPAY", "guid": "A000000677010111", "proxy_type": "MOBILE", "proxy_value": "0066899999999", "mobile_number": "+66899999999" } }
4.3 印度尼西亚
QRIS
{ "ID.CO.QRIS.WWW": { "original_id": 51, "reverse_domain": "ID.CO.QRIS.WWW", "nmid": "ID1234567890123", "03": "UMI" } }
4.4 马来西亚
马来西亚的QR码,DuitNow尚未实现。
4.5 香港
香港的QR码尚未实现。