index.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. /*
  3. * Copayco user frontend
  4. */
  5. ///подключаем все требуемые либы
  6. require_once './incl/copayco.php';
  7. require_once '../../libs/api.openpayz.php';
  8. header('Content-Type: text/html; charset=utf-8');
  9. if (isset($_GET['customer_id'])) {
  10. $customer_id=vf($_GET['customer_id'],3);
  11. } else {
  12. die('customer_id fail');
  13. }
  14. $copConf= parse_ini_file("config/copayco.ini");
  15. $sTaId = 'opcop_'.round(microtime(true) * 100);
  16. $nAmount = @$_POST['pushamount'];
  17. $sCurrency = $copConf['CURRENCY'];
  18. $sDescription = $copConf['DESC'];
  19. $sLang = $copConf['LANG'];
  20. $sCustom = $customer_id;
  21. try {
  22. $oCop = copayco_api::instance();
  23. // Установка основных параметров
  24. $oCop->set_main_data($sTaId, $nAmount, $sCurrency);
  25. // Установка дополнительных параметров (если необходимо)
  26. $oCop->set_description($sDescription);
  27. $oCop->set_custom_field($sCustom);
  28. $oCop->set_language($sLang);
  29. $oCop->set_payment_mode(array('paycard', 'account','copayco','ecurrency','terminal','sms'));
  30. // Данные (в виде строки HTML-кода) для отображения формы способом 1
  31. $sFormFields_1 = $oCop->get_form_fields(
  32. array(
  33. 'ta_id' => array(
  34. 'type' => 'hidden',
  35. ),
  36. 'currency' => array(
  37. 'id' => 'currency1',
  38. ),
  39. ),
  40. "\n"
  41. );
  42. // URL (строка) для подстановки в тэг <form ...>
  43. $sSubmitUrl = $oCop->get_submit_url();
  44. $sException = NULL;
  45. } catch (copayco_exception $e) {
  46. $sException = print_r($e, true);
  47. }
  48. function copayco_AmountForm($copConf) {
  49. $result='<form action="" method="post">';
  50. $i=0;
  51. if (!empty($copConf['AMOUNTS'])) {
  52. $amounts= explode(',', $copConf['AMOUNTS']);
  53. foreach ($amounts as $each) {
  54. $i++;
  55. $checked = ($i==1) ? 'CHECKED' : '';
  56. $result.='<input name="pushamount" value="'.trim($each).'" type="radio" '.$checked.'> '.$each.' '.$copConf['CURRENCY'].'<br>'."\n";
  57. }
  58. } else {
  59. throw new Exception('EMPTY_AMOUNTS');
  60. }
  61. $result.='<br> <input type="submit">';
  62. $result.='</form>';
  63. return ($result);
  64. }
  65. ?>
  66. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  67. <html xmlns="http://www.w3.org/1999/xhtml">
  68. <head>
  69. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  70. <title>CoPAYCo</title>
  71. <link href="style.css" rel="stylesheet" type="text/css" media="screen" />
  72. </head>
  73. <body>
  74. <div id="wrapper">
  75. <div id="header" class="container">
  76. <div id="logo">
  77. <h1>CoPAYCo</h1>
  78. <p></p>
  79. </div>
  80. <div id="menu">
  81. </div>
  82. </div>
  83. <!-- end #header -->
  84. <div id="page" class="container">
  85. <div id="content">
  86. <div class="post">
  87. <div class="entry">
  88. <h3><?=$sDescription;?> <?=$customer_id;?> </h3> <br>
  89. <?php if (isset($_POST['pushamount'])) { ?>
  90. <h3>в размере <?=number_format($nAmount, 2)?> <?=$sCurrency?>.</h3>
  91. <form action="<?=$sSubmitUrl?>" method="post" target="_top" name="my_payment1" id="my_payment1">
  92. <?=$sFormFields_1?>
  93. <input type="submit"/>
  94. </form>
  95. <?php } else {
  96. print(copayco_AmountForm($copConf));
  97. }
  98. ?>
  99. </div>
  100. </div>
  101. <div style="clear: both;">&nbsp;</div>
  102. </div>
  103. <!-- end #content -->
  104. <div id="sidebar">
  105. <ul>
  106. <li>
  107. <!-- some logo here -->
  108. <img src="http://ubilling.net.ua/logo.png">
  109. </li>
  110. </ul>
  111. </div>
  112. <!-- end #sidebar -->
  113. <div style="clear: both;">&nbsp;</div>
  114. </div>
  115. <!-- end #page -->
  116. </div>
  117. <div id="footer-content" class="container">
  118. <div id="footer-bg">
  119. <div id="column1">
  120. Powered by <a href="http://ubilling.net.ua">OpenPayz</a>
  121. </div>
  122. <div id="column2">
  123. </div>
  124. <div id="column3">
  125. </div>
  126. </div>
  127. </div>
  128. <div id="footer">
  129. </div>
  130. <!-- end #footer -->
  131. </body>
  132. </html>