From a3afa0b9dfc55cf6da2d2bcfc17b06e0e17a8441 Mon Sep 17 00:00:00 2001 From: Edson Nascimento Date: Fri, 3 May 2019 09:28:51 -0300 Subject: [PATCH] =?UTF-8?q?Cancelamento=20de=20transa=C3=A7=C3=B5es=20h?= =?UTF-8?q?=C3=A1=20mais=20de=201=20dia=20(D+n).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Getnet/API/Getnet.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Getnet/API/Getnet.php b/src/Getnet/API/Getnet.php index 6390c7a..878a766 100644 --- a/src/Getnet/API/Getnet.php +++ b/src/Getnet/API/Getnet.php @@ -200,6 +200,7 @@ public function authorizeConfirmDebit($payment_id, $payer_authentication_respons } /** + * Estorna ou desfaz transações feitas no mesmo dia (D0). * * @param $payment_id * @param $amount_val @@ -225,6 +226,35 @@ public function authorizeCancel($payment_id, $amount_val) { return $authresponse; } + /** + * Solicita o cancelamento de transações que foram realizadas há mais de 1 dia (D+n). + * + * @param mixed $payment_id + * @param mixed $cancel_amount + * @param mixed $cancel_custom_key + * @return AuthorizeResponse|BaseResponse + */ + public function cancelTransaction($payment_id, $cancel_amount, $cancel_custom_key) { + + $params = array("payment_id"=>$payment_id, "cancel_amount"=>$cancel_amount, "cancel_custom_key"=>$cancel_custom_key); + + try { + $request = new Request($this); + $response = $request->post($this, "/v1/payments/cancel/request", json_encode($params)); + } catch (\Exception $e) { + + $error = new BaseResponse(); + $error->mapperJson(json_decode($e->getMessage(), true)); + + return $error; + } + + $authresponse = new AuthorizeResponse(); + $authresponse->mapperJson($response); + + return $authresponse; + } + /** * * @param Transaction $transaction