Skip to content

Commit

Permalink
Cancelamento de transações há mais de 1 dia (D+n).
Browse files Browse the repository at this point in the history
  • Loading branch information
edson-nascimento committed May 3, 2019
1 parent 80a6b87 commit a3afa0b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Getnet/API/Getnet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a3afa0b

Please sign in to comment.