PHP code example of leandroandreaci / iso8583

1. Go to this page and download the library: Download leandroandreaci/iso8583 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/ */

    

leandroandreaci / iso8583 example snippets





namespace Andromeda\ISO8583;

use Andromeda\ISO8583\Contracts\IsoMessageContract;
use Andromeda\ISO8583\MessageDefinition;

class ExampleMessage extends MessageDefinition implements IsoMessageContract
{
    public function getIso(): array
    {
        return [
            1   => ['b',   32,  self::FIXED_LENGTH],
            2   => ['ans',  99,  self::VARIABLE_LENGTH],
            3   => ['n',   6,   self::FIXED_LENGTH],
            4   => ['n',   12,  self::FIXED_LENGTH],
            5   => ['n',   12,  self::FIXED_LENGTH],
            6   => ['n',   12,  self::FIXED_LENGTH],
            7   => ['an',  10,  self::FIXED_LENGTH],
         ];
    }
}

/*
    Array definition:
    1   => ['b',   32,  self::FIXED_LENGTH],
    bit => ['type','size','is variable or fixed']
*/

$messageDefinition = new \Andromeda\ISO8583\ExampleMessage();
$parser = new \Andromeda\ISO8583\Parser($messageDefinition);

//Example 01 
$parser->addMessage('0800...');
$parser->validateISO(); //return false

//Example 02
$parser->addMessage('0800A238000000C0000804000000000000000000010401000443495194000443040176007008043177567000140003001000');
$parser->validateISO(); //return true
$parser->getBit('07');  //return 0401000443


$message = new \Andromeda\ISO8583\ExampleMessage();
$isoMaker = new \Andromeda\ISO8583\Parser($message);
$isoMaker->addMTI('0800');
$isoMaker->addData(3, '123456');
$isoMaker->addData(4, '000000001000');
$isoMaker->addData(7, '1234567890');
$isoMaker->getISO(); // return 080032000000000000001234560000000010001234567890