3

When the sale is completed,the buyer return with sale parameters back to the approved URL that we defined. on 2checkout so i have defined mine localhost/XYZ/index.php?r=order/authenticateCheckout

Now according to documentation as code is given in this URL click here 2checkout documentation

I have given this code in my approval action

  <?php

    $hashSecretWord = 'tango';    //2Checkout Secret Word
    $hashSid = 1303908;    //2Checkout account number
    $hashTotal = '1.00';    //Sale total to validate against
    $hashOrder = $_REQUEST['order_number'];    //2Checkout Order Number
    $StringToHash = strtoupper(md5($hashSecretWord . $hashSid . $hashOrder . $hashTotal));
    if ($StringToHash != $_REQUEST['key']) {
        $result = 'Fail - Hash Mismatch';
    } else {
        $result = 'Success - Hash Matched';
    }

    echo $result;
?>

Now every thing working fine when the hashkeymatched i display confirmation ur payment has been completed but when the hashkey is mismatched then what should i do cancel the payment ? how i will do that becauase they did not mention any way in the documentation. Please help.

AsadYarKhan
  • 678
  • 2
  • 14
  • 31

1 Answers1

2

If you would like to automatically refund the sale when the hash check fails, you can make a refund_invoice call to 2Checkout's back office API using the order_number returned. To make it easy, you can use the 2Checkout PHP library to handle both the passback check and the refund_invoice call as shown in the documentation. As always, feel free to reach out to 2Checkout tech support at techsupport@2co.com with any questions.

Craig-2Checkout
  • 741
  • 5
  • 7
  • so it is necessary to refund ? and please tell me what will be the reason when hash match fail ? – AsadYarKhan Jun 24 '13 at 12:14
  • No it is not necessary to refund. You can contact the buyer to verify and check the sale in your account to make sure that it went through successfully. The hash check will only fail if you are either placing a demo sale or if the total that was processed does not match the total you are using to compare. – Craig-2Checkout Jun 24 '13 at 20:34