You are right, but that does not work in my code. anyways, can you help with incorporating hash code that is being used in the php file that I posted later into my code. somewhat hash should be what their code is giving.
I will need your code to be able to help you out.
but I would first check that you can echo out your posted values as these must be right
you need to echo out all of them that they ask for that are compulsary and make sure they are correct.
[php]
echo $_POST[‘key’].’|’;
echo $_POST[‘txid’].’|’;
echo $_POST[‘amount’].’|’;
[/php]
[php]<?php
function xxx_config() {
$configarray = array(
"FriendlyName" => array("Type" => "System", "Value"=>"XXX"),
"alias" => array("FriendlyName" => "Merchant ID", "Type" => "text", "Size" => "20", ),
"salt" => array("FriendlyName" => "SALT", "Type" => "text", "Size" => "20",),
"mode" => array("FriendlyName" => "MODE", "Type" => "text", "Description" => "TEST or LIVE", ),
);
return $configarray;
}
function xxx_link($params) {
# Gateway Specific Variables
$key = $params['alias'];
$gatewaymode = $params['mode'];
$salt = $params['salt'];
# Invoice Variables
$txnid = $params['invoiceid'];
$productinfo = $params["description"];
$amount = $params['amount']; # Format: ##.##
$currency = $params['currency']; # Currency Code
# Client Variables
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];
# System Variables
$companyname = 'XXX';
$systemurl = $params['systemurl'];
$currency = $params['currency'];
# Enter your code submit to the gateway...
$hashdata = ($key."|".$txnid."|".$amount."|".$productinfo."|".$firstname."|".$email."|"."|"."|"."|"."|"."|".$salt);
$hash = hash(“sha512”, $hashdata);
$code = ’
return $code;
}
?>
[/php]
so where do you get your params array values from ?
echo the ones you need out
[php]echo $key;[/php]
each one has to be like this
[php]$key = htmlentities($params[‘alias’], ENT_QUOTES);
$email = htmlentities($params[‘clientdetails’][‘email’], ENT_QUOTES);
$salt = htmlentities($params[‘salt’], ENT_QUOTES);[/php]
Your hash has to be in lowercase to send
[php]$hash = strtolower(hash(“sha512”, $hashdata));[/php]
your hashdata need to look like this not how you have it you do not have enough pipes
[php]$hashdata = ($key."|".$txnid."|".$amount."|".$productinfo."|".$firstname."|".$email."|||||||||||".$salt);[/php]
Also you never give me any results from the echo values so cant help any more.
Ok I think I have figured it out now as I have it working
<input type="input" name="name" value="'.$firstname.'" />
needs to be this
<input type="input" name="firstname" value="'.$firstname.'" />
This is the code I am testing it with you can modify yours to suit
[php]
<?php function xxx_config() { $configarray = array( "FriendlyName" => array("Type" => "System", "Value"=>"XXX"), "alias" => array("FriendlyName" => "Merchant ID", "Type" => "text", "Size" => "20", "Value"=>"YYY"), "salt" => array("FriendlyName" => "SALT", "Type" => "text", "Size" => "20","Value"=>"WWW"), "mode" => array("FriendlyName" => "MODE", "Type" => "text", "Description" => "TEST or LIVE", "Value"=>"TEST") ); return $configarray; } #function xxx_link($params) { /* # Gateway Specific Variables $key = $params['alias']; $gatewaymode = $params['mode']; $salt = $params['salt']; # Invoice Variables $txnid = $params['invoiceid']; $productinfo = $params["description"]; $amount = $params['amount']; # Format: ##.## $currency = $params['currency']; # Currency Code # Client Variables $firstname = $params['clientdetails']['firstname']; $lastname = $params['clientdetails']['lastname']; $email = $params['clientdetails']['email']; $address1 = $params['clientdetails']['address1']; $address2 = $params['clientdetails']['address2']; $city = $params['clientdetails']['city']; $state = $params['clientdetails']['state']; $postcode = $params['clientdetails']['postcode']; $country = $params['clientdetails']['country']; $phone = $params['clientdetails']['phonenumber']; # System Variables $companyname = 'XXX'; $systemurl = $params['systemurl']; $currency = $params['currency']; */ # Gateway Specific Variables $key = htmlentities('C0Dr8m',ENT_QUOTES);; $gatewaymode = 'TEST'; $salt = htmlentities('3sf0jURk',ENT_QUOTES);; # Invoice Variables // Generate random transaction id $txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20); $productinfo = htmlentities('cap',ENT_QUOTES);; $amount = htmlentities('12',ENT_QUOTES);; # Format: ##.## $currency = 'USD'; # Currency Code # Client Variables $firstname = htmlentities('james',ENT_QUOTES); $lastname = 'last'; $email = htmlentities('[email protected]',ENT_QUOTES);; $address1 = '123 add'; $address2 = ''; $city = 'la'; $state = 'texas'; $postcode = '12123123'; $country = 'usa'; $phone = '23487324'; # System Variables $companyname = 'CCC'; $systemurl = 'http'; $currency = 'http'; # Enter your code submit to the gateway... $hashdata = ($key."|".$txnid."|".$amount."|".$productinfo."|".$firstname."|".$email."|||||||||||".$salt); echo 'hash ='.$hashdata.''; $hash = strtolower(hash("sha512", $hashdata)); echo 'hashed = '.$hash.'
'; $code = '<form method="post" action="https://xxxxxx/_payment" '; echo $code; return $code; # } ?>
[/php]
This is all I can do the rest is up to you.
[php]
<?php function xxx_config() { $configarray = array( "FriendlyName" => array("Type" => "System", "Value"=>"XXX"), "alias" => array("FriendlyName" => "Merchant ID", "Type" => "text", "Size" => "20", ), "salt" => array("FriendlyName" => "SALT", "Type" => "text", "Size" => "20",), "mode" => array("FriendlyName" => "MODE", "Type" => "text", "Description" => "TEST or LIVE", ), ); return $configarray; } function xxx_link($params) { # Gateway Specific Variables $key = htmlentities($params[0]['alias'],ENT_QUOTES); $gatewaymode = $params[0]['mode']; $salt = htmlentities($params[0]['salt'],ENT_QUOTES); # Invoice Variables $txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20); # $txnid = htmlentities($params['invoiceid'],ENT_QUOTES); $productinfo = htmlentities($params[0]["description"],ENT_QUOTES); $amount = htmlentities($params[0]['amount'],ENT_QUOTES); # Format: ##.## $currency = $params['currency']; # Currency Code # Client Variables $firstname = htmlentities($params['clientdetails']['firstname'],ENT_QUOTES); $lastname = $params['clientdetails']['lastname']; $email = htmlentities($params['clientdetails']['email'],ENT_QUOTES); $address1 = $params['clientdetails']['address1']; $address2 = $params['clientdetails']['address2']; $city = $params['clientdetails']['city']; $state = $params['clientdetails']['state']; $postcode = $params['clientdetails']['postcode']; $country = $params['clientdetails']['country']; $phone = $params['clientdetails']['phonenumber']; # System Variables $companyname = 'XXX'; $systemurl = $params[0]['systemurl']; $currency = $params[0]['currency']; # Enter your code submit to the gateway... $hashdata = ($key."|".$txnid."|".$amount."|".$productinfo."|".$firstname."|".$email."|||||||||||".$salt); $hash = strtolower(hash("sha512", $hashdata)); $code = ' '; return $code; } $params = array( array( 'alias' => 'C0Dr8m', 'mode' => 'TEST', 'salt' => '3sf0jURk', 'description' => 'cap', 'amount' => '12', 'systemurl' => 'https://xxx.xx/xxxx.php', 'currency' => 'USD'), 'clientdetails' => array( 'firstname' => 'james', 'lastname' => 'last', 'email' => '[email protected]', 'address1' => 'add1', 'address2' => 'add2', 'city' => 'city', 'state' => 'state', 'postcode' => 'postcode', 'country' => 'country', 'phonenumber' => 'phone' ) ); echo xxx_link($params); ?>[/php]
At LAST, had success. That was all because of Noodles. You are just marvelous. See the below code that works. I have made some changes, it is working very fine. I just have now return variables thing, PG site posts back some variables (txnid, status, unique ID, bank reference number, etc) which I have to post back to my invoice system that accepts it and marks the invoices as paid or unpaid. Im posting below is the code that works to post to the PG site and below that a sample code that I have prepared (which again does not work) which should recieve the status etc…
[php]<?php
function xxx_config() {
$configarray = array(
“FriendlyName” => array(“Type” => “System”, “Value”=>“xxx”), “alias” => array(“FriendlyName” => “Merchant ID”, “Type” => “text”, “Size” => “20”, ), “salt” => array(“FriendlyName” => “SALT”, “Type” => “text”, “Size” => “20”,), “mode” => array(“FriendlyName” => “MODE”, “Type” => “text”, “Description” => “TEST or LIVE”, ), );
return $configarray;
}
function xxx_link($params) {
# Gateway Specific Variables
$key = $params['alias'];
$gatewaymode = $params['mode'];
$salt = $params['salt'];
$amount = $params['amount'];
$productinfo = $params['description'];
$txnid = $params['invoiceid'];
# Invoice Variables
$currency = $params['currency'];
# Client Variables
$firstname = htmlentities($params['clientdetails']['firstname'],ENT_QUOTES);
$lastname = $params['clientdetails']['lastname'];
$email = htmlentities($params['clientdetails']['email'],ENT_QUOTES);
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];
# System Variables $companyname = 'xxx';
$systemurl = $params[0]['systemurl'];
$currency = $params[0]['currency'];
# Enter your code submit to the gateway...
$hashdata = ($key."|".$txnid."|".$amount."|".$productinfo."|".$firstname."|".$email."|||||||||||".$salt);
$hash = strtolower(hash("sha512", $hashdata));
$code = ’
return $code;
}
?>[/php]
Callback Code:
[php]<?php
Required File Includes
include("…/…/…/dbconnect.php");
include("…/…/…/includes/functions.php");
include("…/…/…/includes/gatewayfunctions.php");
include("…/…/…/includes/invoicefunctions.php");
$gatewaymodule = “xxx”;
$GATEWAY = getGatewayVariables($gatewaymodule);
$salt = $GATEWAY[‘salt’]; // Your Secret Key
if(isset($_GET[‘DR’])) {
require(‘Rc43.php’);
$DR = preg_replace("/\s/","+",$_GET[‘DR’]);
$rc4 = new Crypt_RC4($salt);
$QueryString = base64_decode($DR);
$rc4->decrypt($QueryString);
$QueryString = split('&',$QueryString);
$response = array();
foreach($QueryString as $param){
$param = split('=',$param);
$response[$param[0]] = urldecode($param[1]);
}
}
//print_r($response);
$amount = $response[‘amount’];
$txnid = $response[‘txnid’];
$invoiceid = $response[‘productinfo’];
?>
HostWithTheBest.COM |
---|
<center><h3>Response</H3></center>
Transaction Details | |
---|---|
<?php echo $key; ?> | <?php echo $value; ?> |
# Check Result
/*if($gatewayresult=="success") {
addInvoicePayment($response['MerchantRefNo'],$transid,$response['Amount'],$fees,"EBS","on");
logTransaction("XXX",$debugdata,"Successful");
sendMessage("XXX Payment Confirmation",$invoiceid);
$result="success";
} else {
logTransaction("XXX",$debugdata,"Declined");
sendMessage("XXX Payment Failed",$invoiceid);
$result="declined";
}*/
if ($response[‘ResponseCode’]==0) {
# Successful
addInvoicePayment($invoiceid,$txnid,$amount,$amount,$gatewaymodule); # Apply Payment to Invoice: invoiceid, transactionid, amount paid, fees, modulename
logTransaction($GATEWAY[“name”],$_POST,“Successful”); # Save to Gateway Log: name, data array, status
} else {
# Unsuccessful
logTransaction($GATEWAY[“name”],$_POST,“Unsuccessful”); # Save to Gateway Log: name, data array, status
}
?>
[/php]
Need help.
This is not part of the subject that part is working I would not know how to get a responce from a site that does not have a test demo cc submission it seems to only have real ones.
So unless you give me your cc number and details I wont be using mine.