gdsmith / JAK8583

Composer enabled PRS-0 github version of JAK8583
http://www.phpclasses.org/package/5398-PHP-Generate-and-parse-ISO-8583-transaction-messages.html
GNU General Public License v2.0
6 stars 6 forks source link

bad result #1

Closed MFaridAli closed 1 year ago

MFaridAli commented 6 years ago

$jakres = new JAK8583(); $jakres->addISO($hasil); $de=$jakres->getData(); $rc=$de;

result ??? ? ??? ? ? ? ? ? ?? ??

gdsmith commented 6 years ago

Yeah, ISO8583 is a real PITA to work with. What exactly are you trying to do? What's your source ISO? IIRC the bitmap needs to be in hex before you addISO, if you have a binary bitmap you'll need to convert using something like:

    private function _unpack_bitmap($iso)
    {
        $bitmap = substr($iso, 4,8);
        $this->_log(__METHOD__.' bitmap:'.$bitmap);

        $bitmap = bin2hex($bitmap);
        $this->_log(__METHOD__.' bin2hex:bitmap:'.$bitmap);

        return substr($iso, 0,4).$bitmap.substr($iso, 12);
    }

and going the other way

    private function _pack_bitmap($iso)
    {
        $bitmap = substr($iso, 4,16);
        $this->_log(__METHOD__.' bitmap:'.$bitmap);

        $bitmap = hex2bin($bitmap);
        $this->_log(__METHOD__.' hex2bin:bitmap:'.$bitmap);

        return substr($iso, 0,4).$bitmap.substr($iso, 20);
    }

Not sure why this isn't part of the library, I just took the original and built my implementation around it's limitations. Once I got it working for my project I kinda forgot all about it. If you can add that in, I'll happily accept a PR.

gdsmith commented 6 years ago

Hey @MFaridAli did you solve your issue?

MFaridAli commented 6 years ago

not yet, I am very confused, because on my other computer with the Ubuntu OS it's work. now i use osx

sylv3st3r commented 4 years ago

I believe I can answer this. MFaridAli must be running PHP 7.1 and up. Since 7.1, the string will not be converted to array automatically. This the result is in string, instead of intended array on getData(); So you need to change the _clear function from $this->_data = '';

Into: $this->_data = array(); It will solve the problems. And since the change is quite minimal. I believe I don't need to fork this yeah?