Skip to content

Commit 08dff71

Browse files
committed
Implementada melhoria de captura e cancelamento parcial, closes #2
1 parent f24d823 commit 08dff71

10 files changed

Lines changed: 44 additions & 35 deletions

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,37 +288,37 @@ $responsePayment = $ipagClient->payment()->getByUuid($orderId);
288288
### Capturar Pagamento
289289

290290
```php
291-
$responsePayment = $ipagClient->payment()->captureById($transactionId);
291+
$responsePayment = $ipagClient->payment()->captureById($transactionId, $amount);
292292
```
293293
ou
294294
```php
295-
$responsePayment = $ipagClient->payment()->captureByUuid($transactionUuid);
295+
$responsePayment = $ipagClient->payment()->captureByUuid($transactionUuid, $amount);
296296
```
297297
ou
298298
```php
299-
$responsePayment = $ipagClient->payment()->captureByUuid($transactionTid);
299+
$responsePayment = $ipagClient->payment()->captureByUuid($transactionTid, $amount);
300300
```
301301
ou
302302
```php
303-
$responsePayment = $ipagClient->payment()->captureByUuid($orderId);
303+
$responsePayment = $ipagClient->payment()->captureByUuid($orderId, $amount);
304304
```
305305

306306
### Cancelar Pagamento
307307

308308
```php
309-
$responsePayment = $ipagClient->payment()->cancelById($transactionId);
309+
$responsePayment = $ipagClient->payment()->cancelById($transactionId, $amount);
310310
```
311311
ou
312312
```php
313-
$responsePayment = $ipagClient->payment()->cancelByUuid($transactionUuid);
313+
$responsePayment = $ipagClient->payment()->cancelByUuid($transactionUuid, $amount);
314314
```
315315
ou
316316
```php
317-
$responsePayment = $ipagClient->payment()->cancelByUuid($transactionTid);
317+
$responsePayment = $ipagClient->payment()->cancelByUuid($transactionTid, $amount);
318318
```
319319
ou
320320
```php
321-
$responsePayment = $ipagClient->payment()->cancelByUuid($orderId);
321+
$responsePayment = $ipagClient->payment()->cancelByUuid($orderId, $amount);
322322
```
323323

324324
> Todos os exemplos: [examples/payment/](https://github.com/ipagdevs/ipag-sdk-php/tree/master/examples/payment/)

examples/payment/14-payment-capture-by-id.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
$transactionId = 123;
88

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

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

44-
}
44+
}
45+

examples/payment/15-payment-capture-by-uuid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
$transactionUuid = '4c56ff4ce4aaf9573aa5dff913df997a';
88

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

1212
$statusPayment = $responsePayment->getParsedPath('attributes.status.code');

examples/payment/16-payment-capture-by-tid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
$transactionTid = 'fe79b3038e158b6e8802da5a31a557ad';
88

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

1212
$statusPayment = $responsePayment->getParsedPath('attributes.status.code');

examples/payment/17-payment-capture-by-order-id.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
$orderId = '114';
88

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

1212
$statusPayment = $responsePayment->getParsedPath('attributes.status.code');

examples/payment/18-payment-cancel-by-id.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
$transactionId = 115;
88

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

1212
$statusPayment = $responsePayment->getParsedPath('attributes.status.code');

examples/payment/19-payment-cancel-by-uuid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
$transactionUuid = '5fd0b37cd7dbbb00f97ba6ce92bf5add';
88

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

1212
$statusPayment = $responsePayment->getParsedPath('attributes.status.code');

examples/payment/20-payment-cancel-by-tid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
$transactionTid = 'b1c875a8bd263903c24d0b45751bdfba';
88

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

1212
$statusPayment = $responsePayment->getParsedPath('attributes.status.code');

examples/payment/21-payment-cancel-by-order-id.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
$orderId = 124;
88

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

1212
$statusPayment = $responsePayment->getParsedPath('attributes.status.code');

src/Endpoint/PaymentEndpoint.php

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,104 +82,112 @@ public function getByOrderId(string $orderId): Response
8282
* Endpoint para capturar um recurso `Payment`
8383
*
8484
* @param string $id
85+
* @param ?float $amount
8586
* @return Response
8687
*
8788
* @codeCoverageIgnore
8889
*/
89-
public function captureById(string $id): Response
90+
public function captureById(string $id, ?float $amount = null): Response
9091
{
91-
return $this->_POST([], ['id' => $id], [], '/capture');
92+
return $this->_POST([], compact('id', 'amount'), [], '/capture');
9293
}
9394

9495
/**
9596
* Endpoint para capturar um recurso `Payment`
9697
*
9798
* @param string $uuid
99+
* @param ?float $amount
98100
* @return Response
99101
*
100102
* @codeCoverageIgnore
101103
*/
102-
public function captureByUuid(string $uuid): Response
104+
public function captureByUuid(string $uuid, ?float $amount = null): Response
103105
{
104-
return $this->_POST([], ['uuid' => $uuid], [], '/capture');
106+
return $this->_POST([], compact('uuid', 'amount'), [], '/capture');
105107
}
106108

107109
/**
108110
* Endpoint para capturar um recurso `Payment`
109111
*
110112
* @param string $tid
113+
* @param ?float $amount
111114
* @return Response
112115
*
113116
* @codeCoverageIgnore
114117
*/
115-
public function captureByTid(string $tid): Response
118+
public function captureByTid(string $tid, ?float $amount = null): Response
116119
{
117-
return $this->_POST([], ['tid' => $tid], [], '/capture');
120+
return $this->_POST([], compact('tid', 'amount'), [], '/capture');
118121
}
119122

120123
/**
121124
* Endpoint para capturar um recurso `Payment`
122125
*
123-
* @param string $orderId
126+
* @param string $order_id
127+
* @param ?float $amount
124128
* @return Response
125129
*
126130
* @codeCoverageIgnore
127131
*/
128-
public function captureByOrderId(string $orderId): Response
132+
public function captureByOrderId(string $order_id, ?float $amount = null): Response
129133
{
130-
return $this->_POST([], ['order_id' => $orderId], [], '/capture');
134+
return $this->_POST([], compact('order_id', 'amount'), [], '/capture');
131135
}
132136

133137
/**
134138
* Endpoint para cancelar um recurso `Payment`
135139
*
136140
* @param string $id
141+
* @param ?float $amount
137142
* @return Response
138143
*
139144
* @codeCoverageIgnore
140145
*/
141-
public function cancelById(string $id): Response
146+
public function cancelById(string $id, ?float $amount = null): Response
142147
{
143-
return $this->_POST([], ['id' => $id], [], '/cancel');
148+
return $this->_POST([], compact('id', 'amount'), [], '/cancel');
144149
}
145150

146151
/**
147152
* Endpoint para cancelar um recurso `Payment`
148153
*
149154
* @param string $uuid
155+
* @param ?float $amount
150156
* @return Response
151157
*
152158
* @codeCoverageIgnore
153159
*/
154-
public function cancelByUuid(string $uuid): Response
160+
public function cancelByUuid(string $uuid, ?float $amount = null): Response
155161
{
156-
return $this->_POST([], ['uuid' => $uuid], [], '/cancel');
162+
return $this->_POST([], compact('uuid', 'amount'), [], '/cancel');
157163
}
158164

159165
/**
160166
* Endpoint para cancelar um recurso `Payment`
161167
*
162168
* @param string $tid
169+
* @param ?float $amount
163170
* @return Response
164171
*
165172
* @codeCoverageIgnore
166173
*/
167-
public function cancelByTid(string $tid): Response
174+
public function cancelByTid(string $tid, ?float $amount = null): Response
168175
{
169-
return $this->_POST([], ['tid' => $tid], [], '/cancel');
176+
return $this->_POST([], compact('tid', 'amount'), [], '/cancel');
170177
}
171178

172179
/**
173180
* Endpoint para cancelar um recurso `Payment`
174181
*
175-
* @param string $orderId
182+
* @param string $order_id
183+
* @param ?float $amount
176184
* @return Response
177185
*
178186
* @codeCoverageIgnore
179187
*/
180-
public function cancelByOrderId(string $orderId): Response
188+
public function cancelByOrderId(string $order_id, ?float $amount = null): Response
181189
{
182-
return $this->_POST([], ['order_id' => $orderId], [], '/cancel');
190+
return $this->_POST([], compact('order_id', 'amount'), [], '/cancel');
183191
}
184192

185193
}

0 commit comments

Comments
 (0)