title: Cashu Payment Gateway
body: <p>hi all I have a website and I want to add Cashu Payment Gateway . to the users can buy >
  this is my files for payment </p>
  
  <p>Payment_manage.php
      
  
  <pre><code>include("../include/config.php");
  include_once("../include/functions/import.php");
  verify_login_admin();
  $adminurl = $config['adminurl'];
  
  function insert_get_trans_id($a)
  {
      global $conn;
      $query = "select txn_id, memo from paypal_table where id='".mysql_real_escape_string($a[id])."'"; 
      $executequery=$conn-&gt;execute($query);
      $results = $conn-&gt;execute($query);
      $returnthis = $results-&gt;getrows();
      return $returnthis;
  }
  
  if($_REQUEST['sortby']=="OID")
  {
      $sortby = "OID";
      $sort =" order by A.OID";
      $add1 = "&amp;sortby=OID";
  }
  elseif($_REQUEST['sortby']=="username")
  {
      $sortby = "username";
      $sort =" order by B.username";
      $add1 = "&amp;sortby=username";
  }
  elseif($_REQUEST['sortby']=="time")
  {
      $sortby = "time";
      $sort =" order by A.time";
      $add1 = "&amp;sortby=time";
  }
  elseif($_REQUEST['sortby']=="PAYPAL")
  {
      $sortby = "PAYPAL";
      $sort =" order by A.PAYPAL";
      $add1 = "&amp;sortby=PAYPAL";
  }
  else
  {
      $sortby = "ID";
      $sort =" order by A.ID";
      $add1 = "&amp;sortby=ID";
  }
  
  if($_REQUEST['sorthow']=="asc")
  {
      $sorthow ="asc";
      $add1 .= "&amp;sorthow=asc";
  }
  else
  {
      $sorthow ="desc";
      $add1 .= "&amp;sorthow=desc";
  }
  
  //Search
  $fromid = intval($_REQUEST['fromid']);
  $toid = intval($_REQUEST['toid']);
  $OID = htmlentities(strip_tags($_REQUEST['OID']), ENT_COMPAT, "UTF-8");
  $username = htmlentities(strip_tags($_REQUEST['username']), ENT_COMPAT, "UTF-8");
  $add1 .= "&amp;fromid=$fromid&amp;toid=$toid&amp;OID=$OID&amp;username=$username";
  if($_POST['submitform'] == "1" || ($_REQUEST['fromid']!="" || $toid&gt;0 || $OID!="" || $username!=""))
  {
      if($fromid &gt; 0)
      {
          $addtosql = "AND A.ID&gt;='".mysql_real_escape_string($fromid)."'";
          Stemplate::assign('fromid',$fromid);
      }
      else
      {
          $addtosql = "AND A.ID&gt;'".mysql_real_escape_string($fromid)."'";
      }
      if($toid &gt; 0)
      {
          $addtosql .= "AND A.ID&lt;='".mysql_real_escape_string($toid)."'";
          Stemplate::assign('toid',$toid);
      }
      if($OID != "")
      {
          $addtosql .= "AND A.OID='".mysql_real_escape_string($OID)."'";
          Stemplate::assign('OID',$OID);
      }
      if($username != "")
      {
          $addtosql .= "AND B.username like'%".mysql_real_escape_string($username)."%'";
          Stemplate::assign('username',$username);
      }
      Stemplate::assign('search',"1");
  }
  //Search End
  
  $page = intval($_REQUEST['page']);
  if($page=="")
  {
      $page = "1";
  }
  $currentpage = $page;
  
  if ($page &gt;=2)
  {
      $pagingstart = ($page-1)*$config['items_per_page'];
  }
  else
  {
      $pagingstart = "0";
  }
  
  $queryselected = "select A.ID,B.username from payments A, members B WHERE A.ID&gt;0 AND A.USERID=B.USERID $addtosql $sort $sorthow limit $config[maximum_results]";
  $query2 = "select A.*,B.username from payments A, members B WHERE A.ID&gt;0 AND A.USERID=B.USERID $addtosql $sort $sorthow limit $pagingstart, $config[items_per_page]";
  $executequeryselected = $conn-&gt;Execute($queryselected);
  $totalposts = $executequeryselected-&gt;rowcount();    
  if ($totalposts &gt; 0)
  {
      if($totalposts&lt;=$config[maximum_results])
      {
          $total = $totalposts;
      }
      else
      {
          $total = $config[maximum_results];
      }
      $toppage = ceil($total/$config[items_per_page]);
      if($toppage==0)
      {
          $xpage=$toppage+1;
      }
      else
      {
          $xpage = $toppage;
      }
      $executequery2 = $conn-&gt;Execute($query2);   
      $results = $executequery2-&gt;getrows();
      $beginning=$pagingstart+1;
      $ending=$pagingstart+$executequery2-&gt;recordcount();
      $pagelinks="";
      $k=1;
      $theprevpage=$currentpage-1;
      $thenextpage=$currentpage+1;
      if ($currentpage &gt; 0)
      {   
          if($currentpage &gt; 1) 
          {
              $pagelinks.="&lt;a href='$adminurl/payments_manage.php?page=1$add1' title='first page'&gt;First&lt;/a&gt;&amp;nbsp;";
              $pagelinks.="&lt;a href='$adminurl/payments_manage.php?page=$theprevpage$add1'&gt;Previous&lt;/a&gt;&amp;nbsp;";
          };
          $counter=0;
          $lowercount = $currentpage-5;
          if ($lowercount &lt;= 0) $lowercount = 1;
          while ($lowercount &lt; $currentpage)
          {
              $pagelinks.="&lt;a href='$adminurl/payments_manage.php?page=$lowercount$add1'&gt;$lowercount&lt;/a&gt;&amp;nbsp;";
              $lowercount++;
              $counter++;
          }
          $pagelinks.=$currentpage."&amp;nbsp;";
          $uppercounter = $currentpage+1;
          while (($uppercounter &lt; $currentpage+10-$counter) &amp;&amp; ($uppercounter&lt;=$toppage))
          {
              $pagelinks.="&lt;a href='$adminurl/payments_manage.php?page=$uppercounter$add1'&gt;$uppercounter&lt;/a&gt;&amp;nbsp;";
              $uppercounter++;
          }
          if($currentpage &lt; $toppage) 
          {
              $pagelinks.="&lt;a href='$adminurl/payments_manage.php?page=$thenextpage$add1'&gt;Next&lt;/a&gt;&amp;nbsp;";
              $pagelinks.="&lt;a href='$adminurl/payments_manage.php?page=$toppage$add1' title='last page'&gt;Last&lt;/a&gt;&amp;nbsp;";
          };
      }
  }
  else
  {
      $error = "Sorry, no payments were found.";
  }
  
  $mainmenu = "6";
  $submenu = "1";
  Stemplate::assign('mainmenu',$mainmenu);
  Stemplate::assign('submenu',$submenu);
  Stemplate::assign('sorthow',$sorthow);
  Stemplate::assign('sortby',$sortby);
  Stemplate::assign('currentpage',$currentpage);
  STemplate::display("administrator/global_header.tpl");
  STemplate::assign('beginning',$beginning);
  STemplate::assign('ending',$ending);
  STemplate::assign('pagelinks',$pagelinks);
  STemplate::assign('total',$total+0);
  STemplate::assign('results',$results);
  Stemplate::assign('error',$error);
  STemplate::display("administrator/payments_manage.tpl");
  STemplate::display("administrator/global_footer.tpl");
  ?&gt;
  </code></pre>
  
  <p>payment_featured.php</p>
  
  <pre><code>&lt;?php
  
  include("../include/config.php");
  include_once("../include/functions/import.php");
  verify_login_admin();
  $adminurl = $config['adminurl'];
  
  function insert_get_trans_id($a)
  {
      global $conn;
      $query = "select txn_id, memo from paypal_table2 where id='".mysql_real_escape_string($a[id])."'"; 
      $executequery=$conn-&gt;execute($query);
      $results = $conn-&gt;execute($query);
      $returnthis = $results-&gt;getrows();
      return $returnthis;
  }
  
  if($_REQUEST['sortby']=="OID")
  {
      $sortby = "OID";
      $sort =" order by A.PID";
      $add1 = "&amp;sortby=OID";
  }
  elseif($_REQUEST['sortby']=="username")
  {
      $sortby = "username";
      $sort =" order by B.username";
      $add1 = "&amp;sortby=username";
  }
  elseif($_REQUEST['sortby']=="time")
  {
      $sortby = "time";
      $sort =" order by A.time";
      $add1 = "&amp;sortby=time";
  }
  elseif($_REQUEST['sortby']=="PAYPAL")
  {
      $sortby = "PAYPAL";
      $sort =" order by A.PAYPAL";
      $add1 = "&amp;sortby=PAYPAL";
  }
  else
  {
      $sortby = "ID";
      $sort =" order by A.ID";
      $add1 = "&amp;sortby=ID";
  }
  
  if($_REQUEST['sorthow']=="asc")
  {
      $sorthow ="asc";
      $add1 .= "&amp;sorthow=asc";
  }
  else
  {
      $sorthow ="desc";
      $add1 .= "&amp;sorthow=desc";
  }
  
  //Search
  $fromid = intval($_REQUEST['fromid']);
  $toid = intval($_REQUEST['toid']);
  $OID = htmlentities(strip_tags($_REQUEST['OID']), ENT_COMPAT, "UTF-8");
  $username = htmlentities(strip_tags($_REQUEST['username']), ENT_COMPAT, "UTF-8");
  $add1 .= "&amp;fromid=$fromid&amp;toid=$toid&amp;OID=$OID&amp;username=$username";
  if($_POST['submitform'] == "1" || ($_REQUEST['fromid']!="" || $toid&gt;0 || $OID!="" || $username!=""))
  {
      if($fromid &gt; 0)
      {
          $addtosql = "AND A.ID&gt;='".mysql_real_escape_string($fromid)."'";
          Stemplate::assign('fromid',$fromid);
      }
      else
      {
          $addtosql = "AND A.ID&gt;'".mysql_real_escape_string($fromid)."'";
      }
      if($toid &gt; 0)
      {
          $addtosql .= "AND A.ID&lt;='".mysql_real_escape_string($toid)."'";
          Stemplate::assign('toid',$toid);
      }
      if($OID != "")
      {
          $addtosql .= "AND A.PID='".mysql_real_escape_string($OID)."'";
          Stemplate::assign('OID',$OID);
      }
      if($username != "")
      {
          $addtosql .= "AND B.username like'%".mysql_real_escape_string($username)."%'";
          Stemplate::assign('username',$username);
      }
      Stemplate::assign('search',"1");
  }
  //Search End
  
  $page = intval($_REQUEST['page']);
  if($page=="")
  {
      $page = "1";
  }
  $currentpage = $page;
  
  if ($page &gt;=2)
  {
      $pagingstart = ($page-1)*$config['items_per_page'];
  }
  else
  {
      $pagingstart = "0";
  }
  
  $queryselected = "select A.ID,B.username, C.gtitle from featured A, members B, posts C WHERE A.ID&gt;0 AND A.PID=C.PID AND C.USERID=B.USERID $addtosql $sort $sorthow limit $config[maximum_results]";
  $query2 = "select A.*,B.username, C.gtitle from featured A, members B, posts C WHERE A.ID&gt;0 AND A.PID=C.PID AND C.USERID=B.USERID $addtosql $sort $sorthow limit $pagingstart, $config[items_per_page]";
  $executequeryselected = $conn-&gt;Execute($queryselected);
  $totalposts = $executequeryselected-&gt;rowcount();    
  if ($totalposts &gt; 0)
  {
      if($totalposts&lt;=$config[maximum_results])
      {
          $total = $totalposts;
      }
      else
      {
          $total = $config[maximum_results];
      }
      $toppage = ceil($total/$config[items_per_page]);
      if($toppage==0)
      {
          $xpage=$toppage+1;
      }
      else
      {
          $xpage = $toppage;
      }
      $executequery2 = $conn-&gt;Execute($query2);   
      $results = $executequery2-&gt;getrows();
      $beginning=$pagingstart+1;
      $ending=$pagingstart+$executequery2-&gt;recordcount();
      $pagelinks="";
      $k=1;
      $theprevpage=$currentpage-1;
      $thenextpage=$currentpage+1;
      if ($currentpage &gt; 0)
      {   
          if($currentpage &gt; 1) 
          {
              $pagelinks.="&lt;a href='$adminurl/payments_featured.php?page=1$add1' title='first page'&gt;First&lt;/a&gt;&amp;nbsp;";
              $pagelinks.="&lt;a href='$adminurl/payments_featured.php?page=$theprevpage$add1'&gt;Previous&lt;/a&gt;&amp;nbsp;";
          };
          $counter=0;
          $lowercount = $currentpage-5;
          if ($lowercount &lt;= 0) $lowercount = 1;
          while ($lowercount &lt; $currentpage)
          {
              $pagelinks.="&lt;a href='$adminurl/payments_featured.php?page=$lowercount$add1'&gt;$lowercount&lt;/a&gt;&amp;nbsp;";
              $lowercount++;
              $counter++;
          }
          $pagelinks.=$currentpage."&amp;nbsp;";
          $uppercounter = $currentpage+1;
          while (($uppercounter &lt; $currentpage+10-$counter) &amp;&amp; ($uppercounter&lt;=$toppage))
          {
              $pagelinks.="&lt;a href='$adminurl/payments_featured.php?page=$uppercounter$add1'&gt;$uppercounter&lt;/a&gt;&amp;nbsp;";
              $uppercounter++;
          }
          if($currentpage &lt; $toppage) 
          {
              $pagelinks.="&lt;a href='$adminurl/payments_featured.php?page=$thenextpage$add1'&gt;Next&lt;/a&gt;&amp;nbsp;";
              $pagelinks.="&lt;a href='$adminurl/payments_featured.php?page=$toppage$add1' title='last page'&gt;Last&lt;/a&gt;&amp;nbsp;";
          };
      }
  }
  else
  {
      $error = "There are no payments yet.";
  }
  
  $mainmenu = "6";
  $submenu = "1";
  Stemplate::assign('mainmenu',$mainmenu);
  Stemplate::assign('submenu',$submenu);
  Stemplate::assign('sorthow',$sorthow);
  Stemplate::assign('sortby',$sortby);
  Stemplate::assign('currentpage',$currentpage);
  STemplate::display("administrator/global_header.tpl");
  STemplate::assign('beginning',$beginning);
  STemplate::assign('ending',$ending);
  STemplate::assign('pagelinks',$pagelinks);
  STemplate::assign('total',$total+0);
  STemplate::assign('results',$results);
  Stemplate::assign('error',$error);
  STemplate::display("administrator/payments_featured.tpl");
  STemplate::display("administrator/global_footer.tpl");
  ?&gt;
  </code></pre>
  
  <p>payment_clear.php</p>
  
  <pre><code>&lt;?php
  
  include("../include/config.php");
  include_once("../include/functions/import.php");
  verify_login_admin();
  $adminurl = $config['adminurl'];
  
  //CLEAR
  if($_POST['asub']=="1")
  {
      $AID = intval($_POST['AID']);
      $aseller = intval($_POST['aseller']);
      $apay = number_format($_POST['apay'], 2);
      if($AID &gt; 0 &amp;&amp; $aseller &gt; 0 &amp;&amp; $apay &gt; 0)
      {
          $sql="UPDATE payments SET wd='1' WHERE ID='".mysql_real_escape_string($AID)."'";
          $conn-&gt;Execute($sql);
          $sql="UPDATE members SET afunds=afunds+$apay WHERE USERID='".mysql_real_escape_string($aseller)."'";
          $conn-&gt;Execute($sql);
          $message = "Payment successfully cleared.";
          Stemplate::assign('message',$message);
      }
  }
  //CLEAR
  
  function insert_get_trans_id($a)
  {
      global $conn;
      $query = "select txn_id, memo from paypal_table where id='".mysql_real_escape_string($a[id])."'"; 
      $executequery=$conn-&gt;execute($query);
      $results = $conn-&gt;execute($query);
      $returnthis = $results-&gt;getrows();
      return $returnthis;
  }
  
  if($_REQUEST['sortby']=="OID")
  {
      $sortby = "OID";
      $sort =" order by A.OID";
      $add1 = "&amp;sortby=OID";
  }
  elseif($_REQUEST['sortby']=="username")
  {
      $sortby = "username";
      $sort =" order by B.username";
      $add1 = "&amp;sortby=username";
  }
  elseif($_REQUEST['sortby']=="time")
  {
      $sortby = "time";
      $sort =" order by A.time";
      $add1 = "&amp;sortby=time";
  }
  elseif($_REQUEST['sortby']=="PAYPAL")
  {
      $sortby = "PAYPAL";
      $sort =" order by A.PAYPAL";
      $add1 = "&amp;sortby=PAYPAL";
  }
  else
  {
      $sortby = "ID";
      $sort =" order by A.ID";
      $add1 = "&amp;sortby=ID";
  }
  
  if($_REQUEST['sorthow']=="asc")
  {
      $sorthow ="asc";
      $add1 .= "&amp;sorthow=asc";
  }
  else
  {
      $sorthow ="desc";
      $add1 .= "&amp;sorthow=desc";
  }
  
  //Search
  $fromid = intval($_REQUEST['fromid']);
  $toid = intval($_REQUEST['toid']);
  $OID = htmlentities(strip_tags($_REQUEST['OID']), ENT_COMPAT, "UTF-8");
  $username = htmlentities(strip_tags($_REQUEST['username']), ENT_COMPAT, "UTF-8");
  $add1 .= "&amp;fromid=$fromid&amp;toid=$toid&amp;OID=$OID&amp;username=$username";
  if($_POST['submitform'] == "1" || ($_REQUEST['fromid']!="" || $toid&gt;0 || $OID!="" || $username!=""))
  {
      if($fromid &gt; 0)
      {
          $addtosql = "AND A.ID&gt;='".mysql_real_escape_string($fromid)."'";
          Stemplate::assign('fromid',$fromid);
      }
      else
      {
          $addtosql = "AND A.ID&gt;'".mysql_real_escape_string($fromid)."'";
      }
      if($toid &gt; 0)
      {
          $addtosql .= "AND A.ID&lt;='".mysql_real_escape_string($toid)."'";
          Stemplate::assign('toid',$toid);
      }
      if($OID != "")
      {
          $addtosql .= "AND A.OID='".mysql_real_escape_string($OID)."'";
          Stemplate::assign('OID',$OID);
      }
      if($username != "")
      {
          $addtosql .= "AND B.username like'%".mysql_real_escape_string($username)."%'";
          Stemplate::assign('username',$username);
      }
      Stemplate::assign('search',"1");
  }
  //Search End
  
  $page = intval($_REQUEST['page']);
  if($page=="")
  {
      $page = "1";
  }
  $currentpage = $page;
  
  if ($page &gt;=2)
  {
      $pagingstart = ($page-1)*$config['items_per_page'];
  }
  else
  {
      $pagingstart = "0";
  }
  
  $queryselected = "select D.ctp, A.ID,B.username, C.cltime, D.USERID as seller from payments A, members B, orders C, posts D WHERE D.PID=C.PID AND A.OID=C.OID AND C.status='5' AND A.cancel='0' AND A.wd='0' AND A.ID&gt;0 AND D.USERID=B.USERID $addtosql $sort $sorthow limit $config[maximum_results]";
  $query2 = "select D.ctp, A.*,B.username, C.cltime, C.IID, D.USERID as seller from payments A, members B, orders C, posts D WHERE D.PID=C.PID AND A.OID=C.OID AND C.status='5' AND A.cancel='0' AND A.wd='0' AND A.ID&gt;0 AND D.USERID=B.USERID $addtosql $sort $sorthow limit $pagingstart, $config[items_per_page]";
  $executequeryselected = $conn-&gt;Execute($queryselected);
  $totalposts = $executequeryselected-&gt;rowcount();    
  if ($totalposts &gt; 0)
  {
      if($totalposts&lt;=$config[maximum_results])
      {
          $total = $totalposts;
      }
      else
      {
          $total = $config[maximum_results];
      }
      $toppage = ceil($total/$config[items_per_page]);
      if($toppage==0)
      {
          $xpage=$toppage+1;
      }
      else
      {
          $xpage = $toppage;
      }
      $executequery2 = $conn-&gt;Execute($query2);   
      $results = $executequery2-&gt;getrows();
      $beginning=$pagingstart+1;
      $ending=$pagingstart+$executequery2-&gt;recordcount();
      $pagelinks="";
      $k=1;
      $theprevpage=$currentpage-1;
      $thenextpage=$currentpage+1;
      if ($currentpage &gt; 0)
      {   
          if($currentpage &gt; 1) 
          {
              $pagelinks.="&lt;a href='$adminurl/payments_clear.php?page=1$add1' title='first page'&gt;First&lt;/a&gt;&amp;nbsp;";
              $pagelinks.="&lt;a href='$adminurl/payments_clear.php?page=$theprevpage$add1'&gt;Previous&lt;/a&gt;&amp;nbsp;";
          };
          $counter=0;
          $lowercount = $currentpage-5;
          if ($lowercount &lt;= 0) $lowercount = 1;
          while ($lowercount &lt; $currentpage)
          {
              $pagelinks.="&lt;a href='$adminurl/payments_clear.php?page=$lowercount$add1'&gt;$lowercount&lt;/a&gt;&amp;nbsp;";
              $lowercount++;
              $counter++;
          }
          $pagelinks.=$currentpage."&amp;nbsp;";
          $uppercounter = $currentpage+1;
          while (($uppercounter &lt; $currentpage+10-$counter) &amp;&amp; ($uppercounter&lt;=$toppage))
          {
              $pagelinks.="&lt;a href='$adminurl/payments_clear.php?page=$uppercounter$add1'&gt;$uppercounter&lt;/a&gt;&amp;nbsp;";
              $uppercounter++;
          }
          if($currentpage &lt; $toppage) 
          {
              $pagelinks.="&lt;a href='$adminurl/payments_clear.php?page=$thenextpage$add1'&gt;Next&lt;/a&gt;&amp;nbsp;";
              $pagelinks.="&lt;a href='$adminurl/payments_clear.php?page=$toppage$add1' title='last page'&gt;Last&lt;/a&gt;&amp;nbsp;";
          };
      }
  }
  else
  {
      $error = "No payments are ready to be cleared yet";
  }
  
  $mainmenu = "6";
  $submenu = "2";
  Stemplate::assign('mainmenu',$mainmenu);
  Stemplate::assign('submenu',$submenu);
  Stemplate::assign('sorthow',$sorthow);
  Stemplate::assign('sortby',$sortby);
  Stemplate::assign('currentpage',$currentpage);
  STemplate::display("administrator/global_header.tpl");
  STemplate::assign('beginning',$beginning);
  STemplate::assign('ending',$ending);
  STemplate::assign('pagelinks',$pagelinks);
  STemplate::assign('total',$total+0);
  STemplate::assign('results',$results);
  Stemplate::assign('error',$error);
  STemplate::display("administrator/payments_clear.tpl");
  STemplate::display("administrator/global_footer.tpl");
  ?&gt;
  </code></pre>
  
  <p>I thing those for paypal > I wanted be for paypal and cashU . to eneyone can buy from he want.</p>
  
  <p>and thanks .</p>