add event payment.canceled

This commit is contained in:
Your Name
2021-06-22 00:37:38 +03:00
parent 643e2562a9
commit 6e57c66a83
2 changed files with 44 additions and 22 deletions

View File

@@ -82,34 +82,52 @@ function resultpay_kuri(){
$result = json_decode($source, true);
if (isset($result['event'])) {
if (isset($result['event'])) {
$shop_id = $result['object']['id'];
$find_sql = "SELECT `buy_id`, `delivery_id`, `number_id` FROM `anbuy` WHERE `shop_id` = '$shop_id' LIMIT 1";
$find_order = db_get($find_sql);
if (!isset($find_order['buy_id'])) {
return False;
}
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 ($result['event'] == "payment.succeeded"){
$currdate = date('Y-m-d H:i:s');
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']}'";
$supd = "
UPDATE
`anbuy`
SET
`buy_status` = '1',
`buy_active` = '1',
`date` = '$currdate'
WHERE
`buy_id` = '{$find_order['buy_id']}'";
$result = db_get($supd, 'chitatel'); // фисксируем что оплату получил
$result = db_get($supd, 'chitatel'); // фисксируем что оплату получил
}
# SELECT * FROM `price` WHERE `priceslug` = 'saturn-pod-priczelom-smersha';
elseif ( $result['event'] == "payment.canceled"){
if ($find_order['delivery_id'] > 1 ){ #физический товар возвращаем на место
$find_order = db_get("SELECT `pieces` FROM `price` WHERE `price_id` = '{$find_order['number_id']}'");
if (isset($find_order['pieces'])){
$newpieces = $find_order['pieces'] + 1;
$return_tovar = db_get("UPDATE `price` SET `pieces` = '$newpieces' WHERE `price_id` = '{$find_order['number_id']}'");
}
}
}
}
else {
echo "order not fount";
exit;

View File

@@ -188,8 +188,8 @@ function checkout_kuri($priceslug, $delivery_id = 1){
else { # заказ создался
if ( $delivery_id == 1 or ($_POST['pay_id']) == 1){
//уводим на оплату в Юкассу
if ( $delivery_id == 1){
//уводим на оплату онлайн в Юкассу
return anpay_kuri($order_id);
}
else { // даем пользователю номер заказа
@@ -199,6 +199,10 @@ function checkout_kuri($priceslug, $delivery_id = 1){
$pi_sql = "UPDATE `price` SET `pieces` = '$pieces' WHERE `price_id` = '{$price_id['price_id']}';";
$pi_res = db_get($pi_sql, 'chitatel');
if ($_POST['pay_id'] == 1){ # оплата на сайте
return anpay_kuri($order_id);
}
if (isset($add['buy_email'])) {
$message = "Ваш платеж ($price руб.) подтвержден. Номер заказа $order_id.\n