diff --git a/src/Adapter/GuzzleHttpAdapter.php b/src/Adapter/GuzzleHttpAdapter.php index 3498a7f..8f76195 100644 --- a/src/Adapter/GuzzleHttpAdapter.php +++ b/src/Adapter/GuzzleHttpAdapter.php @@ -159,9 +159,9 @@ protected function handleError() { $body = (string) $this->response->getBody(); $code = (int) $this->response->getStatusCode(); - $content = json_decode($body); + $error = $content->errors[0]; - throw new HttpException(isset($content->message) ? $content->message : 'Request not processed.', $code); + throw new HttpException(isset($error) ? $error->description : 'Request not processed.', $code); } } \ No newline at end of file diff --git a/src/Api/Payment.php b/src/Api/Payment.php index f060751..ca53ef7 100644 --- a/src/Api/Payment.php +++ b/src/Api/Payment.php @@ -3,6 +3,7 @@ // Entities use Softr\Asaas\Entity\Payment as PaymentEntity; +use Softr\Asaas\Entity\Installment as InstallmentEntity; /** * Payment API Endpoint @@ -67,6 +68,21 @@ public function getByCustomer($customerId, array $filters = []) }, $payments->data); } + /** + * Get Payment By Installment Id + * + * @param int $installmentId Installment Id + * @return PaymentEntity + */ + public function getByInstallmentId($installmentId) + { + $installment = $this->adapter->get(sprintf('%s/payments?installment=%s', $this->endpoint, $installmentId)); + + $installment = json_decode($installment); + + return new InstallmentEntity($installment); + } + /** * Get Payments By Subscription Id * diff --git a/src/Entity/Installment.php b/src/Entity/Installment.php new file mode 100644 index 0000000..8dedb2e --- /dev/null +++ b/src/Entity/Installment.php @@ -0,0 +1,17 @@ + + */ +final class Installment extends \Softr\Asaas\Entity\AbstractEntity +{ + /** + * @var array + */ + public $data; + + +} \ No newline at end of file diff --git a/src/Entity/Payment.php b/src/Entity/Payment.php index 72082c4..126335a 100644 --- a/src/Entity/Payment.php +++ b/src/Entity/Payment.php @@ -88,6 +88,10 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity */ public $boletoUrl; + /** + * @var int + */ + public $installment; /** * @var int */