artesaos / moip

Pagamentos Moip
https://moip.com.br/
MIT License
38 stars 19 forks source link

Moip \ Exceptions \ ValidationException No message Error on payment setCreditCard #15

Closed esprajwol closed 7 years ago

esprajwol commented 8 years ago

This code

 $payment = $order->payments()->setCreditCard(12, 21, '4073020000000002', '123', $customer)
    ->execute();

give error as Moip \ Exceptions \ ValidationException No message

vendor\moip\moip-sdk-php\src\Resource\MoipResource.php

$code = $http_response->status_code; $response_body = $http_response->body; if ($code >= 200 && $code < 300) { return json_decode($response_body); } elseif ($code == 401) { throw new Exceptions\UnautorizedException(); } elseif ($code >= 400 && $code <= 499) { $errors = Exceptions\Error::parseErrors($response_body); throw new Exceptions\ValidationException($code, $errors); } throw new Exceptions\UnexpectedException(); }

SOSTheBlack commented 8 years ago

The package could not connect to your MoIP account. You have the set?

ishyevandro commented 7 years ago

How do you trying to get the message?

Because "Exceptions\ValidationException" save errors in an array.

And $exception->getMessage() return nothing. the correct way (just in moip) is $exception->getErrors().

You can see an example in moip-sdk-php/tests/MoipTest.php