JAK8583 icon indicating copy to clipboard operation
JAK8583 copied to clipboard

bad result

Open MFaridAli opened this issue 7 years ago • 4 comments

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

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

MFaridAli avatar Aug 09 '18 04:08 MFaridAli

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 avatar Aug 09 '18 06:08 gdsmith

Hey @MFaridAli did you solve your issue?

gdsmith avatar Aug 18 '18 12:08 gdsmith

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

MFaridAli avatar Aug 18 '18 12:08 MFaridAli

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?

sylv3st3r avatar Sep 07 '19 19:09 sylv3st3r