cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with getHostedPaymentPageResponse

I have sucessfully run the getHostedPaymentPageResponse call and have a token.

When I post the token using an HttpWebRequest, I get this as a post_response:

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<!-- Doesn't always work! -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">


<link href="scripts/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">

<script src="scripts/lib/jquery.min.js"></script>
<script src="scripts/lib/angular.min.js"></script>

<script src="scripts/lib/bootstrap/js/bootstrap.min.js"></script>

<head id="Head1"><title>
Secure Information
</title>
<link href="styles/payment.css" rel="stylesheet" type="text/css" />
<style type="text/css">null</style>

<script src="../payment/scripts/components/paymentComponent/1_0/payment-min.js"></script>
<script src="../payment/scripts/components/addressComponent/1_0/address-min.js"></script>
<script src="../payment/scripts/components/bankAccountComponent/1_0/bankAccount-min.js"></script>
<script src="scripts/app-min.js"></script>

 


<script type="text/javascript">
//<![CDATA[
var g_token = "null";
var g_merchantData = null;
var g_pageOptions = null;
var g_iframeCommunicatorUrl = (!! (typeof g_pageOptions !== 'undefined' && g_pageOptions !== null && g_pageOptions.hostedPaymentIFrameCommunicatorUrl && g_pageOptions.hostedPaymentIFrameCommunicatorUrl.url) ) ? g_pageOptions.hostedPaymentIFrameCommunicatorUrl.url : "" ;

</script>
<script type="text/javascript">
var onloadCallback = function () {
var scope = angular.element($('div[ng-controller="mainController"]')).scope();
grecaptcha.render('html_element', {
'sitekey': '6Lc8tgYAAAAAAFfalsuPuIZ6bv_2dGT_Y9ZxURiK',
'theme': 'light',
'callback': verifyCallback
});
if(g_iframeCommunicatorUrl.length > 0 && scope.isIframeCommunication){
IFrameCommunication.sendResizeWindowToMerchant();
}

};
var verifyCallback = function (response) {
var scope = angular.element($('div[ng-controller="mainController"]')).scope();
scope.isValidCaptchResponse = true ;
scope.$apply();
};
</script>

<script type="text/javascript">
var g_EcheckEnabled = false;
var g_CreditEnabled = false;
</script>
</head>
<body>
<div class="PageOuter" id="divPageOuter">
<div id="divPopupScreen" class="PopupScreen" style="display:none;"></div>
<div class="Page" id="divPage" ng-app="HostedPaymentApp">
<div class="PageMain container" id="divPageMain container" ng-controller="mainController" ng-cloak>

<div id="MainContent_divErrorPanel" class="ErrorPanel container">
<div class="ErrorPanelMsg">
<span id="MainContent_spnErrorMsg" class="ErrorMsg">Missing or invalid token.</span>
</div>
<div id="divErrorPanelButtons" class="ErrorPanelButtons">
<input id="btnCloseWindow" class="CloseButton" ng-click="cancelContinueBtnHandler('cancel')" value="Close" type="button"/>
</div>
</div>

<div id="divIframeCommunicator" class="iFrameClass"></div>

</div>
<div class="PageMainAfter"></div>
</div>
</div>
</body>
</html>

 

When I post using a form post, I get "Missing or Invalid Token".

 

I am sure I am doing something wrong, but I have tried everything I know to do and these are the responses no matter what.  Can anyone help me?

 

 

prsnider73
Member
8 REPLIES 8

Is anyone with Authorize.net out there?

prsnider73
Member

Lets see your form action, method and input.

Powered by NexWebSites.com -
Certified Authorize.net developers
NexusSoftware
Trusted Contributor

I have tried this routine:

Private Function PostToURL(strToken As String) As String
Dim strMsg As String = ""

Dim objRequest As HttpWebRequest = Nothing
Dim post_values As New System.Collections.Generic.Dictionary(Of String, String)
Dim post_string As String = ""

Try
post_string = "token=" & strToken
objRequest = CType(WebRequest.Create(webAddress), HttpWebRequest)
objRequest.Method = "POST"
objRequest.ContentLength = post_string.Length
'objRequest.ContentType = "text/html"
objRequest.ContentType = "application/x-www-form-urlencoded"
Catch ex As Exception
strMsg = ex.Message
End Try


Try
Dim myWriter As StreamWriter = Nothing
myWriter = New StreamWriter(objRequest.GetRequestStream())
myWriter.Write(post_string)
myWriter.Close()
Catch ex As Exception
strMsg = ex.Message
End Try

Dim objResponse As HttpWebResponse
Dim responseStream As StreamReader = Nothing
Dim post_response As String = Nothing

Try
objResponse = CType(objRequest.GetResponse(), HttpWebResponse)
responseStream = New StreamReader(objResponse.GetResponseStream())
post_response = responseStream.ReadToEnd()
Catch ex As Exception
strMsg = ex.Message
End Try
Try
responseStream.Close()
Catch ex As Exception
strMsg = ex.Message
End Try

Return "OK"
End Function

 

And this form post where the input is auto filled in with the token:

<form id="form1" runat="server" method="post" action="https://accept.authorize.net/payment/payment">
<input name="token" id="txtToken" runat="server"/>
<br/>
<input type="submit" value="Send" name="Send"/>

</form>

 

 

When requesting the token, are you using live account credentials or sandbox credentials? 

 

You probably want to be testing on the sandbox and form post to : https://test.authorize.net/payment/payment.

Powered by NexWebSites.com -
Certified Authorize.net developers

I worked off of the sandbox account for about 3 days and i couldn't get anywhere, so I switched to production in test mode and have the same issue, so I'm guessing it isn't going to matter.

I see you are defining post_values As New System.Collections.Generic.Dictionary(Of String, String), but are not using it by adding post_values.Add("token", "YOUR_TOKEN_HERE").

Try something easy to start with, as the post_response is the page returned, based on the token sent and isn't goint to be of any value to you on your own server.

Private Function PostToURL(strToken As String) As String
Response.Clear()
Dim posturl As String = "https://test.authorize.net/payment/payment"
Dim sb As New StringBuilder()
sb.Append("<html>")
sb.AppendFormat("<body onload='document.forms[""form""].submit()'>")
sb.AppendFormat("<form target='payframe' name='form' action='{0}' method='post'>", posturl)
sb.AppendFormat("<input type='hidden' name='token' value='{0}'>", strToken)
sb.Append("</form>")
sb.Append("<iframe style='height: 700px;width:100%;border-style: none;' name='payframe' id='payframe'></iframe>")
sb.Append("</body>")
sb.Append("</html>")
Response.Write(sb.ToString())
Response.End()
Return strToken
End Function

 

Powered by NexWebSites.com -
Certified Authorize.net developers

That got me a form.  Thank you so much!

You're welcome. Glad to hear you are getting a form now. 

Powered by NexWebSites.com -
Certified Authorize.net developers