onSalePayOrder event
This commit is contained in:
parent
05bd2807fd
commit
0fc3b0d3df
@ -142,4 +142,54 @@ class ICrmOrderEvent {
|
|||||||
|
|
||||||
return true;
|
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,7 +372,10 @@ class intaro_intarocrm extends CModule
|
|||||||
} else if ($step == 4) {
|
} else if ($step == 4) {
|
||||||
|
|
||||||
RegisterModule($this->MODULE_ID);
|
RegisterModule($this->MODULE_ID);
|
||||||
|
|
||||||
RegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder");
|
RegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder");
|
||||||
|
RegisterModuleDependences("sale", "OnSalePayOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSalePayOrder");
|
||||||
|
|
||||||
|
|
||||||
//agent
|
//agent
|
||||||
$dateAgent = new DateTime();
|
$dateAgent = new DateTime();
|
||||||
@ -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_STATUSES);
|
||||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT);
|
COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT);
|
||||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_LAST_ID);
|
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");
|
UnRegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder");
|
||||||
|
|
||||||
$this->DeleteFiles();
|
$this->DeleteFiles();
|
||||||
|
Loading…
Reference in New Issue
Block a user