No need extra $order->status check. These functions expired() and settled() do it for us.
This commit is contained in:
@@ -82,7 +82,7 @@ function authorize_expired(&$order)
|
||||
* @param string &$message Information about error message if this function returns false.
|
||||
* @param object &$extra Extra data that used for refunding and credit card information.
|
||||
* @param int $action Which action will be performed. See AN_ACTION_*
|
||||
* @param string $cctype Credit card type, used internally to configure types automatically.
|
||||
* @param string $cctype Used internally to configure credit types automatically.
|
||||
* @return bool true Transaction was successful, false otherwise. Use $message for reason.
|
||||
* @author Ethem Evlice <ethem a.t evlice d.o.t com>
|
||||
* @uses $CFG
|
||||
@@ -95,7 +95,7 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
|
||||
$test = !empty($CFG->an_test);
|
||||
|
||||
if (!isset($conststring)) {
|
||||
$consdata = array(
|
||||
$constdata = array(
|
||||
'x_version' => '3.1',
|
||||
'x_delim_data' => 'True',
|
||||
'x_delim_char' => AN_DELIM,
|
||||
@@ -106,7 +106,7 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
|
||||
'x_test_request' => $test ? 'TRUE' : 'FALSE'
|
||||
);
|
||||
$str = '';
|
||||
foreach($consdata as $ky => $vl) {
|
||||
foreach($constdata as $ky => $vl) {
|
||||
$str .= $ky . '=' . urlencode($vl) . '&';
|
||||
}
|
||||
$str .= (!empty($CFG->an_tran_key)) ?
|
||||
@@ -198,20 +198,8 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $
|
||||
|
||||
case AN_ACTION_VOID:
|
||||
{
|
||||
if ($order->status == AN_STATUS_AUTH) {
|
||||
if (authorize_expired($order)) {
|
||||
$message = "Authorized transaction must be voided within 30 days. EXPIRED!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
elseif ($order->status == AN_STATUS_AUTHCAPTURE or $order->status == AN_STATUS_CREDIT) {
|
||||
if (authorize_settled($order)) {
|
||||
$message = "Settled transaction cannot be voided. Check Cut-Off time!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$message = "Order status must be authorized/pending capture or captured-refunded/pending settlement!";
|
||||
if (authorize_expired($order) || authorize_settled($order)) {
|
||||
$message = "The transaction cannot be voided due to the fact that it is expired or settled.";
|
||||
return false;
|
||||
}
|
||||
$poststring .= '&x_type=VOID&x_trans_id=' . urlencode($order->transid);
|
||||
|
||||
Reference in New Issue
Block a user