Jump to content

Recommended Posts

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',

));

?>

Link to comment
https://forums.phpfreaks.com/topic/307323-need-help-with-our-payment-gateway/
Share on other sites

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

 

 

 

 

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 ;

    }

 

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'].

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.