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