Помоги проекту

'textfield', '#title' => t('Amount'), '#default_value' => '500', '#size' => 10, '#maxlength' => 12, '#required' => TRUE ); $form['memo'] = array( '#type' => 'textarea', '#title' => t('Memo'), '#default_value' => t('Payment to !sitename', array('!sitename' => variable_get('site_name', 'Drupal'))), '#description' => t("Payment description."), '#required' => TRUE ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Cerate payment'), ); return $form; } function robokassa_prefillform_submit(&$form, $form_state){ $payment=_robokassa_createpayment(array( 'amount'=>$form_state['values']['amount'], 'memo'=>$form_state['values']['memo'], )); if(is_array($payment) && $payment['pid']>0){ drupal_set_message(t("Please confirm payment details")); drupal_goto('robokassa/payment/'.$payment['pid']); } } function robokassa_merchantform($form_state, $payment){ global $base_url,$user; if(!is_array($payment) && is_integer($payment)){ // fetch payment info from DB $payment=robokassa_pid_load($payment); } if(!is_array($payment) || !($payment['pid']>0)){ $form['error'] = array( '#type' => 'item', '#title' => t('Error'), '#value' => t('Order you are going to pay for does not exist'), ); }else{ $form['#action'] = variable_get('robokassa_payment_url', ROBOKASSA_MERCHANT_URL); // interface data: $form['payment_id'] = array( '#type' => 'item', '#title' => t('Order #'), '#value' => $payment['pid'], ); $form['amount'] = array( '#type' => 'item', '#title' => t('Amount'), '#value' => round($payment['amount'], 2), ); $form['memo'] = array( '#type' => 'item', '#title' => t('Memo'), '#value' => $payment['memo'] ); // merchant data... $form['MrchLogin'] = array( '#type' => 'hidden', '#value' => variable_get('robokassa_login', ''), ); $form['InvId'] = array( '#type' => 'hidden', '#value' => $payment['pid'], ); $form['Desc'] = array( '#type' => 'hidden', '#value' => $payment['memo'], ); $form['OutSum'] = array( '#type' => 'hidden', '#value' => round($payment['amount'], 2), ); $form['SignatureValue'] = array( '#type' => 'hidden', '#value' => md5(variable_get('robokassa_login', '').':'.round($payment['amount'], 2).':'.$payment['pid'].':'.variable_get('robokassa_secretkey', '')), ); $form['IncCurrLabel'] = array( '#type' => 'hidden', '#value' => variable_get('robokassa_default_currency', 'BANKOCEAN2R'), ); $form['Culture'] = array( '#type' => 'hidden', '#value' => 'ru', ); if (user_is_logged_in() && $user->mail) { $form['Email'] = array( '#type' => 'hidden', '#value' => $user->mail, ); } $form['submit'] = array( '#type' => 'submit', '#value' => t('Pay now'), ); } return $form; } function robokassa_success(){ return theme('robokassa_success'); } function robokassa_fail(){ return theme('robokassa_fail'); } function robokassa_status(){ global $base_path; drupal_set_header('Content-type: text/html; charset=iso-8859-1'); // check url $url=trim($_SERVER['REQUEST_URI'], '/'); $alias = trim($base_path . drupal_get_path_alias('robokassa/status'), '/'); if($url!=$alias){ die("bad sign"); } $created=time(); $out_summ = $_REQUEST["OutSum"]; $inv_id = $_REQUEST["InvId"]; $crc = $_REQUEST["SignatureValue"]; $crc = strtoupper($crc); $my_crc = strtoupper(md5("$out_summ:$inv_id:".variable_get('robokassa_secretkey2', ''))); if ($my_crc !=$crc || !preg_match("/^[0-9]{1,10}$/", $_REQUEST["InvId"])) { die("bad sign"); } $payment=robokassa_pid_load($_REQUEST["InvId"]); if(!is_array($payment)){ die("bad InvId"); } // check if payment already enrolled if($payment['enrolled']>0){ die("bad sign"); } if($_REQUEST["OutSum"]==round($payment['amount'], 2)){ // enroll payment $result = db_query('UPDATE {robokassa} SET enrolled=%d WHERE pid=%d', $created, $payment['pid']); // fire hook $payment['enrolled']=$created; module_invoke_all('robokassa', 'enrolled', $payment['pid'], $payment); die("OK$inv_id"); }else{ // you can also save invalid payments for debug purposes die(); } }
Поделитесь
Поделитесь
Вы подтверждаете удаление поста?
Этот пост используется в шапке на главной странице.
Его удаление повлечет за собой удаление шапок соответствущих страниц.
Вы подтверждаете удаление поста?