robokassa.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. function curPageName()
  3. {
  4. return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
  5. }
  6. function exec_ogp_module()
  7. {
  8. global $db,$view,$settings;
  9. $cart_id = $_GET['cart_id'];
  10. if(!empty($cart_id))
  11. {
  12. $orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id );
  13. if( !empty( $orders ) )
  14. {
  15. $cart['price'] = 0;
  16. foreach($orders as $order)
  17. {
  18. if( $order['qty'] > 1 )
  19. $order['invoice_duration'] = $order['invoice_duration']."s";
  20. $cart['price'] += $order['price'];
  21. if( !isset( $cart['name'] ) )
  22. $cart['name'] = $order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
  23. else
  24. $cart['name'] .= ' + '.$order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
  25. }
  26. $total = $cart['price']+($settings['tax_amount']/100*$cart['price']);
  27. if ($total === 0)
  28. {
  29. $db->query("UPDATE " . $table_prefix . "billing_carts
  30. SET paid=1
  31. WHERE cart_id=".$cart_id);
  32. $view->refresh("home.php?m=billing&p=cart",0);
  33. }
  34. else
  35. {
  36. $mrh_login = $settings['robokassa_merchant_login']; // your login here
  37. $mrh_pass1 = $settings['robokassa_securepass1']; // merchant pass1 here
  38. // order properties
  39. $inv_id = $cart_id; // shop's invoice number
  40. // (unique for shop's lifetime)
  41. $inv_desc = urlencode($cart['name']); // invoice desc
  42. $out_summ = number_format( $total , 2 ); // invoice summ
  43. // build CRC value
  44. $crc = md5("$mrh_login:$out_summ:$inv_id:$mrh_pass1");
  45. // build URL
  46. $url = "https://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin=$mrh_login&".
  47. "OutSum=$out_summ&InvId=$inv_id&Desc=$inv_desc&SignatureValue=$crc";
  48. echo "<h2>".get_lang_f('redirecting_to',get_lang('robokassa'))."</h2>";
  49. echo "<img style='border:4px dotted white;background:black' src='modules/addonsmanager/loading.gif' width='180' height='180' /img>";
  50. echo '<meta HTTP-EQUIV="REFRESH" content="0; url='.$url.'">';
  51. }
  52. }
  53. }
  54. }
  55. ?>