Fatal error: Uncaught TypeError: Cannot assign array to property MercadoPago\Resources\Common\Address::$city of type ?string #492
Closed
Jhulianogs
started this conversation in
General
Replies: 1 comment
-
Bom dia @Jhulianogs , tudo bem? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Olá,
durante e implantação da SDK, notei que quando tentava cadastrar clientes adicionando um array a propriedade city (address.city) conforme aparece na documentação, durante a desserialização ocorria um erro fatal:
Fatal error: Uncaught TypeError: Cannot assign array to property MercadoPago\Resources\Common\Address::$city of type ?string
Caso eu não venha a adicionar a propriedade city, ao buscar pelo mesmo cadastro o sistema não ocorre erro.
$body = [ 'email' => '[email protected]', 'first_name' => 'Jhon', 'last_name' => 'Doe', 'phone' => [ 'area_code' => '55', 'number' => '991234567' ], 'identification' => [ 'type' => 'CPF', 'number' => '12345678900' ], 'default_address' => 'Home', 'address' => [ 'id' => '123123', 'zip_code' => '01205000', 'street_name' => 'Rua Exemplo', 'street_number' => 123, 'city' => ['name' => 'São Paulo'], //The problem ], 'date_registered' => '2023-09-07T11:37:30.000-04:00', 'description' => 'Description del user', 'default_card' => 'None' ];
Foram 3 testes:
[ "message" => "invalid parameters : address.address.city is wrong" "error" => "bad_request" "status" => 400 "cause" => array:1 [▼ 0 => array:2 [▼ "code" => "103" "description" => "address.address.city must be a Json Object" ] ] ]
Possível solução: adicionar a tipagem de array|object a propriedade \MercadoPago\Resources\Common\Address::city.
SDK: 3.0.1
PHP: 8.2.0
Documentação:
https://www.mercadopago.com.br/developers/pt/docs/sdks-library/server-side/php/customers
https://www.mercadopago.com.br/developers/pt/reference/customers/_customers/post
Beta Was this translation helpful? Give feedback.
All reactions