Skip to content

PHP Library to generate QR Code payload for PromptPay

License

Notifications You must be signed in to change notification settings

jestherthejoker/php-promptpay-qr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-promptpay-qr

Latest Version on Packagist Packagist PHP Version GitHub Tests Action Status GitHub Code Style Action Status License: MIT

PHP Library to generate QR Code payload for PromptPay, a Thai QR Code Standard for Payment Transactions, using fluent interface

inspired by dtinth/promptpay-qr and pheerathach/promptpay

adapted from kittinan/php-promptpay-qr

Installation

You can install the package via composer:

composer require keenthekeen/php-promptpay-qr

Usage

use PromptPayQR\Builder;

// Generate PromptPay Payload
Builder::staticMerchantPresentedQR('0899999999')->build();
// 00020101021129370016A000000677010111011300668999999995802TH53037646304FE29

// Generate PromptPay Payload With Amount
Builder::staticMerchantPresentedQR('089-999-9999')->setAmount(420)->build();
// 00020101021229370016A000000677010111011300668999999995802TH53037645406420.006304CF9E

// Generate PromptPay Payload With Amount (one-time use)
Builder::dynamicQR()->creditTransfer()->phoneNumber('083-888-3333')->setAmount(420)->build();

// Generate PromptPay Bill Payment (Tag 30) Payload
Builder::dynamicQR()->billPayment()
  ->setBillerIdentifier('099400015804189', 'Ref1', 'Ref2')
  ->setAmount(1999.99)->build();

// Generate QR Code SVG string
$svgString = Builder::staticMerchantPresentedQR('1-2345-67890-12-3')->toSvgString();
// Laravel example: respond with header Content-Type: image/svg+xml
return response($svgString, 200)->header('Content-Type', 'image/svg+xml')->header('Cache-Control', 'no-store');

// Generate QR Code SVG file
Builder::staticMerchantPresentedQR('1-2345-67890-12-3')->toSvgFile($path);

License

The MIT License (MIT). Please see License File for more information.

About

PHP Library to generate QR Code payload for PromptPay

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%