load_order($message); $payment_method = $order['PaymentMethod'] ? new nc_netshop_payment_method($order['PaymentMethod']) : null; $possible_payment_systems = $netshop->payment->get_enabled_methods()->where('handler_id', true); // Переход к оплате заказа показывается, если статус заказа — «Оформлен» или «Принят» // (при нестандартных статусах заказов потребуются соответствующие изменения в условии): $can_pay = ($f_Status_id == 0 || $f_Status_id == 1) && nc_module_check_by_keyword('payment', false) && count($possible_payment_systems) > 0; // Переход к оплате $payment_system_id = (int)$nc_core->input->fetch_post('payment_system_id'); if ($can_pay && $payment_system_id) { $invoice_statuses = array( nc_payment_invoice::STATUS_NEW, nc_payment_invoice::STATUS_SENT_TO_PAYMENT_SYSTEM, nc_payment_invoice::STATUS_CALLBACK_ERROR, ); $invoices = nc_payment::load_order_invoices($catalogue, 'netshop', $f_Message_ID) ->where_all(array( array('status', $invoice_statuses, 'IN'), array('amount', 0, '>'), )); if (count($invoices) > 0) { $invoice = $invoices[count($invoices) - 1]; } else { $invoice = new nc_payment_invoice(array( 'payment_system_id' => $payment_system_id, 'amount' => $order->get_totals(), 'description' => "Оплата заказа $f_Message_ID", 'currency' => $netshop->get_currency_code(), 'customer_id' => $AUTH_USER_ID, 'customer_name' => (string)$f_ContactName, 'customer_email' => (string)$f_Email, 'customer_phone' => (string)$f_Phone, 'order_source' => 'netshop', 'order_id' => $f_Message_ID, )); $invoice->save(); } $payment_url = nc_module_path('payment') . "pay_request.php?payment_system=$payment_system_id&invoice_id=" . $invoice->get_id(); while (ob_end_clean()) ; header("Location: $payment_url"); die; } $button_class = $f_Status_id == 2 || $f_Status_id == 5 ? "tpl-button-primary tpl-button-normal" : "tpl-button-secondary tpl-button-normal"; $inplace_payment = false; if ($f_Status_id == 3 || $f_Status_id == 4 || $f_Status_id == 5) { $status_paid_text = "Оплачен"; } elseif (($f_Status_id == null || $f_Status_id == 1 || $f_Status_id == 6) && ($payment_method["payment_on_delivery_cash"] == "1" || $payment_method["payment_on_delivery_card"] == "1") ) { $status_paid_text = "Оплата при получении"; } elseif ($f_Status_id == 2) { $status_paid_text = "Не оплачен"; } elseif ($payment_method["payment_on_delivery_cash"] == "0" || $payment_method["payment_on_delivery_card"] == "0" ) { $inplace_payment = true; $status_paid_text = "Не оплачен"; } else { $status_paid_text = ""; } ?>