_id}' WHERE `buy_id` = '{$buy_id['buy_id']}' "; db_get($upd_shop, 'chitatel'); # фиксируем shop_id от Юкассы header("Location: $pay_url"); // перенаправляем на оплату } } # получение результатов оплаты заказа function resultpay_kuri(){ $source = file_get_contents('php://input'); //$source = file_get_contents('/thosts/anpdf/app/tests/result.json'); $fjson = '/thosts/anpdf/app/tests/result.json'; file_put_contents($fjson, $source); // logsave('yk', $source); $result = json_decode($source, true); if (isset($result['event'])) { if ($result['event'] == "payment.succeeded"){ $shop_id = $result['object']['id']; $find_sql = "SELECT `buy_id` FROM `anbuy` WHERE `shop_id` = '$shop_id' LIMIT 1"; $find_order = db_get($find_sql); if (isset($find_order['buy_id'])) { $currdate = date('Y-m-d H:i:s'); $supd = " UPDATE `anbuy` SET `buy_status` = '1', `buy_active` = '1', `date` = '$currdate' WHERE `buy_id` = '{$find_order['buy_id']}'"; $result = db_get($supd, 'chitatel'); // фисксируем что оплату получил } } } else { echo "order not fount"; exit; } return True; } function yk_pay($price, $name, $return_url = ''){ if ($return_url == '') $return_url = SITE; $client = new Client(); $client->setAuth(YID, YKEY); $items = array( 'amount' => array( 'value' => 1.0, 'currency' => 'RUB', ), 'confirmation' => array( 'type' => 'redirect', 'return_url' => $return_url, ), 'capture' => true, 'description' => $name, ); $id = uniqid('', true); $payment = $client->createPayment( $items, $id ); return $payment; } #оповещаем письмом об успешном заказе function sendstatus_kuri(){ if (isset($find_order['client_id'])) { # получаем клиента $find_client = db_get("SELECT * FROM `clients` WHERE `client_id` = '{$find_order['client_id']}'"); if (isset($find_client['client_id'])){ # если удалось индефицировать клиента if ($find_order['delivery_id'] == 1) { #электронный платеж отправляем личный кабинет $message = "Ваш заказ выполнен. Он доступен в Вашем личном кабинете.\n Чтобы войти в кабинет перейдите по ссылке - ".SITE.'login'; $subject = "Аргументы Недели: заказ выполнен"; klanmail($find_order['clientmail'], $subject, $message, set('klanmail')); } else { $message = "Ваш платеж подтвержден. Номер заказа {find_order['order_id']}\n Сообщите его менеджеру при необходимостию"; $subject = "Аргументы Недели: платеж подтвержден"; klanmail($find_order['clientmail'], $subject, $message, set('klanmail')); } } } }