activemerchant / active_merchant

Active Merchant is a simple payment abstraction library extracted from Shopify. The aim of the project is to feel natural to Ruby users and to abstract as many parts as possible away from the user to offer a consistent interface across all supported gateways.
http://activemerchant.org
MIT License
4.53k stars 2.49k forks source link

getting html response from payu API with data "Error. We are sorry we are unable to process your payment. Mandatory parameter txnId missing for" #1836

Closed madhusudhan518 closed 9 years ago

madhusudhan518 commented 9 years ago

Hi i am integrating my rails app with Payu . when i request a purchase from console , i am getting a html response rather than json. my parameters are here

ran1 = rand(36**10).to_s(36)
payment = {:first_name => "madhu",:last_name => "sudhan",:brand => "visa",:number => 5123456789012346,:verification_value => 123,:name => "madhu sudhan",:expire_mon => 05,:expire_year => 2017}
options = {:amount => 10.00,:txnid => ran1,:email => "test@gmail.com",:phone => 1111111111,:key => "gtKFFx",:salt => "eCwWELxi",:order_id => ran1}
@options = {:key => "gtKFFx",:salt => "eCwWELxi",:amount => 10.00,:txnid => ran1,:email => "test@gmail.com",:phone => 1111111111,:key => "gtKFFx",:salt => "eCwWELxi",:order_id => ran1}

payu_gateway = ActiveMerchant::Billing::PayuInGateway.new @options
payu_gateway.purchase(400,payment,options)

I am sending transaction Id also.

my stack trace is

# @primary_response=
# @authorization=nil,
@avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil},
@cvv_result={"code"=>nil, "message"=>nil},
@emv_authorization=nil,
@error_code=
"Invalid response received from the PayU API. (The raw response was <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n \n <meta name=\"HandheldFriendly\" content=\"true\" />\n <meta name=\"viewport\" content=\"width=device-width;target-densitydpi=device-dpi;initial-scale=1.0; maximum-scale=1.0;minimum-scale=1.0; user-scalable=0;\"/>\n <meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />\n <meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\" />\n <title>PayUbiz</title>\n <script type=\"text/javascript\">\n\tvar baseImagePath = 'https://static.payu.in/images/';\n </script>\n <link rel=\"shortcut icon\" type=\"image/ico\" href=\"https://static.payu.in/images/favicon.png\" />\n <link href=\"https://static.payu.in/css/helpers.css\" rel=\"stylesheet\" type=\"text/css\" />\n <link href=\"https://static.payu.in/css/screen.css?version=2\" rel=\"stylesheet\" type=\"text/css\" />\n <style type=\"text/css\"></style></head>\n<body>\n<div data-role=\"page\" class=\"container\" id=\"page\"> \n <div id=\"header\" class=\"clearfix\" style='width:100%;margin-top: 10%;' >\n \t\t<div id=\"payu_logo\"\n\t\t >\t\n\t</div>\n\t </div>\n<!DOCTYPE html>\n<!--[if lt IE 7 ]> <html lang=\"en\" class=\"no-js oldie ie6\"> <![endif]-->\n<!--[if IE 7 ]> <html lang=\"en\" class=\"no-js oldie ie7\"> <![endif]-->\n<!--[if IE 8 ]> <html lang=\"en\" class=\"no-js ie8\"> <![endif]-->\n<!--[if (gte IE 9)|!(IE)]><!--> <html class=\"no-js\" lang=\"en\"> <!--<![endif]-->\n\n\n<!-- Custom Modernizr build (should always be on the top) -->\n<script src=\"js/modernizr-2.0.6.min.js\"></script>\n <script language=\"javascript\">\n document.title = \"Transaction Error\";\n </script>\n\n<div id=\"content\" class=\"borderNone message append-bottom\">\n<div class=\"message append-bottom prepend-top append-1 prepend-1\">\n\t<h4 class=\"append-bottom\"><img width=\"32\" height=\"31\" src=\"https://static.payu.in/images/error.jpg\"><span class=\"err\">Error.</span> We are sorry we are unable to process your payment.</h4>\n\n\t<p class=\"prepend-top prepend-2 append-2\">\n\t\t <div class=\"card-note\" style=\"color: red; font-size:20px; margin-top: 5px;\">\n Mandatory parameter txnId missing for </div>\n\n\t</p>\n</div>\n \n</div><!-- #content -->\n\n<script src=\"js/libs/jquery-custom.min.js\"></script>\n<!-- <script src=\"./_js/plugins.js\"></script> -->\n<script src=\"js/script.js?version=v2.0.10\"></script>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"https://static.payu.in/css/new/base.css?version=1.5\" />\n<div id=\"footer\" class=\"\">\n</div>\n</div>\n<script language ='javascript' type=\"text/javascript\">\n function openlink(url) {\n window.open(url, \"DescriptiveWindow\",\"toolbar=0,scrollbars=1,resizable=1,width=550,height=500\");\n self.name = \"mainWin\";\n }\n</script>\n</body>\n</html>\n\n).",
@fraud_review=nil,
@message=
"Invalid response received from the PayU API. (The raw response was <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n \n <meta name=\"HandheldFriendly\" content=\"true\" />\n <meta name=\"viewport\" content=\"width=device-width;target-densitydpi=device-dpi;initial-scale=1.0; maximum-scale=1.0;minimum-scale=1.0; user-scalable=0;\"/>\n <meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />\n <meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\" />\n <title>PayUbiz</title>\n <script type=\"text/javascript\">\n\tvar baseImagePath = 'https://static.payu.in/images/';\n </script>\n <link rel=\"shortcut icon\" type=\"image/ico\" href=\"https://static.payu.in/images/favicon.png\" />\n <link href=\"https://static.payu.in/css/helpers.css\" rel=\"stylesheet\" type=\"text/css\" />\n <link href=\"https://static.payu.in/css/screen.css?version=2\" rel=\"stylesheet\" type=\"text/css\" />\n <style type=\"text/css\"></style></head>\n<body>\n<div data-role=\"page\" class=\"container\" id=\"page\"> \n <div id=\"header\" class=\"clearfix\" style='width:100%;margin-top: 10%;' >\n \t\t<div id=\"payu_logo\"\n\t\t >\t\n\t</div>\n\t </div>\n<!DOCTYPE html>\n<!--[if lt IE 7 ]> <html lang=\"en\" class=\"no-js oldie ie6\"> <![endif]-->\n<!--[if IE 7 ]> <html lang=\"en\" class=\"no-js oldie ie7\"> <![endif]-->\n<!--[if IE 8 ]> <html lang=\"en\" class=\"no-js ie8\"> <![endif]-->\n<!--[if (gte IE 9)|!(IE)]><!--> <html class=\"no-js\" lang=\"en\"> <!--<![endif]-->\n\n\n<!-- Custom Modernizr build (should always be on the top) -->\n<script src=\"js/modernizr-2.0.6.min.js\"></script>\n <script language=\"javascript\">\n document.title = \"Transaction Error\";\n </script>\n\n<div id=\"content\" class=\"borderNone message append-bottom\">\n<div class=\"message append-bottom prepend-top append-1 prepend-1\">\n\t<h4 class=\"append-bottom\"><img width=\"32\" height=\"31\" src=\"https://static.payu.in/images/error.jpg\"><span class=\"err\">Error.</span> We are sorry we are unable to process your payment.</h4>\n\n\t<p class=\"prepend-top prepend-2 append-2\">\n\t\t <div class=\"card-note\" style=\"color: red; font-size:20px; margin-top: 5px;\">\n Mandatory parameter txnId missing for </div>\n\n\t</p>\n</div>\n \n</div><!-- #content -->\n\n<script src=\"js/libs/jquery-custom.min.js\"></script>\n<!-- <script src=\"./_js/plugins.js\"></script> -->\n<script src=\"js/script.js?version=v2.0.10\"></script>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"https://static.payu.in/css/new/base.css?version=1.5\" />\n<div id=\"footer\" class=\"\">\n</div>\n</div>\n<script language ='javascript' type=\"text/javascript\">\n function openlink(url) {\n window.open(url, \"DescriptiveWindow\",\"toolbar=0,scrollbars=1,resizable=1,width=550,height=500\");\n self.name = \"mainWin\";\n }\n</script>\n</body>\n</html>\n\n).",
@params=
{"error"=>
"Invalid response received from the PayU API. (The raw response was <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n \n <meta name=\"HandheldFriendly\" content=\"true\" />\n <meta name=\"viewport\" content=\"width=device-width;target-densitydpi=device-dpi;initial-scale=1.0; maximum-scale=1.0;minimum-scale=1.0; user-scalable=0;\"/>\n <meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />\n <meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\" />\n <title>PayUbiz</title>\n <script type=\"text/javascript\">\n\tvar baseImagePath = 'https://static.payu.in/images/';\n </script>\n <link rel=\"shortcut icon\" type=\"image/ico\" href=\"https://static.payu.in/images/favicon.png\" />\n <link href=\"https://static.payu.in/css/helpers.css\" rel=\"stylesheet\" type=\"text/css\" />\n <link href=\"https://static.payu.in/css/screen.css?version=2\" rel=\"stylesheet\" type=\"text/css\" />\n <style type=\"text/css\"></style></head>\n<body>\n<div data-role=\"page\" class=\"container\" id=\"page\"> \n <div id=\"header\" class=\"clearfix\" style='width:100%;margin-top: 10%;' >\n \t\t<div id=\"payu_logo\"\n\t\t >\t\n\t</div>\n\t </div>\n<!DOCTYPE html>\n<!--[if lt IE 7 ]> <html lang=\"en\" class=\"no-js oldie ie6\"> <![endif]-->\n<!--[if IE 7 ]> <html lang=\"en\" class=\"no-js oldie ie7\"> <![endif]-->\n<!--[if IE 8 ]> <html lang=\"en\" class=\"no-js ie8\"> <![endif]-->\n<!--[if (gte IE 9)|!(IE)]><!--> <html class=\"no-js\" lang=\"en\"> <!--<![endif]-->\n\n\n<!-- Custom Modernizr build (should always be on the top) -->\n<script src=\"js/modernizr-2.0.6.min.js\"></script>\n <script language=\"javascript\">\n document.title = \"Transaction Error\";\n </script>\n\n<div id=\"content\" class=\"borderNone message append-bottom\">\n<div class=\"message append-bottom prepend-top append-1 prepend-1\">\n\t<h4 class=\"append-bottom\"><img width=\"32\" height=\"31\" src=\"https://static.payu.in/images/error.jpg\"><span class=\"err\">Error.</span> We are sorry we are unable to process your payment.</h4>\n\n\t<p class=\"prepend-top prepend-2 append-2\">\n\t\t <div class=\"card-note\" style=\"color: red; font-size:20px; margin-top: 5px;\">\n Mandatory parameter txnId missing for </div>\n\n\t</p>\n</div>\n \n</div><!-- #content -->\n\n<script src=\"js/libs/jquery-custom.min.js\"></script>\n<!-- <script src=\"./_js/plugins.js\"></script> -->\n<script src=\"js/script.js?version=v2.0.10\"></script>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"https://static.payu.in/css/new/base.css?version=1.5\" />\n<div id=\"footer\" class=\"\">\n</div>\n</div>\n<script language ='javascript' type=\"text/javascript\">\n function openlink(url) {\n window.open(url, \"DescriptiveWindow\",\"toolbar=0,scrollbars=1,resizable=1,width=550,height=500\");\n self.name = \"mainWin\";\n }\n</script>\n</body>\n</html>\n\n)."},
@success=false,
@test=false>,
@responses=
[# @authorization=nil,
@avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil},
@cvv_result={"code"=>nil, "message"=>nil},
@emv_authorization=nil,
@error_code=
"Invalid response received from the PayU API. (The raw response was <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n...).",
@fraud_review=nil,
@message=
"Invalid response received from the PayU API. (The raw response was <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n.....).",
@params=
{"error"=>
"Invalid response received from the PayU API. (The raw response was <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n......"},
@success=false,
@test=false>],
@use_first_response=false>

Can anyone tell where is the problem.

ntalbott commented 9 years ago

@madhusudhan518 to get PayU working correctly you'll need to talk to them, as they don't have the code necessary to do direct API calls enabled by default.

madhusudhan518 commented 9 years ago

thank you @ntalbott

buoyant commented 7 years ago

@ntalbott the parameter txn_s2s_flow which is added in payu gateway is invalid. As I spoke to payu dev team, they are saying it is an invalid parameter. There is two-factor auth for transactions to be made via payu gateway. I hope there is offsite_payments gem for such kind of gateways integration.