1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Ebanx Cancel Request. |
4
|
|
|
*/ |
5
|
|
|
namespace Omnipay\Ebanx\Message; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Ebanx Cancel Request. |
9
|
|
|
* |
10
|
|
|
* To cancel a payment, you must call the API method cancel. You can cancel a payment if, only if, |
11
|
|
|
* its status is open (OP) or pending (PE). It’s important to remember that is not possible to |
12
|
|
|
* cancel confirmed payments (CO), only refunded. |
13
|
|
|
* |
14
|
|
|
* Example: |
15
|
|
|
* |
16
|
|
|
* <code> |
17
|
|
|
* // Create a gateway for the Ebanx Gateway |
18
|
|
|
* // (routes to GatewayFactory::create) |
19
|
|
|
* $gateway = Omnipay::create('Ebanx'); |
20
|
|
|
* |
21
|
|
|
* // Initialise the gateway |
22
|
|
|
* $gateway->initialize(array( |
23
|
|
|
* 'integration_key' => 'MyApiKey', |
24
|
|
|
* )); |
25
|
|
|
* |
26
|
|
|
* // Do an authorize transaction on the gateway |
27
|
|
|
* $transaction = $gateway->cancel(array( |
28
|
|
|
* 'transactionReference' => '5d5eb3389d1bce23d265b8d2376688b09a0fafc56d453252', |
29
|
|
|
* )); |
30
|
|
|
* |
31
|
|
|
* $response = $transaction->send(); |
32
|
|
|
* </code> |
33
|
|
|
* |
34
|
|
|
* @see \Omnipay\Ebanx\Gateway |
35
|
|
|
* @link https://developers.ebanxpagamentos.com/api-reference/ebanx-payment-api/ebanx-payment-guide/guide-cancel-a-refund/ |
36
|
|
|
*/ |
37
|
|
|
class CancelRequest extends AbstractRequest |
38
|
|
|
{ |
39
|
3 |
|
public function getData() |
40
|
|
|
{ |
41
|
|
|
/* |
42
|
|
|
* As the cancel request the params should be passed in the query |
43
|
|
|
* not in the body, we return an empty array for the body, and |
44
|
|
|
* change the params at the getEndpoint method. |
45
|
|
|
*/ |
46
|
3 |
|
return []; |
47
|
|
|
} |
48
|
|
|
|
49
|
3 |
|
public function getEndpoint() |
50
|
|
|
{ |
51
|
3 |
|
$data = $this->getDefaultParameters(); |
52
|
3 |
|
$data['hash'] = $this->getTransactionReference(); |
53
|
|
|
|
54
|
3 |
|
return parent::getEndpoint() . '/cancel?' . http_build_query($data, '', '&'); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|