PHP code example of catidegla / pi-spi-qr

1. Go to this page and download the library: Download catidegla/pi-spi-qr library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

catidegla / pi-spi-qr example snippets


use Catidegla\PiSpiQr\QrCode;

// A printed QR at the counter. The payer types the amount.
echo QrCode::static('341c3e1b-4312-49ec-b75e-4c8c74c10fd7', 'SN')
    ->merchantName('Chez Fatou')
    ->merchantCity('Dakar')
    ->toPayload();

// One sale at the till. The transaction id is 

use Catidegla\PiSpiQr\Payload;

$payload = Payload::parse($scanned);

$payload->alias();          // 341c3e1b-4312-49ec-b75e-4c8c74c10fd7
$payload->amount();         // 1500, or null when the payer enters it
$payload->transactionId();  // TILL-1-000842
$payload->country();        // CI

foreach ($payload->problems() as $problem) {
    echo $problem, PHP_EOL;
}

// config/pi-spi.php
'alias'   => env('PI_SPI_ALIAS'),
'country' => env('PI_SPI_COUNTRY'),
'merchant' => [
    'name' => env('PI_SPI_MERCHANT_NAME'),
    'city' => env('PI_SPI_MERCHANT_CITY'),
],

use Catidegla\PiSpiQr\Laravel\Facades\PiSpi;

PiSpi::dynamic(1500, 'TILL-1-000842')->toPayload();
PiSpi::static()->toPayload();

use Catidegla\PiSpiQr\Laravel\Rules\PiSpiPayload;

$request->validate([
    'qr' => ['

checksum does not match: the payload carries 0000, its contents give 9618
bash
php artisan vendor:publish --tag=pi-spi-config
bash
php artisan pi-spi:qr 00020126520014int.bceao.pi0136341c3e1b...