add anpay

This commit is contained in:
Your Name
2021-06-20 18:20:21 +03:00
parent d328ffa7b0
commit 099e0be8f5
6 changed files with 219 additions and 26 deletions

View File

@@ -5,19 +5,13 @@
* оформление заказа
*/
function checkout_kuri($priceslug, $buy_type = 1){
function checkout_kuri($priceslug, $delivery_id = 1){
$price_id = db_get("SELECT * FROM `price` WHERE `priceslug` = '$priceslug' LIMIT 1");
if (isset($price_id['price_id'])) {
if ($buy_type == 1){ // тип товара
if ($delivery_id == 1){ // тип товара
$price = $price_id['price']; // электронная книжка
}
else {
@@ -30,7 +24,7 @@ function checkout_kuri($priceslug, $buy_type = 1){
$client = client_find_id(CLIENT_ID);
if (isset($client['result']['client_id'])){
$clienthash = $client['result']['clienthash'];
$client = $client['result'];
}
}
@@ -43,16 +37,42 @@ function checkout_kuri($priceslug, $buy_type = 1){
$error_mail = True;
}
else {
# получаем хэш клиента чтобы отправить на оплату
$clienthash = api_add_client($clientmail);
# ищем или создаем клиента
$client = api_add_client($clientmail);
}
}
if (isset($clienthash) and $clienthash) {
$paylink = PAYSITE."anpay/$priceslug/$clienthash";
header("Location: $paylink");
return True;
if (isset($client['client_id'])) {
#создаем заказ
$add['client_id'] = $client['client_id'];
$add['buy_email'] = $client['clientmail'];
$add['buy_price'] = $price;
$add['price'] = $price;
$add['buy_status'] = 0;
$add['mail_status'] = 0;
$add['number_id'] = $price_id['price_id'];
$add['pay_id'] = 3; // оплата через Юкассу
$add['delivery_id'] = $delivery_id;
$add['date_start'] = date('Y-m-d H:i:s');
$add['buy_active'] = 0;
$order_id = db_insert('anbuy', $add, 'chitatel'); // добавляем в базу заказ
if (is_array($order_id)){ // неудалось создать заказ
$error_mail = True;
}
else { // заказ создался
return anpay_kuri($order_id);
}
}
@@ -61,9 +81,9 @@ function checkout_kuri($priceslug, $buy_type = 1){
$error_price = True;
}
$submit_link = SITE."checkout/$priceslug/$buy_type";
$submit_link = SITE."checkout/$priceslug/$buy_type";
include VIEWPATH.'checkout.phtml';
include VIEWPATH.'checkout.phtml';
}
}