# Error when integrating new API

**URL:** <https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955>\
**Category:** Questions\
**Created:** [March 22, 2023, 2:34pm UTC](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955 "2023-03-22T14:34:21Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![jeremyredd](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jeremyredd](https://developer.squareup.com/forums/u/jeremyredd)\
**Post date:** [March 22, 2023, 10:01pm UTC](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955/21 "2023-03-22T22:01:36Z")

</div>

$create\_payment\_request ?

---

<div class="post-metadata">

**Author:** ![jeremyredd](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jeremyredd](https://developer.squareup.com/forums/u/jeremyredd)\
**Post date:** [March 22, 2023, 11:17pm UTC](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955/22 "2023-03-22T23:17:43Z")

</div>

tried writing the value to the the console and its like its not even hitting the process-payment.php

---

<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:** [March 22, 2023, 11:42pm UTC](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955/23 "2023-03-22T23:42:59Z")

</div>

Right its `$create_payment_request`. Are you able to print the request body that it builds? 🙂

---

<div class="post-metadata">

**Author:** ![jeremyredd](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jeremyredd](https://developer.squareup.com/forums/u/jeremyredd)\
**Post date:** [March 22, 2023, 11:47pm UTC](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955/24 "2023-03-22T23:47:50Z")

</div>

error\_log(“start1”);  
error\_log($create\_payment\_request);  
error\_log(“end1”);

produces this in the php error log  
[22-Mar-2023 23:47:04 UTC] -------------------------------------------------------------------------------------------------  
[22-Mar-2023 23:47:04 UTC] start1  
[22-Mar-2023 23:47:04 UTC] PHP Warning: error\_log() expects parameter 1 to be string, object given in D:\vhosts\nac-issa.org\httpdocs\SquareEcom2\process-payment.php on line 72  
[22-Mar-2023 23:47:04 UTC] end1  
[22-Mar-2023 23:47:04 UTC] PHP Fatal error: Uncaught TypeError: Argument 1 passed to Square\ApiHelper::appendUrlWithTemplateParameters() must be of the type string, null given, called in D:\vhosts\nac-issa.org\httpdocs\SquareEcom2\vendor\square\square\src\SquareClient.php on line 304 and defined in D:\vhosts\nac-issa.org\httpdocs\SquareEcom2\vendor\square\square\src\ApiHelper.php:47  
Stack trace:  
#0 D:\vhosts\nac-issa.org\httpdocs\SquareEcom2\vendor\square\square\src\SquareClient.php(304): Square\ApiHelper::appendUrlWithTemplateParameters()  
#1 D:\vhosts\nac-issa.org\httpdocs\SquareEcom2\vendor\square\square\src\Apis\PaymentsApi.php(163): Square\SquareClient-\>getBaseUri()  
#2 D:\vhosts\nac-issa.org\httpdocs\SquareEcom2\process-payment.php(75): Square\Apis\PaymentsApi-\>createPayment()  
#3 {main}  
thrown in D:\vhosts\nac-issa.org\httpdocs\SquareEcom2\vendor\square\square\src\ApiHelper.php on line 47

---

<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:** [March 22, 2023, 11:52pm UTC](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955/25 "2023-03-22T23:52:33Z")

</div>

Whats on `\process-payment.php` on line 72? 🙂

---

<div class="post-metadata">

**Author:** ![jeremyredd](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jeremyredd](https://developer.squareup.com/forums/u/jeremyredd)\
**Post date:** [March 22, 2023, 11:54pm UTC](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955/26 "2023-03-22T23:54:05Z")

</div>

error\_log(“start1”);  
error\_log(strval( $create\_payment\_request));  
error\_log(“end1”);

---

<div class="post-metadata">

**Author:** ![jeremyredd](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jeremyredd](https://developer.squareup.com/forums/u/jeremyredd)\
**Post date:** [March 23, 2023, 12:03am UTC](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955/28 "2023-03-23T00:03:03Z")

</div>

ok got it to print to log…

Square\Models\CreatePaymentRequest Object  
(  
[sourceId:Square\Models\CreatePaymentRequest:private] =\> cnon:CBESEFtRO\_N50XJl5M3izXyk3Ec  
[idempotencyKey:Square\Models\CreatePaymentRequest:private] =\> 309504d6-12d3-44dc-aa9b-803b2794e947  
[amountMoney:Square\Models\CreatePaymentRequest:private] =\> Square\Models\Money Object  
(  
[amount:Square\Models\Money:private] =\> 100  
[currency:Square\Models\Money:private] =\> USD  
)

```
[tipMoney:Square\Models\CreatePaymentRequest:private] => 
[appFeeMoney:Square\Models\CreatePaymentRequest:private] => 
[delayDuration:Square\Models\CreatePaymentRequest:private] => 
[autocomplete:Square\Models\CreatePaymentRequest:private] => 
[orderId:Square\Models\CreatePaymentRequest:private] => 
[customerId:Square\Models\CreatePaymentRequest:private] => 
[locationId:Square\Models\CreatePaymentRequest:private] => 67DE3EQ108NQZ
[teamMemberId:Square\Models\CreatePaymentRequest:private] => 
[referenceId:Square\Models\CreatePaymentRequest:private] => 
[verificationToken:Square\Models\CreatePaymentRequest:private] => 
[acceptPartialAuthorization:Square\Models\CreatePaymentRequest:private] => 
[buyerEmailAddress:Square\Models\CreatePaymentRequest:private] => 
[billingAddress:Square\Models\CreatePaymentRequest:private] => 
[shippingAddress:Square\Models\CreatePaymentRequest:private] => 
[note:Square\Models\CreatePaymentRequest:private] => 
[statementDescriptionIdentifier:Square\Models\CreatePaymentRequest:private] => 
[cashDetails:Square\Models\CreatePaymentRequest:private] => 
[externalDetails:Square\Models\CreatePaymentRequest:private] => 

```

)

---

<div class="post-metadata">

**Author:** ![jeremyredd](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jeremyredd](https://developer.squareup.com/forums/u/jeremyredd)\
**Post date:** [March 23, 2023, 12:20am UTC](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955/30 "2023-03-23T00:20:27Z")

</div>

the php then crashes on this line

$response = $payments\_api-\>createPayment($create\_payment\_request);

---

<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:** [March 23, 2023, 4:10pm UTC](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955/31 "2023-03-23T16:10:39Z")

</div>

Is it the JSON error crash at this point? 🙂

---

<div class="post-metadata">

**Author:** ![jeremyredd](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jeremyredd](https://developer.squareup.com/forums/u/jeremyredd)\
**Post date:** [March 23, 2023, 4:36pm UTC](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955/32 "2023-03-23T16:36:26Z")

</div>

Yeah it is. It crashes and produces that error in the console.

[Previous page](https://developer.squareup.com/forums/t/error-when-integrating-new-api/8955.md?page=1)
