Reputation: 9175
I created a test demo account in 2checkout.And i tested some code to do a demo payment in 2checkout. in the account , i set 'demo setting' 'On'
Everything goes correctly,and i am getting hash match on the return page.
Following is my code.
index.php
<form action='https://www.2checkout.com/checkout/spurchase' method='post'>
<input type='hidden' name='sid' value='123456' >
<input type='hidden' name='mode' value='2CO' >
<input type='hidden' name='li_0_type' value='product' >
<input type='hidden' name='li_0_name' value='Test' >
<input type='hidden' name='li_0_price' value='2.00' >
<input type='hidden' name='li_0_quantity' value='4' >
<input type='hidden' name='li_0_tangible' value='N' >
<input type='hidden' name='currency_code' value='INR' >
<input name='submit' type='submit' value='Checkout' >
</form>
return.php
if ($_REQUEST['demo'] == 'Y')
{
$order_number = 1;
}
else
{
$order_number = $_REQUEST['order_number'];
}
$hashSecretWord = '2checkout';
$compare_string = $hashSecretWord . $_REQUEST['sid'] . $order_number . $_REQUEST['total'];
$compare_hash1 = strtoupper(md5($compare_string));
$compare_hash2 = $_REQUEST['key'];
if ($compare_hash1 != $compare_hash2)
{
echo "Hash Mismatch";
}
else
{
echo "Hash Matched";
}
How to confirm that whether the payment was success or not ?
i can't see the demo orders in my account But I am getting mails about each orders .Also iam getting "HAsh Matched" in return.php page.
I also created a API username & password.
How to do these payment process using the API details?
Upvotes: 2
Views: 2996
Reputation: 741
Your script is validating the hash correctly. 2Checkout demo sales will not show in your account as they do not actually create a sale in 2Checkout's system. When placing a live sale, the sale record will show in your account under the sales tab.
2Checkout's back office API can be used for retrieving or updating live sales that have already been placed but it cannot be used to create a sale. Sales need to be passed in along with the buyer to 2Checkouts secured server to complete the payment.
Feel free to reach out to 2Checkout's integrations department at [email protected] if you would like additional assistance with your integration.
Upvotes: 0