onSalePayOrder event
This commit is contained in:
parent
05bd2807fd
commit
0fc3b0d3df
@ -141,5 +141,55 @@ class ICrmOrderEvent {
|
||||
ICrmOrderActions::eventLog('ICrmOrderEvent::onSaleCancelOrder', 'IntaroCrm\RestApi::orderEdit', $api->getLastError());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type $ID -- orderId
|
||||
* @param type $payed -- Y / N - pay order status
|
||||
* @return boolean
|
||||
*/
|
||||
function onSalePayOrder($ID, $payed) {
|
||||
if(!$ID || !$payed || ($payed != 'Y'))
|
||||
return true;
|
||||
|
||||
if (!CModule::IncludeModule('iblock')) {
|
||||
//handle err
|
||||
ICrmOrderActions::eventLog('ICrmOrderEvent::onSalePayOrder', 'iblock', 'module not found');
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!CModule::IncludeModule("sale")) {
|
||||
//handle err
|
||||
ICrmOrderActions::eventLog('ICrmOrderEvent::onSalePayOrder', 'sale', 'module not found');
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!CModule::IncludeModule("catalog")) {
|
||||
//handle err
|
||||
ICrmOrderActions::eventLog('ICrmOrderEvent::onSalePayOrder', 'catalog', 'module not found');
|
||||
return true;
|
||||
}
|
||||
|
||||
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||
|
||||
//saved cat params
|
||||
$optionsPayment = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT, 0));
|
||||
|
||||
$api = new IntaroCrm\RestApi($api_host, $api_key);
|
||||
|
||||
$order = array(
|
||||
'externalId' => (int) $ID,
|
||||
'paymentStatus' => $optionsPayment[$payed]
|
||||
);
|
||||
|
||||
$api->orderEdit($order);
|
||||
|
||||
// error pushing order
|
||||
if ($api->getStatusCode() != 201)
|
||||
ICrmOrderActions::eventLog('ICrmOrderEvent::onSalePayOrder', 'IntaroCrm\RestApi::orderEdit', $api->getLastError());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -372,8 +372,11 @@ class intaro_intarocrm extends CModule
|
||||
} else if ($step == 4) {
|
||||
|
||||
RegisterModule($this->MODULE_ID);
|
||||
|
||||
RegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder");
|
||||
RegisterModuleDependences("sale", "OnSalePayOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSalePayOrder");
|
||||
|
||||
|
||||
//agent
|
||||
$dateAgent = new DateTime();
|
||||
$intAgent = new DateInterval('PT60S'); // PT60S - 60 sec;
|
||||
@ -417,6 +420,8 @@ class intaro_intarocrm extends CModule
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES);
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT);
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_LAST_ID);
|
||||
|
||||
UnRegisterModuleDependences("sale", "OnSalePayOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSalePayOrder");
|
||||
UnRegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder");
|
||||
|
||||
$this->DeleteFiles();
|
||||
|
Loading…
Reference in New Issue
Block a user