Hi All,

This is hurting my head. I am setting up my online store with a new payment provider and have to modify the script that passes variables through, what I need to do is generate a MD5 hash and pass that as a variable through my post.

I need to mod the script below to include the code below that, my PAYMENT_KEY is already defined as $data2

I really need help with this one...

<?php
if($demomode){
$vspsite="https://www.e-merchant.co.uk/pay/test/";
}else{
$vspsite="https://www.e-merchant.co.uk/pay/";
}
// Firstly you will need to set the URL to pass payment variables below in the FORM action ?>
<FORM ACTION="<? echo($vspsite); ?>" METHOD="post" ID="form1">
<input type="hidden" name="orderRef" value="<?php print $orderid?>">
<input type="hidden" name="merchantId" value="<?php print $data1?>">
<input type="hidden" name="merchantHash" value= WHAT HERE
<INPUT TYPE="hidden" NAME="orderAmount" VALUE="<?php print number_format($grandtotal,2,'.','')?>">
<input type="hidden" name="successURL" VALUE="<?php print $storeurl?>">
<input type="hidden" name="failureURL" VALUE="<?php print $storeurl?>sorry.php">
<input type="hidden" name="cancelURL" VALUE="<?php print $storeurl?>sorry.php">
<input type="hidden" name="CUSTMAIL" value="<?php print unstripslashes(@$POST["email"])?>">
<input type="hidden" name="CUSTNAME" value="<?php print unstripslashes(@$
POST["name"])?>">

<?php // A variable "demomode" is made available to the admin section that, if provided by the payment system will turn on a demo transaction mode ?>
<?php if($demomode) print '<input type="hidden" name="demo" value="Y">'; ?>
<?php // IMPORTANT NOTE ! You may notice there is not closing <FORM> tag. This is intentional. ?>

Code to be integrated into the above:

<?php
// Create a global constant for your payment key
define("PAYMENT_KEY","123456"); //This is an example payment key

// Combine the details
$orderRef = "OrderRef"; //Insert order reference/number here *
$orderAmount = "Amount"; //Insert the full order amount here **

$data = $orderRef.";".$orderAmount.";".PAYMENT_KEY;

// Create security hash
$securityHash = md5($data);
?>

You'll notice $orderRef and $orderAmount are processed in the first script.

My head is now spinning...

    Can you be a little bit more clear about what you want to do with the payment key? Where do you want it to go, and at what point -- after they post, or before?

      You could do something like:

      <FORM ACTION="<? echo($vspsite); ?>" METHOD="post" ID="form1">
      <input type="hidden" name="orderRef" value="<?php print $orderid?>">
      <input type="hidden" name="merchantId" value="<?php print $data1?>">
      <input type="hidden" name="merchantHash" value= "<?php include('hash.php'); echo getHash(); ?>">
      

      Then in hash.php

      function getHash(){
      
      define("PAYMENT_KEY","123456"); //Use your payment key
      
      $orderRef = $orderid;
      $orderAmount = number_format($grandtotal,2,'.','');
      $data = $orderRef.";".$orderAmount.";".PAYMENT_KEY;
      
      $securityHash = md5($data);
      return $securityHash;
      }
      
      
        Write a Reply...