Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buscar Pagamento por Parcelamento. #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Adapter/GuzzleHttpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
16 changes: 16 additions & 0 deletions src/Api/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

// Entities
use Softr\Asaas\Entity\Payment as PaymentEntity;
use Softr\Asaas\Entity\Installment as InstallmentEntity;

/**
* Payment API Endpoint
Expand Down Expand Up @@ -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
*
Expand Down
17 changes: 17 additions & 0 deletions src/Entity/Installment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Softr\Asaas\Entity;

/**
* Installment Entity
*
* @author Shirleyson Kaisser <[email protected]>
*/
final class Installment extends \Softr\Asaas\Entity\AbstractEntity
{
/**
* @var array
*/
public $data;


}
4 changes: 4 additions & 0 deletions src/Entity/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity
*/
public $boletoUrl;

/**
* @var int
*/
public $installment;
/**
* @var int
*/
Expand Down