PHP Fatal error: Uncaught TypeError: Square\ApiHelper::serialize()

I use the WebPay module for Square in Zen Cart. I sometimes find this error in the log files. It happens when some customers want to check out. They receive an HTTP Error 500 and the transaction is not finished.
I can not recreate this error and most customers have no problem.
The language of the shop is Japanese. I mention this because maybe the serialize function has some problem with Japanese input.

→ PHP Fatal error: Uncaught TypeError: Square\ApiHelper::serialize(): Return value must be of type string, bool returned in /includes/modules/payment/square_webPay/square/square/src/ApiHelper.php:113

:wave: If this is with the official ZenCart Square integration we recommend that you reach out to them about this since they manage the integration and all API functions. :slightly_smiling_face:

Thank you. I already asked in the Zen Cart forum, but since it is an error happening in the files provided by Square, nobody had an answer.

Do they know what’s being returned as a boolean instead of a string? :slightly_smiling_face:

I do not know what is returned as a boolean.

The full error log is this:
PHP Fatal error: Uncaught TypeError: Square\ApiHelper::serialize(): Return value must be of type string, bool returned in /includes/modules/payment/square_webPay/square/square/src/ApiHelper.php:113
Stack trace:
#0 /includes/modules/payment/square_webPay/square/square/src/Apis/PaymentsApi.php(176): Square\ApiHelper::serialize(Object(Square\Models\CreatePaymentRequest))
#1 /includes/modules/payment/square_webPay.php(399): Square\Apis\PaymentsApi->createPayment(Object(Square\Models\CreatePaymentRequest))
#2 /includes/classes/payment.php(252): square_webPay->before_process()
#3 /includes/modules/myResp2/checkout_process.php(96): payment->before_process()
#4 /includes/modules/pages/checkout_process/header_php.php(14): require(‘/home2/rcracean…’)
#5 /index.php(35): require(‘/home2/…’)
#6 {main}
thrown in /includes/modules/payment/square_webPay/square/square/src/ApiHelper.php on line 113

hi brian,
square is not really developer friendly. here you have a person asking for some help, and you want to know if they are using the official zencart square implementation? have you investigated that link? zen-cart 1.5.4 was released in 2014 and is no longer supported. the current zen-cart version is 1.5.8. php 5.6 was EOL 12/2018. and yet that is what square has on their official zen-cart integration? on the link you have provided?

what you have listed there is the integration based on the SqPaymentForm library; which square retired 10/2022.

the new official zen-cart square integration is based on the square web payments sdk. and i developed it as courtesy to the zen-cart community. the plugin is listed here.

and it is officially listed in the docs here.

despite supporting all of the zen-cart community that relies on this plugin, square refuses to even grant me an affiliate link to allow me to continue development of the module, and the zen-cart community financial support is minimal at best.

considering the amount of financial transactions processed through square using code developed by me, and supported by me, why do you think that is?

with regards to the problem experienced here by todoonada, i have already done some troubleshooting on it. and frankly, i do not understand your question:

“Do they know what’s being returned as a boolean instead of a string?”

what does that mean? a boolean is being returned. probably false. the real question is why is a boolean being returned? the version that he is running has a json_encode call on line 113. and what is being submitted there are the complete order details as an array (from what i remember). and json_encode will return false if it can not properly encode the array. which most likely means some of the data submitted by the store owner was not properly utf8 encoded.

unfortunately todoonada can not provide all of the input array that is causing the error, which makes fixing it pure guess work. i would say that it is squares’ responsibility for catching any errors on failures with json_encode, but for all i know a more current version of your sdk does that. without financial support from the zen-cart community or from square, it makes keeping up with all of the latest sdks another charity project that i am less inclined to do.

does that make any sense?

best.

Hey @prose, just sent you a private message regarding the App Marketplace listing!