/** * onpay status * @link http://wiki.onpay.ru/doku.php?id=api-notify * @link http://wiki.onpay.ru/doku.php?id=payment-links-specs 2013/11/21 01:18:36 [info] [payment] IPN notification Array ( [type] => check [amount] => 100.0 [order_amount] => 100.0 [order_currency] => TST [pay_for] => 4932797 [md5] => B6C80B7F925CD99C1CC8B35AEE6F8630 ) 2013/11/21 01:33:39 [info] [payment] IPN notification Array ( [type] => check [amount] => 100.0 [order_amount] => 100.0 [order_currency] => TST [pay_for] => 4932797 [md5] => B6C80B7F925CD99C1CC8B35AEE6F8630 ) * 2013/11/21 01:39:59 [info] [payment] IPN notification Array ( [type] => pay [onpay_id] => 7261069 [amount] => 100.0 [balance_amount] => 100.0 [balance_currency] => TST [order_amount] => 100.0 [order_currency] => TST [exchange_rate] => 1.0 [pay_for] => 4932797 [paymentDateTime] => 2013-11-21T01:39:59+04:00 [user_email] => ivan5@iv-an.ru [user_phone] => [paid_amount] => 100.0 [md5] => 99C40DE7B5F231B7E54C59A06A8C0A1C ) * 2013/11/21 01:50:48 [info] [payment] IPN notification Array ( [type] => check [amount] => 100.0 [order_amount] => 100.0 [order_currency] => TST [pay_for] => 4932797 [md5] => B6C80B7F925CD99C1CC8B35AEE6F8630 ) * 2013/11/21 01:51:54 [info] [payment] IPN notification Array ( [type] => pay [onpay_id] => 7261103 [amount] => 100.0 [balance_amount] => 100.0 [balance_currency] => TST [order_amount] => 100.0 [order_currency] => TST [exchange_rate] => 1.0 [pay_for] => 4932797 [paymentDateTime] => 2013-11-21T01:51:54+04:00 [user_email] => ivan5@iv-an.ru [user_phone] => [paid_amount] => 100.0 [md5] => E1532BFA5BB6CA8511F17ECA6B8A1871 ) * 2013/11/21 02:22:17 [info] [payment] IPN notification Array ( [type] => check [amount] => 100.0 [order_amount] => 100.0 [order_currency] => TST [pay_for] => 4932797 [md5] => B6C80B7F925CD99C1CC8B35AEE6F8630 [code] => 0 [d_errors] => * 2013/11/21 02:22:25 [info] [payment] IPN notification Array ( [type] => pay [onpay_id] => 7261193 [amount] => 100.0 [balance_amount] => 100.0 [balance_currency] => TST [order_amount] => 100.0 [order_currency] => TST [exchange_rate] => 1.0 [pay_for] => 4932797 [paymentDateTime] => 2013-11-21T02:22:25+04:00 [user_email] => ivan5@iv-an.ru [user_phone] => [paid_amount] => 100.0 [md5] => 4A79BCEF6EC06764ACB973840ACAF863 * 2013/11/21 02:27:08 [info] [payment] IPN notification Array ( [type] => check [amount] => 100.0 [order_amount] => 100.0 [order_currency] => TST [pay_for] => 4932797 [md5] => B6C80B7F925CD99C1CC8B35AEE6F8630 [code] => 0 [d_errors] => ) * 2013/11/21 02:30:23 [info] [payment] IPN notification Array ( [type] => pay [onpay_id] => 7261210 [amount] => 100.0 [balance_amount] => 100.0 [balance_currency] => TST [order_amount] => 100.0 [order_currency] => TST [exchange_rate] => 1.0 [pay_for] => 4932797 [paymentDateTime] => 2013-11-21T02:30:22+04:00 [user_email] => ivan5@iv-an.ru [user_phone] => [paid_amount] => 100.0 [md5] => A79B7830ACE5269F076A1E1585CB07F8 */ public function actionOnpayStatus1() { /** @var $transaction Btransaction */ $data = $_POST; /* if (!$transaction = Btransaction::model()->findByPk($data['ik_payment_id'])) { $transaction = new Btransaction(); if (!preg_match('/(\d+)-(\d+)/',$data['ik_payment_id'],$matches)) { $data['alert'] = '!unhandled transaction'; Yii::log('WARNING! IPN notification '.print_r($data,true),'info','payment'); return; } $transaction->amount = $data['ik_payment_amount']; $transaction->id_user = $matches[1]; $transaction->id_operation = 1; $transaction->time_start = time(); } $transaction->amount_real = $data['ik_payment_amount']; $transaction->time_end = time(); $transaction->status = 1; $transaction->info = serialize($data); $transaction->description = 'Пополнение счета'; // прикрутить разбор "картой" $transaction->save(false); if ($user = $transaction->user) { $user->balance += $transaction->amount_real; $user->contact_count += floor($transaction->amount_real / 10); $user->saveAttributes(array('balance','contact_count')); //$user->con } */ Yii::import('ext.payment.*'); $onpay = new Onpay('other_db', 'atolin_ru', '3dNXOO4lPAN'); if ($onpay->check_errors($data)) { $data['code'] = 0; } else { if (empty($data['order_amount'])) { $data['code'] = 0; } else { $data['code'] = 2; } } $data['d_errors'] = $onpay->error; Yii::log('IPN notification ' . print_r($data, true), 'info', 'payment'); if ($data['type'] == 'pay') { $transaction = new Btransaction(); $transaction->amount = $data['order_amount']; $transaction->id_user = $data['pay_for']; $transaction->id_operation = 1; $transaction->time_start = time(); $transaction->amount_real = $data['order_amount']; $transaction->time_end = time(); $transaction->status = 1; $transaction->info = serialize($data); $transaction->description = 'Пополнение счета'; // прикрутить разбор "картой" $transaction->save(false); if ($user = $transaction->user) { $user->balance += $transaction->amount_real; $user->contact_count += floor($transaction->amount_real / 10); $user->saveAttributes(array('balance', 'contact_count')); } } echo $onpay->gen_xml_answer($data); /* $code = 0; $keys = array( 'type' => $data['type'] == 'pay' ? 'pay' : 'check', // 'pay_for'=>$data['pay_for'], 'order_amount'=>$data['order_amount'], 'order_ticker'=>$data['order_currency'], 'code'=>$code, 'secret_key_for_api_in'=>'3dNXOO4lPAN', ); // md5 - проверка ответа // check “type;pay_for;order_amount;order_ticker;secret_key_for_api_in” // pay “type;pay_for;onpay_id;order_amount;order_ticker;secret_key_for_api_in” // “type;pay_for;order_amount;order_ticker;code;secret_key_api_in” (без кавычек) // “type;pay_for;onpay_id;order_id;order_amount;order_ticker;code;secret_key_api_in” $md5 = implode(';',$keys); $md5 = md5($md5); echo '<?xml version="1.0" encoding="UTF-8"?> <result> <code>'.$code.'</code> <pay_for>'.$data['pay_for'].'</pay_for> <comment>OK</comment> <md5>'.$md5.'</md5> </result>';*/ }
* @author norgen * @version 1.0 * @namespace Onpay */ /* * Если пришли данные формы, подключаем класс Onpay, создаем экземпляр класса * и инициализируем его. */ require_once 'onpay.class/onpay.class.php'; //Данные авторизации в Onpay $onpay_form = 'norgen'; $onpay_key = '1231233211'; //Работаем с внутренней базой класса. $mode = 'internal_db'; // Создаем экземпляр класса Onpay и включаем отладку. $opy = new Onpay($mode, $onpay_form, $onpay_key); $opy->debug = true; // Если запрос содержит параметр type - перехватываем его и отправляем в процессор. // По всей вероятности это запрос от Onpay, дальнейшая валидация параметров производится классом. if (isset($_REQUEST['type'])) { if ($opy->process_onpay($_REQUEST)) { //Заказ успешно оплачлен, Onpay передан корректный XML, статус заказа сменен на "оплачено" можно что-то сделать //в пользовательском скрипте, например отправить email администратору/пользователю и прервать выполнение скрипта. exit; } else { //Есть какие-то ошибки, которые в данном примере передаются в onpay. Лучшим вариантом было бы отправить их //администратору или записать в лог. echo $opy->error; exit; } }