Skip to content

Commit

Permalink
Implementada melhoria de captura e cancelamento parcial, closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
lcsLucas committed Dec 22, 2023
1 parent f24d823 commit 08dff71
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 35 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,37 +288,37 @@ $responsePayment = $ipagClient->payment()->getByUuid($orderId);
### Capturar Pagamento

```php
$responsePayment = $ipagClient->payment()->captureById($transactionId);
$responsePayment = $ipagClient->payment()->captureById($transactionId, $amount);
```
ou
```php
$responsePayment = $ipagClient->payment()->captureByUuid($transactionUuid);
$responsePayment = $ipagClient->payment()->captureByUuid($transactionUuid, $amount);
```
ou
```php
$responsePayment = $ipagClient->payment()->captureByUuid($transactionTid);
$responsePayment = $ipagClient->payment()->captureByUuid($transactionTid, $amount);
```
ou
```php
$responsePayment = $ipagClient->payment()->captureByUuid($orderId);
$responsePayment = $ipagClient->payment()->captureByUuid($orderId, $amount);
```

### Cancelar Pagamento

```php
$responsePayment = $ipagClient->payment()->cancelById($transactionId);
$responsePayment = $ipagClient->payment()->cancelById($transactionId, $amount);
```
ou
```php
$responsePayment = $ipagClient->payment()->cancelByUuid($transactionUuid);
$responsePayment = $ipagClient->payment()->cancelByUuid($transactionUuid, $amount);
```
ou
```php
$responsePayment = $ipagClient->payment()->cancelByUuid($transactionTid);
$responsePayment = $ipagClient->payment()->cancelByUuid($transactionTid, $amount);
```
ou
```php
$responsePayment = $ipagClient->payment()->cancelByUuid($orderId);
$responsePayment = $ipagClient->payment()->cancelByUuid($orderId, $amount);
```

> Todos os exemplos: [examples/payment/](https://github.com/ipagdevs/ipag-sdk-php/tree/master/examples/payment/)
Expand Down
5 changes: 3 additions & 2 deletions examples/payment/14-payment-capture-by-id.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$transactionId = 123;

$responsePayment = $ipagClient->payment()->captureById($transactionId);
$responsePayment = $ipagClient->payment()->captureById($transactionId, 50.00);
$data = $responsePayment->getData();

$statusPayment = $responsePayment->getParsedPath('attributes.status.code');
Expand Down Expand Up @@ -41,4 +41,5 @@
var_dump($error);
echo "</pre>" . PHP_EOL;

}
}

2 changes: 1 addition & 1 deletion examples/payment/15-payment-capture-by-uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$transactionUuid = '4c56ff4ce4aaf9573aa5dff913df997a';

$responsePayment = $ipagClient->payment()->captureByUuid($transactionUuid);
$responsePayment = $ipagClient->payment()->captureByUuid($transactionUuid, 50.00);
$data = $responsePayment->getData();

$statusPayment = $responsePayment->getParsedPath('attributes.status.code');
Expand Down
2 changes: 1 addition & 1 deletion examples/payment/16-payment-capture-by-tid.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$transactionTid = 'fe79b3038e158b6e8802da5a31a557ad';

$responsePayment = $ipagClient->payment()->captureByTid($transactionTid);
$responsePayment = $ipagClient->payment()->captureByTid($transactionTid, 50.0);
$data = $responsePayment->getData();

$statusPayment = $responsePayment->getParsedPath('attributes.status.code');
Expand Down
2 changes: 1 addition & 1 deletion examples/payment/17-payment-capture-by-order-id.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$orderId = '114';

$responsePayment = $ipagClient->payment()->captureByOrderId($orderId);
$responsePayment = $ipagClient->payment()->captureByOrderId($orderId, 50.00);
$data = $responsePayment->getData();

$statusPayment = $responsePayment->getParsedPath('attributes.status.code');
Expand Down
2 changes: 1 addition & 1 deletion examples/payment/18-payment-cancel-by-id.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$transactionId = 115;

$responsePayment = $ipagClient->payment()->cancelById($transactionId);
$responsePayment = $ipagClient->payment()->cancelById($transactionId, 50.00);
$data = $responsePayment->getData();

$statusPayment = $responsePayment->getParsedPath('attributes.status.code');
Expand Down
2 changes: 1 addition & 1 deletion examples/payment/19-payment-cancel-by-uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$transactionUuid = '5fd0b37cd7dbbb00f97ba6ce92bf5add';

$responsePayment = $ipagClient->payment()->cancelByUuid($transactionUuid);
$responsePayment = $ipagClient->payment()->cancelByUuid($transactionUuid, 50.00);
$data = $responsePayment->getData();

$statusPayment = $responsePayment->getParsedPath('attributes.status.code');
Expand Down
2 changes: 1 addition & 1 deletion examples/payment/20-payment-cancel-by-tid.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$transactionTid = 'b1c875a8bd263903c24d0b45751bdfba';

$responsePayment = $ipagClient->payment()->cancelByTid($transactionTid);
$responsePayment = $ipagClient->payment()->cancelByTid($transactionTid, 50.00);
$data = $responsePayment->getData();

$statusPayment = $responsePayment->getParsedPath('attributes.status.code');
Expand Down
2 changes: 1 addition & 1 deletion examples/payment/21-payment-cancel-by-order-id.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$orderId = 124;

$responsePayment = $ipagClient->payment()->cancelByOrderId($orderId);
$responsePayment = $ipagClient->payment()->cancelByOrderId($orderId, 50.00);
$data = $responsePayment->getData();

$statusPayment = $responsePayment->getParsedPath('attributes.status.code');
Expand Down
44 changes: 26 additions & 18 deletions src/Endpoint/PaymentEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,104 +82,112 @@ public function getByOrderId(string $orderId): Response
* Endpoint para capturar um recurso `Payment`
*
* @param string $id
* @param ?float $amount
* @return Response
*
* @codeCoverageIgnore
*/
public function captureById(string $id): Response
public function captureById(string $id, ?float $amount = null): Response
{
return $this->_POST([], ['id' => $id], [], '/capture');
return $this->_POST([], compact('id', 'amount'), [], '/capture');
}

/**
* Endpoint para capturar um recurso `Payment`
*
* @param string $uuid
* @param ?float $amount
* @return Response
*
* @codeCoverageIgnore
*/
public function captureByUuid(string $uuid): Response
public function captureByUuid(string $uuid, ?float $amount = null): Response
{
return $this->_POST([], ['uuid' => $uuid], [], '/capture');
return $this->_POST([], compact('uuid', 'amount'), [], '/capture');
}

/**
* Endpoint para capturar um recurso `Payment`
*
* @param string $tid
* @param ?float $amount
* @return Response
*
* @codeCoverageIgnore
*/
public function captureByTid(string $tid): Response
public function captureByTid(string $tid, ?float $amount = null): Response
{
return $this->_POST([], ['tid' => $tid], [], '/capture');
return $this->_POST([], compact('tid', 'amount'), [], '/capture');
}

/**
* Endpoint para capturar um recurso `Payment`
*
* @param string $orderId
* @param string $order_id
* @param ?float $amount
* @return Response
*
* @codeCoverageIgnore
*/
public function captureByOrderId(string $orderId): Response
public function captureByOrderId(string $order_id, ?float $amount = null): Response
{
return $this->_POST([], ['order_id' => $orderId], [], '/capture');
return $this->_POST([], compact('order_id', 'amount'), [], '/capture');
}

/**
* Endpoint para cancelar um recurso `Payment`
*
* @param string $id
* @param ?float $amount
* @return Response
*
* @codeCoverageIgnore
*/
public function cancelById(string $id): Response
public function cancelById(string $id, ?float $amount = null): Response
{
return $this->_POST([], ['id' => $id], [], '/cancel');
return $this->_POST([], compact('id', 'amount'), [], '/cancel');
}

/**
* Endpoint para cancelar um recurso `Payment`
*
* @param string $uuid
* @param ?float $amount
* @return Response
*
* @codeCoverageIgnore
*/
public function cancelByUuid(string $uuid): Response
public function cancelByUuid(string $uuid, ?float $amount = null): Response
{
return $this->_POST([], ['uuid' => $uuid], [], '/cancel');
return $this->_POST([], compact('uuid', 'amount'), [], '/cancel');
}

/**
* Endpoint para cancelar um recurso `Payment`
*
* @param string $tid
* @param ?float $amount
* @return Response
*
* @codeCoverageIgnore
*/
public function cancelByTid(string $tid): Response
public function cancelByTid(string $tid, ?float $amount = null): Response
{
return $this->_POST([], ['tid' => $tid], [], '/cancel');
return $this->_POST([], compact('tid', 'amount'), [], '/cancel');
}

/**
* Endpoint para cancelar um recurso `Payment`
*
* @param string $orderId
* @param string $order_id
* @param ?float $amount
* @return Response
*
* @codeCoverageIgnore
*/
public function cancelByOrderId(string $orderId): Response
public function cancelByOrderId(string $order_id, ?float $amount = null): Response
{
return $this->_POST([], ['order_id' => $orderId], [], '/cancel');
return $this->_POST([], compact('order_id', 'amount'), [], '/cancel');
}

}

0 comments on commit 08dff71

Please sign in to comment.