maibank / maibapi

MAIB Payment PHP SDK
1 stars 1 forks source link

Gateway response parsing is platform-dependent #3

Closed alexminza closed 1 year ago

alexminza commented 1 year ago

See original issue: https://github.com/alexminza/wc-moldovaagroindbank/issues/29

They are running on a Windows server - thus PHP_EOL is defined differently and explode(PHP_EOL... does not properly parse the response from a *nix server.

https://github.com/maibank/maibapi/blob/main/src/MaibApi/MaibClient.php#LL77

$array1 = explode(PHP_EOL, trim((string)$response->offsetGet('additionalProperties')));
alexminza commented 1 year ago

@ChR1sMC suggests a great article here :) https://eidson.info/post/php_eol_is_broken

ChR1sMC commented 1 year ago

@ChR1sMC suggests a great article here :) https://eidson.info/post/php_eol_is_broken

Thx @alexminza , I replaced the code of the library on my server, as article suggests: To Replace: $lines = explode(PHP_EOL, $str);

With: $lines = preg_split('/\n|\r\n?/', $str);

And I can confirm that my issue has been fixed !

alexminza commented 1 year ago

I replaced the code of the library on my server, as article suggests

@ChR1sMC can you please submit a PR for this?

ChR1sMC commented 1 year ago

Will do, thank you

On Mon, 29 May 2023 at 14:56, Alexander Minza @.***> wrote:

I replaced the code of the library on my server, as article suggests

@ChR1sMC https://github.com/ChR1sMC can you please submit a PR for this?

— Reply to this email directly, view it on GitHub https://github.com/maibank/maibapi/issues/3#issuecomment-1567039918, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALRQOR56VXRH4YQDLDUGQILXISFE7ANCNFSM6AAAAAAYQIYR7Y . You are receiving this because you were mentioned.Message ID: @.***>

alexminza commented 1 year ago

It seems that there was just a release with this modification implemented directly in the code, without any PR or issue mentioned.

https://github.com/maibank/maibapi/releases/tag/2.0.4

https://github.com/maibank/maibapi/compare/2.0.3...2.0.4

alexminza commented 1 year ago

@maib-ecomm please use branches and PR merging along with issues mentioning to allow proper tracking for the fixes.

maib-ecomm commented 1 year ago

Hi! Thank you! Fixed in 2.0.4 / 3.0.4