Reputation: 9
i am having demo account on 2checkout.i am require to accept online payment via 2checkout. so for that i am testing code with demo account. the problem is that on demo account i got message the order processsed sucessfully but when i verify the same on myside using documentation it is always failed.
below is html code to make payment online
<form action='https://www.2checkout.com/checkout/purchase' method='post'>
<input type='hidden' name='sid' value='202351337'>
<input type='hidden' name='quantity' value='1'>
<input type='hidden' name='product_id' value='1'>
<input name='submit' type='submit' value='Buy from 2CO' >
</form>
below is verification code taken from 2checkout official documentation
<?php
print_r($_REQUEST);
$hashSecretWord='james007'; //2Checkout Secret Word
$hashSid=202351337; //2Checkout account number
$hashTotal=100.00; //Sale total to validate against
$hashOrder=1; //2Checkout Order Number
$StringToHash = strtoupper(md5($hashSecretWord . $hashSid . $hashOrder . $hashTotal));
echo "<br/> And StringToHash is $StringToHash <br/>";
if ($StringToHash != $_REQUEST['key'])
{
$result = 'Fail - Hash Mismatch';
}
else
{
$result = 'Success - Hash Matched';
}
echo $result;
i always to message Fail-Hash Mismatch
Upvotes: 0
Views: 838
Reputation: 11
your giving $hashOrder=1;
but order number 1 will work only for Demo sales
if your Post URL like below then only $hashOrder=1;
will work
(https://sandbox.2checkout.com/checkout/purchase' method='post'>).
but your using <form action='https://www.2checkout.com/checkout/purchase' method='post'>
. that means your live sale.
in this case $hashOrder=$_REQUEST['hashOrder'];
I hope this will work for you.
Upvotes: 1
Reputation: 1
I think your issue is due to the fact that you are setting the hashTotal
as a number, not a string. Try changing that line to this:
$hashTotal='100.00';
Upvotes: 0