我正在使用SIM并发送用户向Authorizaiton.net购买东西。但成功交易后我无法访问我们的网站。如何通过回复进行重定向?
<form id="simForm" runat="server" method='post' action='https://test.authorize.net/gateway/transact.dll'>
<input id="HiddenValue" type="hidden" value="Initial Value" runat="server" />
<input type='hidden' runat="server" name='x_login' id='x_login' />
<input type='hidden' runat="server" name='x_amount' id='x_amount' />
<input type='hidden' runat="server" name='x_description' id='x_description' />
<input type='hidden' runat="server" name='x_invoice_num' id='x_invoice_num' />
<input type='hidden' runat="server" name='x_fp_sequence' id='x_fp_sequence' />
<input type='hidden' runat="server" name='x_fp_timestamp' id='x_fp_timestamp' />
<input type='hidden' runat="server" name='x_fp_hash' id='x_fp_hash' />
<input type='hidden' runat="server" name='x_test_request' id='x_test_request' />
<%--<input type='hidden' runat="server" name='x_relay_response' id='x_relay_response' />
<input type='hidden' runat="server" name='x_relay_url' id='x_relay_url' />--%>
<input type='hidden' name='x_show_form' value='PAYMENT_FORM' />
<input type='submit' value="Make Payment" title="Make Payment" visible="false" runat="server" id='buttonLabel' />
</form>
Code Behind :
protected void Page_Load(object sender, EventArgs e)
{
// start by setting the static values
string loginID = "LOGIN ID";
string transactionKey = "TRANSACTION ID";
string amount = "19.99";
string description = "Sample Transaction";
string label = "Submit Payment"; // The is the label on the 'submit' button
string testMode = "true";
// If an amount or description were posted to this page, the defaults are overidden
if (Request.Form["amount"] != null)
{ amount = Request.Form["amount"]; }
if (Request.Form["description"] != null)
{ description = Request.Form["description"]; }
// also check to see if the amount or description were sent using the GET method
if (Request.QueryString["amount"] != null)
{ amount = Request.QueryString["amount"]; }
if (Request.QueryString["description"] != null)
{ description = Request.QueryString["description"]; }
string invoice = DateTime.Now.ToString("yyyyMMddhhmmss");
Random random = new Random();
string sequence = (random.Next(0, 1000)).ToString();
string timeStamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();
string fingerprint = HMAC_MD5(transactionKey, loginID + "^" + sequence + "^" + timeStamp + "^" + amount + "^");
//Print the Amount and Description to the page by placing them in the Spans
//amountSpan.InnerHtml = amount;
//descriptionSpan.InnerHtml = description;
//Update the fields in the actual form
x_login.Value = loginID;
x_amount.Value = amount;
x_description.Value = description;
buttonLabel.Value = label;
x_test_request.Value = testMode;
x_invoice_num.Value = invoice;
x_fp_sequence.Value = sequence;
x_fp_timestamp.Value = timeStamp;
x_fp_hash.Value = fingerprint;
//x_relay_response.Value = "TRUE";
//x_relay_url.Value = "http:mysite.com";
}
// This is a wrapper for the VB.NET's built-in HMACMD5 functionality
// This function takes the data and key as strings and returns the hash as a hexadecimal value
string HMAC_MD5(string key, string value)
{
// The first two lines take the input values and convert them from strings to Byte arrays
byte[] HMACkey = (new System.Text.ASCIIEncoding()).GetBytes(key);
byte[] HMACdata = (new System.Text.ASCIIEncoding()).GetBytes(value);
// create a HMACMD5 object with the key set
HMACMD5 myhmacMD5 = new HMACMD5(HMACkey);
//calculate the hash (returns a byte array)
byte[] HMAChash = myhmacMD5.ComputeHash(HMACdata);
//loop through the byte array and add append each piece to a string to obtain a hash string
string fingerprint = "";
for (int i = 0; i < HMAChash.Length; i++)
{
fingerprint += HMAChash[i].ToString("x").PadLeft(2, '0');
}
return fingerprint;
}
我正在成功发送数据并付款。但是它没有将我重定向到我的网站。是否有帮助?
提前致谢
答案 0 :(得分:0)
您已将中继网址注释掉。此外,您不应透露您的API密钥或交易ID。