質問

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.

役に立ちましたか?

解決

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.

他のヒント

  1. Get the parameters from your URL

Get the key, sid,order_number ,total and the secret word from your account settings. if you cant read properly you can use this web to read get parameters better.

http://www.freeformatter.com/url-parser-query-string-splitter.html

  1. Convert to MD5 in uppercase

String result = YourMethodConvertStringToMD5InUpperCase(secret word* + sid + order_number + total );

[!] dont forget to convert to UpperCase,dont forget convert total to string.

  1. Compare

Compare key generated by 2checkout with result ,this should be true.

Remember if you have the parameter "demo"="Y" you'd use number_order="1" in your encryption md5 as you can read here .

https://www.2checkout.com/documentation/checkout/passback-validation/

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top