Search code examples
asp.net2checkout

Cannot Fetch 2Checkout Return Parameters


I am facing a problem in fetching return parameters from 2Checkout using .Net, I am currently working on demo mode, products list are sent successfully to 2checkout and when return to (x_receipt_link_url) nothing happen to notify that purchase has been completed although I am adding a block to fetch the return parameters, I am using something like this but with different values

//Check for response from 2Checkout
            if (Request.Params["credit_card_processed"] != null)
            {

                //Initialize returned parameters
                string key = Request.Params["key"];
                string sid = "1303908";
                string secret_word = "tango";
                string merchant_order_id = Request.Params["merchant_order_id"];
                string order_number = Request.Params["order_number"];
                string total = Request.Params["total"];

                //Compute our hash
                string string_to_hash = secret_word + sid + order_number + total;
                string our_hash = getMd5Hash(string_to_hash);

                //Compare hashes and update response string
                if (our_hash != key)
                {
                    response = "ERROR: MD5 hash did not match!";
                } 
                else 
                {
                    response = "Thank you for your Order!";
                }
            }

Kindly Advice? Thanks for your help.


Solution

  • 2Checkout will return credit_card_processed=Y on all successful sales so your hash check should be firing. On demo sales the 2Checkout MD5 Hash will fail to validate because the returned hash is computed using a "1" for the order number. So in your code, you can match it like so:

    if (Request.Params["demo"] == "Y")
    {
        string order_number = "1";
    }
    

    Your post indicates that you are having a problem fetching the returned parameters , not a problem validating the hash so I think the issue is outside of the code that you posted. Please contact 2Checkout tech support at techsupport@2co.com for assistance with troubleshooting the passback.