|
|
@@ -257,15 +257,33 @@ class BxPaymentSubscriptions extends BxBaseModPaymentSubscriptions
|
|
|
|
|
|
return $mixedResult;
|
|
|
}
|
|
|
-
|
|
|
- public function serviceCancel($sOrder)
|
|
|
+
|
|
|
+ public function serviceCancel($sOrder, $bForce = true)
|
|
|
{
|
|
|
$aPending = $this->_oModule->_oDb->getOrderPending(['type' => 'order', 'order' => $sOrder]);
|
|
|
if(empty($aPending) || !is_array($aPending))
|
|
|
return ['code' => 1, 'message' => _t('_bx_payment_err_not_found_pending')];
|
|
|
-
|
|
|
+
|
|
|
+ if(!(bool)$bForce && ($mixedResult = $this->_oModule->isAllowedManage($aPending)) !== true)
|
|
|
+ return ['code' => 2, 'message' => $mixedResult];
|
|
|
+
|
|
|
+ if(!$this->cancel((int)$aPending['id']))
|
|
|
+ return ['code' => 3, 'message' => _t('_bx_payment_err_cannot_perform')];
|
|
|
+
|
|
|
+ return ['code' => 0, 'message' => _t('_bx_payment_msg_successfully_performed')];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function serviceCancelByPendingId($iId, $bForce = true)
|
|
|
+ {
|
|
|
+ $aPending = $this->_oModule->_oDb->getOrderPending(['type' => 'id', 'id' => $iId]);
|
|
|
+ if(empty($aPending) || !is_array($aPending))
|
|
|
+ return ['code' => 1, 'message' => _t('_bx_payment_err_not_found_pending')];
|
|
|
+
|
|
|
+ if(!(bool)$bForce && ($mixedResult = $this->_oModule->isAllowedManage($aPending)) !== true)
|
|
|
+ return ['code' => 2, 'message' => $mixedResult];
|
|
|
+
|
|
|
if(!$this->cancel((int)$aPending['id']))
|
|
|
- return ['code' => 2, 'message' => _t('_bx_payment_err_cannot_perform')];
|
|
|
+ return ['code' => 3, 'message' => _t('_bx_payment_err_cannot_perform')];
|
|
|
|
|
|
return ['code' => 0, 'message' => _t('_bx_payment_msg_successfully_performed')];
|
|
|
}
|