Создаю модуль, нужно дабавить php библиотеку. Модуль интеграцыи по API, пользуюсь хуком actionPaymentConfirmation, мне нужно что б после оплаты страбаывал скрипт отправки данних, и почему не работають в хуке стандарные функцыи php
public function actionPaymentConfirmation($params)
{
include_once '../orangedata_client.php';
if (!$params['id_order'])
{
return;
}
global $cookie;
$customer123 = new Customer((int)$cookie->id_customer);
$customerInfo123 = $customer123->getAddresses((int)$cookie->id_lang);
$order123 = new Order((int)($this->id_order));
$products1 = $order123->getProducts();
$cart_sum = $order123->getOrdersTotalPaid();
$payment1 = $order123->getOrderPayments();
$order_detail123 = OrderDetail::getList((int)($this->id_order));
$countProductNamed = count($order_detail);
$orderOrangeData = [];
for($i = 0; $i < $countProductNamed; $i++ )
{
$orderOrangeData[] = (array) [
'quantity' => (int)$order_detail123[$i]["product_quantity"],
'price' => (float)$order_detail123[$i]["unit_price_tax_incl"],
'tax' => 6,
'text' => substr( $order_detail123[$i]["product_name"], 0, 127),
'paymentMethodType' => 4,
'paymentSubjectType' => 1,
'nomenclatureCode' => $order_detail123[$i]["product_reference"],
'unitOfMeasurement' => 'pcs'
];
}
$paymentOrangeData = (array)[
'type' => 16,
'amount' => (float)$payment1[0]->amount
];
try {
$client = [
'inn' => '471205789168',
'api_url' => '2443',
// 'api_url' => 'https://apip.orangedata.ru:2443', // link access
'sign_pkey' => dirname(__DIR__) . '/secure_path/private_key.pem',
'ssl_client_key' => dirname(__DIR__) . '/secure_path/client.key',
'ssl_client_crt' => dirname(__DIR__) . '/secure_path/client.crt',
'ssl_ca_cert' => dirname(__DIR__) . '/secure_path/cacert.pem',
'ssl_client_crt_pass' => 1234,
];
$buyer = new orangedata\orangedata_client($client); // create new client
// $buyer->is_debug(); // for write curl.log file
$order = [
'id' => $params['id_order'],
'type' => 1,
'customerContact' => $customerInfo[0]["phone_mobile"],
'taxationSystem' => 2,
'key' => '471205789168',
];
$position = $orderOrangeData;
$payment = $paymentOrangeData ;
$additional = [
'customer' => $customerInfo123[0]["firstname"]." ".$customerInfo123[0]["lastname"]
];
$vending = [
'automatNumber' => '21321321123',
'settlementAddress' => 'Address',
'settlementPlace' => 'Place',
];
/** Create client new order **/
$buyer->create_order($order)
->add_position_to_order($position)
->add_payment_to_order($payment)
->add_agent_to_order($agent)
->add_user_attribute($userAttribute)
->add_additional_attributes($additional)
->add_vending_to_order($vending);
$result = $buyer->send_order(); // Send order
var_dump($result); // View response
} catch (Exception $ex) {
echo 'Errors:' . PHP_EOL . $ex->getMessage();
}
/** View status of order **/
try {
$order_status = $buyer->get_order_status(23423423434);
var_dump($order_status);
} catch (Exception $ex) {
echo 'Ошибка:' . PHP_EOL . $ex->getMessage();
}
}
}
|