Не работает оплата в приложении

Обсуждение и помощь по вопросам взаимодействия с ВКонтакте API в IFrame-приложениях (JavaScript, PHP и т.д)
stepan05
Сообщения: 146
Зарегистрирован: 15 авг 2012, 09:43

Не работает оплата в приложении

Сообщение stepan05 »

Привет всем, такая проблема, когда покупаю валюту в приложении например за 1 голос. Жму оплатить и мне после долгой оплаты пишет: Мы ожидаем подтверждение от приложения. Если оно не будет получено в течение часа, голоса будут возвращены на Ваш счёт. Через 1 час голос возвратился. Пробовал несколько раз и толку 0. Скажите как решить эту проблему?
Casperovskii
Сообщения: 429
Зарегистрирован: 22 июн 2012, 17:50

Re: Не работает оплата в приложении

Сообщение Casperovskii »

Сразу вопрос: ваше приложение или нет?
Если не ваше - то никак. Если ваше - то смотреть, что за скрипт отвечает за оплату и ответ серверу.
stepan05
Сообщения: 146
Зарегистрирован: 15 авг 2012, 09:43

Re: Не работает оплата в приложении

Сообщение stepan05 »

приложение мое. Тестовая оплата для тестеров работает. Все зачисляется
Вот логи платежей:

Код: Выделить всё

05:27:45    Рабочий  Ответ  null05:27:44    Рабочий  Запрос    app_id=2020942&date=1387243269&item=item9&item_id=9&item_photo_url=https://dod-apps.ru/all/img/piar_order.png&item_price=1&item_title=Место в vip-блоке&notification_type=order_status_change&order_id=7844322&receiver_id=199871311&status=chargeable&user_id=19987131105:27:12    Тестовый    Ответ  {"response":{"order_id":385703, "app_order_id":"489"}}05:27:12    Тестовый    Запрос    app_id=2020942&date=1387243624&item=item4&item_id=4&item_photo_url=https://dod-apps.ru/all/img/sheet_order.png&item_price=50&item_title=250 золота&notification_type=order_status_change_test&order_id=385703&receiver_id=214402965&status=chargeable&user_id=214402965
Casperovskii
Сообщения: 429
Зарегистрирован: 22 июн 2012, 17:50

Re: Не работает оплата в приложении

Сообщение Casperovskii »

stepan05
А что мне с логов то? Как видишь сам: рабочий ответ null. М.б. сам обработчик не заточен под рабочие ответы?
stepan05
Сообщения: 146
Зарегистрирован: 15 авг 2012, 09:43

Re: Не работает оплата в приложении

Сообщение stepan05 »

вот файл payment, то есть путь оплаты:

Код: Выделить всё

<?phpheader("Content-Type: application/json; encoding=utf-8");  $secret_key = 'тут мой ключ'; // Защищенный ключ приложения require 'init.php'; $input = $_POST;  // Проверка подписи $sig = $input['sig']; unset($input['sig']); ksort($input); $str = ''; foreach ($input as $k => $v) {   $str .= $k.'='.$v; } $input['item'] = addslashes($input['item']);$input['item'] = htmlspecialchars($input['item']);$input['item'] = mysql_escape_string($input['item']); $input['notification_type'] = addslashes($input['notification_type']);$input['notification_type'] = htmlspecialchars($input['notification_type']);$input['notification_type'] = mysql_escape_string($input['notification_type']); $input['status'] = addslashes($input['status']);$input['status'] = htmlspecialchars($input['status']);$input['status'] = mysql_escape_string($input['status']); $server = "https://dod-apps.ru/all/img/";  if ($sig != md5($str.$secret_key)) {   $response['error'] = array(     'error_code' => 10,     'error_msg' => 'Несовпадение вычисленной и переданной подписи запроса.',     'critical' => true   ); } else {   if(!mysql_connect($db_host,$db_user,$db_pass)) exit('not_connect');  mysql_select_db($db_name);  // Подпись правильная   switch ($input['notification_type']) {     case 'get_item_test':       // Получение информации о товаре       $item = $input['item']; // наименование товара        if ($item == 'item1') {         $response['response'] = array(           'item_id' => 1,           'title' => '30 золота',           'photo_url' => $server.'sheet_order.png',           'price' => 1         );       } elseif ($item == 'item2') {         $response['response'] = array(           'item_id' => 2,           'title' => '100 золота',           'photo_url' => $server.'sheet_order.png',           'price' => 3         );       } elseif ($item == 'item3') {         $response['response'] = array(           'item_id' => 3,           'title' => '400 золота',           'photo_url' => $server.'sheet_order.png',           'price' => 10         );       } elseif ($item == 'item4') {         $response['response'] = array(           'item_id' => 4,           'title' => '2500 золота',           'photo_url' => $server.'sheet_order.png',           'price' => 50         );       } elseif ($item == 'item5') {         $response['response'] = array(           'item_id' => 5,           'title' => '300 морковок',           'photo_url' => $server.'drop_order.png',           'price' => 1        );       } elseif ($item == 'item6') {         $response['response'] = array(           'item_id' => 6,           'title' => 'Акция! 1500 морковок',           'photo_url' => $server.'drop_order.png',           'price' => 3         );       } elseif ($item == 'item7') {         $response['response'] = array(           'item_id' => 7,           'title' => '4000 морковок',           'photo_url' => $server.'drop_order.png',           'price' => 10         );       } elseif ($item == 'item8') {         $response['response'] = array(           'item_id' => 8,           'title' => '25000 морковок',           'photo_url' => $server.'drop_order.png',           'price' => 50         );       } elseif ($item == 'item9') {         $response['response'] = array(           'item_id' => 9,           'title' => 'Место в vip-блоке',           'photo_url' => $server.'piar_order.png',           'price' => 1         );       } else {         $response['error'] = array(           'error_code' => 20,           'error_msg' => 'Товара не существует.',           'critical' => true         );       }      $q = "INSERT INTO `buys`(`order_id`,`user_id`,`status`,`date`) VALUES(".intval($input['order_id']).",".intval($input['user_id']).",0,".time().")";      mysql_query($q);      break; case 'get_item':       // Получение информации о товаре в тестовом режиме       $item = $input['item']; // наименование товара        if ($item == 'item1') {         $response['response'] = array(           'item_id' => 1,           'title' => '30 золота',           'photo_url' => 'https://dod-apps.ru/all/img/sheet_order.png',           'price' => 1         );       } elseif ($item == 'item2') {         $response['response'] = array(           'item_id' => 2,           'title' => '100 золота',           'photo_url' => 'https://dod-apps.ru/all/img/sheet_order.png',           'price' => 3         );       } elseif ($item == 'item3') {         $response['response'] = array(           'item_id' => 3,           'title' => '400 золота',           'photo_url' => 'https://dod-apps.ru/all/img/sheet_order.png',           'price' => 10         );       } elseif ($item == 'item4') {         $response['response'] = array(           'item_id' => 4,           'title' => '2500 золота',           'photo_url' => 'https://dod-apps.ru/all/img/sheet_order.png',           'price' => 50         );       } elseif ($item == 'item5') {         $response['response'] = array(           'item_id' => 5,           'title' => '300 морковок',           'photo_url' => 'https://dod-apps.ru/all/img/drop_order.png',           'price' => 1        );       } elseif ($item == 'item6') {         $response['response'] = array(           'item_id' => 6,           'title' => 'Акция! 1500 морковок',           'photo_url' => 'https://dod-apps.ru/all/img/drop_order.png',           'price' => 3         );       } elseif ($item == 'item7') {         $response['response'] = array(           'item_id' => 7,           'title' => '4000 морковок',           'photo_url' => 'https://dod-apps.ru/all/img/drop_order.png',           'price' => 10         );       } elseif ($item == 'item8') {         $response['response'] = array(           'item_id' => 8,           'title' => '25000 морковок',           'photo_url' => 'https://dod-apps.ru/all/img/drop_order.png',           'price' => 50         );       } elseif ($item == 'item9') {         $response['response'] = array(           'item_id' => 9,           'title' => 'Место в vip-блоке',           'photo_url' => 'https://dod-apps.ru/all/img/piar_order.png',           'price' => 1         );       } else {         $response['error'] = array(           'error_code' => 20,           'error_msg' => 'Товара не существует.',           'critical' => true         );       }      $q = "INSERT INTO `buys`(`order_id`,`user_id`,`status`,`date`) VALUES(".intval($input['order_id']).",".intval($input['user_id']).",0,".time().")";      mysql_query($q);      break;/*case 'order_status_change':       // Изменение статуса заказа       if ($input['status'] == 'chargeable') {         $order_id = intval($input['order_id']);         $user_id = intval($input['user_id']);        $item = $input['item'];        $item_price = intval($input['item_price']);                $prices = array(1,3,10,50,1,3,10,50,1);        for($i=1;$i<10;$i++) {            if($item == 'item'.$i && $item_price != $prices[$i-1]) {                $response['error'] = array(                     'error_code' => 21,                     'error_msg' => 'Неверная цена товара.',                     'critical' => true                 );                break;            }        }       $q = "SELECT * FROM `buys` WHERE `order_id` = ".$order_id." AND `user_id` = ".$user_id;       $res = mysql_query($q);       if(mysql_num_rows($res) == 0) {           $response['error'] = array(                  'error_code' => 22,                  'error_msg' => 'Нет такого заказа',                  'critical' => true             );            break;       }              $arr = array(array(1,'sheets',30),array(3,'sheets',100),array(10,'sheets',400),array(50,'sheets',2500),               array(1,'drops',300),array(3,'drops',1500),array(10,'drops',4000),array(50,'drops',25000),               array(1));                      $itt = intval(substr($item,4,2));       $f = mysql_fetch_array($res);       if($f['status'] == 0 && $itt != 9) {            $q = "UPDATE `users` SET `".$arr[$itt-1][1]."` = ".$arr[$itt-1][1]."+".$arr[$itt-1][2].",`spent_votes` = spent_votes+".$arr[$itt-1][0]." WHERE `uid` = ".$user_id;            mysql_query($q);            $q = "UPDATE `buys` SET `status` = 1 WHERE `order_id` = ".$order_id;            mysql_query($q);       }        if($itt == 9) {            $q = "INSERT INTO `vip_place`(`uid`,`time`) VALUES(".$user_id.",".time().")";            mysql_query($q);            $q = "UPDATE `users` SET `drops` = drops + 50 WHERE `uid` = ".$user_id;            mysql_query($q);       }                    $app_order_id = $f['app_order_id']; // Получающийся у вас идентификатор заказа.        $response['response'] = array(           'order_id' => $order_id,           'app_order_id' => $app_order_id,         );       } else {         $response['error'] = array(           'error_code' => 100,           'error_msg' => 'Передано непонятно что вместо chargeable.',           'critical' => true         );       }       break; */ case 'order_status_change_test':       // Изменение статуса заказа       if ($input['status'] == 'chargeable') {         $order_id = intval($input['order_id']);         $user_id = intval($input['user_id']);        $item = $input['item'];        $item_price = intval($input['item_price']);                $prices = array(1,3,10,50,1,3,10,50,1);        for($i=1;$i<10;$i++) {            if($item == 'item'.$i && $item_price != $prices[$i-1]) {                $response['error'] = array(                     'error_code' => 21,                     'error_msg' => 'Неверная цена товара.',                     'critical' => true                 );                break;            }        }       $q = "SELECT * FROM `buys` WHERE `order_id` = ".$order_id." AND `user_id` = ".$user_id;       $res = mysql_query($q);       if(mysql_num_rows($res) == 0) {           $response['error'] = array(                  'error_code' => 22,                  'error_msg' => 'Нет такого заказа',                  'critical' => true             );            break;       }              $arr = array(array(1,'sheets',30),array(3,'sheets',100),array(10,'sheets',400),array(50,'sheets',2500),               array(1,'drops',300),array(3,'drops',1500),array(10,'drops',4000),array(50,'drops',25000),               array(1));                      $itt = intval(substr($item,4,2));       $f = mysql_fetch_array($res);       if($f['status'] == 0 && $itt != 9) {            $q = "UPDATE `users` SET `".$arr[$itt-1][1]."` = ".$arr[$itt-1][1]."+".$arr[$itt-1][2].",`spent_votes` = spent_votes+".$arr[$itt-1][0]." WHERE `uid` = ".$user_id;            mysql_query($q);            $q = "UPDATE `buys` SET `status` = 1 WHERE `order_id` = ".$order_id;            mysql_query($q);       }        if($itt == 9) {            $q = "INSERT INTO `vip_place`(`uid`,`time`) VALUES(".$user_id.",".time().")";            mysql_query($q);            $q = "UPDATE `users` SET `drops` = drops + 50 WHERE `uid` = ".$user_id;            mysql_query($q);       }                    $app_order_id = $f['app_order_id']; // Получающийся у вас идентификатор заказа.        $response['response'] = array(           'order_id' => $order_id,           'app_order_id' => $app_order_id,         );       } else {         $response['error'] = array(           'error_code' => 100,           'error_msg' => 'Передано непонятно что вместо chargeable.',           'critical' => true         );       }       break;  } }  echo json_encode($response); ?> 
Casperovskii
Сообщения: 429
Зарегистрирован: 22 июн 2012, 17:50

Re: Не работает оплата в приложении

Сообщение Casperovskii »

stepan05
Ну дак ясен хрен - форма order_status_change почему-то закомменчена. А для тестогового юзверя - нет. Почему бы ей и не работать?..
stepan05
Сообщения: 146
Зарегистрирован: 15 авг 2012, 09:43

Re: Не работает оплата в приложении

Сообщение stepan05 »

раскоментировал строку, теперь не работает оплата. пишет: Ваш запрос не был обработан. Попробуйте повторить его позднее.
Casperovskii
Сообщения: 429
Зарегистрирован: 22 июн 2012, 17:50

Re: Не работает оплата в приложении

Сообщение Casperovskii »

Строку? 0_о Там же ЦЕЛЫЙ БЛОК в комментарий внесен. Не тупи!
stepan05
Сообщения: 146
Зарегистрирован: 15 авг 2012, 09:43

Re: Не работает оплата в приложении

Сообщение stepan05 »

Сделал, тоже самое:

Код: Выделить всё

<?phpheader("Content-Type: application/json; encoding=utf-8");  $secret_key = 'MhqurKEulfOVEYwvBQi1'; // Защищенный ключ приложения require 'init.php'; $input = $_POST;  // Проверка подписи $sig = $input['sig']; unset($input['sig']); ksort($input); $str = ''; foreach ($input as $k => $v) {   $str .= $k.'='.$v; } $input['item'] = addslashes($input['item']);$input['item'] = htmlspecialchars($input['item']);$input['item'] = mysql_escape_string($input['item']); $input['notification_type'] = addslashes($input['notification_type']);$input['notification_type'] = htmlspecialchars($input['notification_type']);$input['notification_type'] = mysql_escape_string($input['notification_type']); $input['status'] = addslashes($input['status']);$input['status'] = htmlspecialchars($input['status']);$input['status'] = mysql_escape_string($input['status']); $server = "https://dod-apps.ru/all/img/";  if ($sig != md5($str.$secret_key)) {   $response['error'] = array(     'error_code' => 10,     'error_msg' => 'Несовпадение вычисленной и переданной подписи запроса.',     'critical' => true   ); } else {   if(!mysql_connect($db_host,$db_user,$db_pass)) exit('not_connect');  mysql_select_db($db_name);  // Подпись правильная   switch ($input['notification_type']) {     case 'get_item_test':       // Получение информации о товаре       $item = $input['item']; // наименование товара        if ($item == 'item1') {         $response['response'] = array(           'item_id' => 1,           'title' => '30 золота',           'photo_url' => $server.'sheet_order.png',           'price' => 1         );       } elseif ($item == 'item2') {         $response['response'] = array(           'item_id' => 2,           'title' => '100 золота',           'photo_url' => $server.'sheet_order.png',           'price' => 3         );       } elseif ($item == 'item3') {         $response['response'] = array(           'item_id' => 3,           'title' => '400 золота',           'photo_url' => $server.'sheet_order.png',           'price' => 10         );       } elseif ($item == 'item4') {         $response['response'] = array(           'item_id' => 4,           'title' => '2500 золота',           'photo_url' => $server.'sheet_order.png',           'price' => 50         );       } elseif ($item == 'item5') {         $response['response'] = array(           'item_id' => 5,           'title' => '300 морковок',           'photo_url' => $server.'drop_order.png',           'price' => 1        );       } elseif ($item == 'item6') {         $response['response'] = array(           'item_id' => 6,           'title' => 'Акция! 1500 морковок',           'photo_url' => $server.'drop_order.png',           'price' => 3         );       } elseif ($item == 'item7') {         $response['response'] = array(           'item_id' => 7,           'title' => '4000 морковок',           'photo_url' => $server.'drop_order.png',           'price' => 10         );       } elseif ($item == 'item8') {         $response['response'] = array(           'item_id' => 8,           'title' => '25000 морковок',           'photo_url' => $server.'drop_order.png',           'price' => 50         );       } elseif ($item == 'item9') {         $response['response'] = array(           'item_id' => 9,           'title' => 'Место в vip-блоке',           'photo_url' => $server.'piar_order.png',           'price' => 1         );       } else {         $response['error'] = array(           'error_code' => 20,           'error_msg' => 'Товара не существует.',           'critical' => true         );       }      $q = "INSERT INTO `buys`(`order_id`,`user_id`,`status`,`date`) VALUES(".intval($input['order_id']).",".intval($input['user_id']).",0,".time().")";      mysql_query($q);      break; case 'get_item':       // Получение информации о товаре в тестовом режиме       $item = $input['item']; // наименование товара        if ($item == 'item1') {         $response['response'] = array(           'item_id' => 1,           'title' => '30 золота',           'photo_url' => 'https://dod-apps.ru/all/img/sheet_order.png',           'price' => 1         );       } elseif ($item == 'item2') {         $response['response'] = array(           'item_id' => 2,           'title' => '100 золота',           'photo_url' => 'https://dod-apps.ru/all/img/sheet_order.png',           'price' => 3         );       } elseif ($item == 'item3') {         $response['response'] = array(           'item_id' => 3,           'title' => '400 золота',           'photo_url' => 'https://dod-apps.ru/all/img/sheet_order.png',           'price' => 10         );       } elseif ($item == 'item4') {         $response['response'] = array(           'item_id' => 4,           'title' => '2500 золота',           'photo_url' => 'https://dod-apps.ru/all/img/sheet_order.png',           'price' => 50         );       } elseif ($item == 'item5') {         $response['response'] = array(           'item_id' => 5,           'title' => '300 морковок',           'photo_url' => 'https://dod-apps.ru/all/img/drop_order.png',           'price' => 1        );       } elseif ($item == 'item6') {         $response['response'] = array(           'item_id' => 6,           'title' => 'Акция! 1500 морковок',           'photo_url' => 'https://dod-apps.ru/all/img/drop_order.png',           'price' => 3         );       } elseif ($item == 'item7') {         $response['response'] = array(           'item_id' => 7,           'title' => '4000 морковок',           'photo_url' => 'https://dod-apps.ru/all/img/drop_order.png',           'price' => 10         );       } elseif ($item == 'item8') {         $response['response'] = array(           'item_id' => 8,           'title' => '25000 морковок',           'photo_url' => 'https://dod-apps.ru/all/img/drop_order.png',           'price' => 50         );       } elseif ($item == 'item9') {         $response['response'] = array(           'item_id' => 9,           'title' => 'Место в vip-блоке',           'photo_url' => 'https://dod-apps.ru/all/img/piar_order.png',           'price' => 1         );       } else {         $response['error'] = array(           'error_code' => 20,           'error_msg' => 'Товара не существует.',           'critical' => true         );       }      $q = "INSERT INTO `buys`(`order_id`,`user_id`,`status`,`date`) VALUES(".intval($input['order_id']).",".intval($input['user_id']).",0,".time().")";      mysql_query($q);      break; case 'order_status_change':       // Изменение статуса заказа       if ($input['status'] == 'chargeable') {         $order_id = intval($input['order_id']);         $user_id = intval($input['user_id']);        $item = $input['item'];        $item_price = intval($input['item_price']);                $prices = array(1,3,10,50,1,3,10,50,1);        for($i=1;$i<10;$i++) {            if($item == 'item'.$i && $item_price != $prices[$i-1]) {                $response['error'] = array(                     'error_code' => 21,                     'error_msg' => 'Неверная цена товара.',                     'critical' => true                 );                break;            }        }       $q = "SELECT * FROM `buys` WHERE `order_id` = ".$order_id." AND `user_id` = ".$user_id;       $res = mysql_query($q);       if(mysql_num_rows($res) == 0) {           $response['error'] = array(                  'error_code' => 22,                  'error_msg' => 'Нет такого заказа',                  'critical' => true             );            break;       }              $arr = array(array(1,'sheets',30),array(3,'sheets',100),array(10,'sheets',400),array(50,'sheets',2500),               array(1,'drops',300),array(3,'drops',1500),array(10,'drops',4000),array(50,'drops',25000),               array(1));                      $itt = intval(substr($item,4,2));       $f = mysql_fetch_array($res);       if($f['status'] == 0 && $itt != 9) {            $q = "UPDATE `users` SET `".$arr[$itt-1][1]."` = ".$arr[$itt-1][1]."+".$arr[$itt-1][2].",`spent_votes` = spent_votes+".$arr[$itt-1][0]." WHERE `uid` = ".$user_id;            mysql_query($q);            $q = "UPDATE `buys` SET `status` = 1 WHERE `order_id` = ".$order_id;            mysql_query($q);       }        if($itt == 9) {            $q = "INSERT INTO `vip_place`(`uid`,`time`) VALUES(".$user_id.",".time().")";            mysql_query($q);            $q = "UPDATE `users` SET `drops` = drops + 50 WHERE `uid` = ".$user_id;            mysql_query($q);       }                    $app_order_id = $f['app_order_id']; // Получающийся у вас идентификатор заказа.        $response['response'] = array(           'order_id' => $order_id,           'app_order_id' => $app_order_id,         );       } else {         $response['error'] = array(           'error_code' => 100,           'error_msg' => 'Передано непонятно что вместо chargeable.',           'critical' => true         );       }       break; */ case 'order_status_change_test':       // Изменение статуса заказа       if ($input['status'] == 'chargeable') {         $order_id = intval($input['order_id']);         $user_id = intval($input['user_id']);        $item = $input['item'];        $item_price = intval($input['item_price']);                $prices = array(1,3,10,50,1,3,10,50,1);        for($i=1;$i<10;$i++) {            if($item == 'item'.$i && $item_price != $prices[$i-1]) {                $response['error'] = array(                     'error_code' => 21,                     'error_msg' => 'Неверная цена товара.',                     'critical' => true                 );                break;            }        }       $q = "SELECT * FROM `buys` WHERE `order_id` = ".$order_id." AND `user_id` = ".$user_id;       $res = mysql_query($q);       if(mysql_num_rows($res) == 0) {           $response['error'] = array(                  'error_code' => 22,                  'error_msg' => 'Нет такого заказа',                  'critical' => true             );            break;       }              $arr = array(array(1,'sheets',30),array(3,'sheets',100),array(10,'sheets',400),array(50,'sheets',2500),               array(1,'drops',300),array(3,'drops',1500),array(10,'drops',4000),array(50,'drops',25000),               array(1));                      $itt = intval(substr($item,4,2));       $f = mysql_fetch_array($res);       if($f['status'] == 0 && $itt != 9) {            $q = "UPDATE `users` SET `".$arr[$itt-1][1]."` = ".$arr[$itt-1][1]."+".$arr[$itt-1][2].",`spent_votes` = spent_votes+".$arr[$itt-1][0]." WHERE `uid` = ".$user_id;            mysql_query($q);            $q = "UPDATE `buys` SET `status` = 1 WHERE `order_id` = ".$order_id;            mysql_query($q);       }        if($itt == 9) {            $q = "INSERT INTO `vip_place`(`uid`,`time`) VALUES(".$user_id.",".time().")";            mysql_query($q);            $q = "UPDATE `users` SET `drops` = drops + 50 WHERE `uid` = ".$user_id;            mysql_query($q);       }                    $app_order_id = $f['app_order_id']; // Получающийся у вас идентификатор заказа.        $response['response'] = array(           'order_id' => $order_id,           'app_order_id' => $app_order_id,         );       } else {         $response['error'] = array(           'error_code' => 100,           'error_msg' => 'Передано непонятно что вместо chargeable.',           'critical' => true         );       }       break;  } }  echo json_encode($response); ?> 
stepan05
Сообщения: 146
Зарегистрирован: 15 авг 2012, 09:43

Re: Не работает оплата в приложении

Сообщение stepan05 »

аа все сделал, спасибо за помощь!
Ответить