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

**URL:** <https://developer.squareup.com/forums/t/php-fatal-error-uncaught-typeerror-square-apihelper-serialize/8224>\
**Category:** Questions\
**Created:** [January 14, 2023, 9:35am UTC](https://developer.squareup.com/forums/t/php-fatal-error-uncaught-typeerror-square-apihelper-serialize/8224 "2023-01-14T09:35:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![todoonada](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@todoonada](https://developer.squareup.com/forums/u/todoonada)\
**Post date:** [January 14, 2023, 9:35am UTC](https://developer.squareup.com/forums/t/php-fatal-error-uncaught-typeerror-square-apihelper-serialize/8224/1 "2023-01-14T09:35:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [January 17, 2023, 4:58pm UTC](https://developer.squareup.com/forums/t/php-fatal-error-uncaught-typeerror-square-apihelper-serialize/8224/2 "2023-01-17T16:58:15Z")

</div>

👋 If this is with the official [ZenCart](https://squareup.com/us/en/app-marketplace/search?query=zen%20cart) Square integration we recommend that you reach out to them about this since they manage the integration and all API functions. 🙂

---

<div class="post-metadata">

**Author:** ![todoonada](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@todoonada](https://developer.squareup.com/forums/u/todoonada)\
**Post date:** [January 18, 2023, 12:32am UTC](https://developer.squareup.com/forums/t/php-fatal-error-uncaught-typeerror-square-apihelper-serialize/8224/3 "2023-01-18T00:32:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [January 18, 2023, 12:40am UTC](https://developer.squareup.com/forums/t/php-fatal-error-uncaught-typeerror-square-apihelper-serialize/8224/4 "2023-01-18T00:40:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![todoonada](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@todoonada](https://developer.squareup.com/forums/u/todoonada)\
**Post date:** [January 18, 2023, 12:54am UTC](https://developer.squareup.com/forums/t/php-fatal-error-uncaught-typeerror-square-apihelper-serialize/8224/5 "2023-01-18T00:54:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![prose](https://avatars.discourse-cdn.com/v4/letter/p/b4bc9f/32.png) [@prose](https://developer.squareup.com/forums/u/prose)\
**Post date:** [January 23, 2023, 6:10am UTC](https://developer.squareup.com/forums/t/php-fatal-error-uncaught-typeerror-square-apihelper-serialize/8224/6 "2023-01-23T06:10:39Z")

</div>

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.](https://www.zen-cart.com/downloads.php?do=file&id=2345)

and it is `officially` listed in [the docs here](https://docs.zen-cart.com/user/payment/square/).

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.

---

<div class="post-metadata">

**Author:** ![josh-square](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@josh-square](https://developer.squareup.com/forums/u/josh-square)\
**Post date:** [January 24, 2023, 12:05am UTC](https://developer.squareup.com/forums/t/php-fatal-error-uncaught-typeerror-square-apihelper-serialize/8224/7 "2023-01-24T00:05:32Z")

</div>

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