sandip123 Posted May 30, 2018 Share Posted May 30, 2018 Hi, Need a help in upgrading the gateway on our website , Total amount in Old code : <input type=hidden name='i_amount' value='<?= $tot_amount*10000; ?>'> New code : <?php require './gate.php'; $fields = new gate( array( user_code' => 'ALMXX', 'pass_code' => 'ALM$1XXX21#', 'hash_key' => 'AQW23T5XXX87XC47', 'tran_id' => 'ALMCXX' .time(), 'amount' => '00..00', Note : In this field the amount needs to be dynamic like in the old code using $tot_amount . How do we do that 'charge_code' => 'AZ', )); ?> Quote Link to comment https://forums.phpfreaks.com/topic/307323-need-help-with-our-payment-gateway/ Share on other sites More sharing options...
requinix Posted May 30, 2018 Share Posted May 30, 2018 If it's not as simple as putting the variable there then you aren't giving us enough information to know the answer. Quote Link to comment https://forums.phpfreaks.com/topic/307323-need-help-with-our-payment-gateway/#findComment-1558659 Share on other sites More sharing options...
NotionCommotion Posted May 30, 2018 Share Posted May 30, 2018 Total guess, but give this a try. $fields = new gate( array( //... 'amount' => $_POST['i_amount']*10000, //... )); Quote Link to comment https://forums.phpfreaks.com/topic/307323-need-help-with-our-payment-gateway/#findComment-1558661 Share on other sites More sharing options...
sandip123 Posted May 30, 2018 Author Share Posted May 30, 2018 Thank you for your reply guys I have attached the entire code , please see if you can help Commented the start of the new code and old code <? session_start(); include('includes/connection.php'); include("header.php"); include("menu.php"); $tot_amount=base64_decode($_REQUEST['total_value']); $paypal_currency=$_SESSION['paypal_currency']; $item_name=$_SESSION['service']." , ".$_SESSION['name']; ?> <div class="flash"><img src="images/flash_pic.png" width="964" height="328" /></div> <div class="middle"> <div style="width:98%; margin:10px; border:1px #CCC solid; height:auto; background-color:#f0f0f0; vertical-align:middle; -moz-border-radius: 10px;-webkit-border-radius: 10px; border-radius: 10px; float:left;" align="center"> <div style="width:94%; margin:17px; border:1px #CCC solid; height:auto; background-color:#fff; padding:10px; "> <table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr> <td colspan="3" style="font-family:Verdana, Geneva, sans-serif; font-size:20px; text-align:left; color:#5185ad; border-bottom:solid 1px #CCe; padding-bottom:7px;"> <strong>Payment Option</strong> </td> </tr> <tr> <td align="left" valign="middle" colspan="2" height="20" style="font-family:Arial, Helvetica, sans-serif; color:#000; font-size:20px; padding-top:5px; padding-bottom:7px; font-weight:bold;">Proceed To Secured Payment : </td> <td align="center" valign="middle"> <!--OLD CODE--> <!--<form target="_new" method="post" action="#"> <form target="_new" method="post" action="#"> <input type=hidden name='i_name' value='<?= $item_name; ?>'> <input type=hidden name='i_amount' value='<?= $tot_amount*10000; ?>'> <input type="hidden" name="currency_code" value="356"/> <input type="hidden" name="merchant_reference_no" value='<?= date("mdyhis"); ?>'> <input type="hidden" name="perform" value="initiatePaymentCapture#sale" /> <INPUT TYPE="image" SRC="images/pay.png" height="67" width="195"> </form>--> <br /><br /> <!--NEW CODE--> <?php require './gate.php'; $fields = new gate( array( 'user_code' => 'ALMXX', 'pass_code' => 'ALM$1XXX21#', 'hash_key' => 'AQW23T5XXX87XC47', 'tran_id' => 'ALMCXX' .time(), 'amount' => '10.50', 'charge_code' => 'zw', )); ?> You are going pay <?php echo number_format( $fields['amount']/100 , 2 ); ?> Rs <form action="#" method="post" name="merchantForm"> <input type="hidden" value="<?php echo $fields['user_code']; ?>" name="user_code"> <input type="hidden" value="<?php echo $fields['pass_code']; ?>" name="pass_code"> <input type="hidden" value="<?php echo $fields['tran_id']; ?>" name="tran_id"> <input type="hidden" value="<?php echo $fields['amount']; ?>" name="amount"> <input type="hidden" value="<?php echo $fields['charge_code']; ?>" name="charge_code"> <input type="hidden" value="<?php echo $fields['hash_value']; ?>" name="hash_value"> <INPUT TYPE="image" SRC="images/pay.png" height="67" width="195"> </form> <br /><br /> </td> </tr> </table> </div> </div> </div> <?php include("footer.php");?> </div> </body> Thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/307323-need-help-with-our-payment-gateway/#findComment-1558666 Share on other sites More sharing options...
NotionCommotion Posted May 30, 2018 Share Posted May 30, 2018 It depends on gate.php and the gate class. PS. Wrap your code using <> on the toolbar. Quote Link to comment https://forums.phpfreaks.com/topic/307323-need-help-with-our-payment-gateway/#findComment-1558667 Share on other sites More sharing options...
sandip123 Posted May 30, 2018 Author Share Posted May 30, 2018 Gate.php code <?php class Gate extends \ArrayObject { /** * Construct a new array object */ function __construct( $input ){ parent::__construct( $input , self::ARRAY_AS_PROPS); $this->setPriceInPissa(); $this->setPrefixTranId(); $this->setHash(); } /** * Amount to mix in hash logic, we ajax call from client side to pass hash key * * @param type $amount */ private function setHash() { $p = $this; $string = implode('|', array( $p['user_code'] , $p['pass_code'] , $p['tran_id'] , $p['amount'] , $p['charge_code'] , $p['hash_key'] )); $this['hash_value'] = base64_encode(sha1( $string , true ) ); } /** * Amount to mix in hash logic, we ajax call from client side to pass hash key * * @param type $amount */ private function setPrefixTranId() { $this['tran_id'] = $this['user_code'] . $this['tran_id']; } /** * Amount to mix in hash logic, we ajax call from client side to pass hash key * * @param type $amount */ private function setPriceInPissa() { $this['amount'] = floatval( $this['amount'] ) * 100 ; } Quote Link to comment https://forums.phpfreaks.com/topic/307323-need-help-with-our-payment-gateway/#findComment-1558672 Share on other sites More sharing options...
NotionCommotion Posted May 30, 2018 Share Posted May 30, 2018 Your gate class has no public methods, but just updates itself. It does so using $this['tran_id'] versus $this->tran_id. I wouldn't think this is correct, but maybe it is okay. After this line: $fields = new gate( array(/*...*/)); Add the following: var_dump($fields); or if you prefer, add the following: echo('<pre>'.print_r($fields,1).'</pre>'); For that matter, do them both so you can see the different format they export. The information, however, is basically the same. If you are lucky, you will see your data, and will likely have to access it as $fields->tran_id instead of $fields['tran_id']. Quote Link to comment https://forums.phpfreaks.com/topic/307323-need-help-with-our-payment-gateway/#findComment-1558673 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.