NikolaGavric94 / laravel-square

Square integration with Laravel/Lumen >=5.5
MIT License
31 stars 23 forks source link

Error Throw When user Exists #82

Closed mobrad1 closed 7 months ago

mobrad1 commented 9 months ago

This Error gets thrown when setCustomer is called and an existing customer is passed in { "message": "Cannot assign Square\\Models\\UpdateCustomerRequest to property Nikolag\\Square\\SquareService::$createCustomerRequest of type Square\\Models\\CreateCustomerRequest", "exception": "TypeError", "file": "/var/www/html/vendor/nikolag/laravel-square/src/SquareService.php", "line": 391, "trace": [ { "file": "/var/www/html/vendor/nikolag/laravel-square/src/SquareService.php", "line": 433, "function": "setCreateCustomerRequest", "class": "Nikolag\\Square\\SquareService", "type": "->" },

After Updating this on the SquareService it works okay ` /**
 * @var CreateCustomerRequest
 */
private CreateCustomerRequest $createCustomerRequest;`

To this 

` /**
 * @var CreateCustomerRequest|UpdateCustomerRequest;
 */
private $createCustomerRequest;`

Am i Doing something wrong 
NikolaGavric94 commented 7 months ago

Hello, I'll investigate this issue this weekend and get back to you, thanks for reporting it

NikolaGavric94 commented 7 months ago

@mobrad1 Seems like you have an older version of the library which doesn't have this fix, but yes, you are right, it is only throwing a type error, not an actual logical error so updating the phpdoc and adding the UpdateCustomerRequest will fix the error. If for any reason you are not able to have the latest version of the library, you are free to fork and make your own fix with the version you are using.

Altho I would suggest to upgrade to the latest version of the library as soon as possible.