我繼承了使用的CyberSource作爲信用卡處理公司的應用程序。它目前使用CyberSource API,我試圖將其轉換爲使用他們的託管訂單頁面 - 特別是無聲訂單發佈方法。這個例子給CyberSource的運行它如下:回覆於與一個iframe
<form action="https://orderpagetest.ic3.com/hop/ProcessOrder.do" method="POST">
<% insertSignature3("10", "USD", "sale"); %>
<h2>Payment Information</h2>
Card Type: <select name="card_cardType"><br>
<option value="">
<option value="001">Visa
<option value="002">MasterCard
<option value="003">American Express
</select><br>
Card Number: <input type="text" name="card_accountNumber"><br>
Expiration Month: <input type="text" name="card_expirationMonth"> (mm)<br>
Expiration Year: <input type="text" name="card_expirationYear"> (yyyy)<br><br>
<h2>Ready to Check Out!</h2>
<input type="submit" name="submit" value="Buy Now">
</form>
的insertSignature方法的代碼如下:當我在測試應用程序運行它
public void insertSignature3(String amount, String currency, String orderPage_transactionType)
{
try
{
TimeSpan timeSpanTime = DateTime.UtcNow - new DateTime(1970, 1, 1);
String[] arrayTime = timeSpanTime.TotalMilliseconds.ToString().Split('.');
String time = arrayTime[0];
String merchantID = GetMerchantID();
if (merchantID.Equals(""))
Response.Write("<b>Error:</b> <br>The current security script (HOP.cs) doesn't contain your merchant information. Please login to the <a href='https://ebc.cybersource.com/ebc/hop/HOPSecurityLoad.do'>CyberSource Business Center</a> and generate one before proceeding further. Be sure to replace the existing HOP.cs with the newly generated HOP.cs.<br><br>");
String data = merchantID + amount + currency + time + orderPage_transactionType;
String pub = GetSharedSecret();
String serialNumber = GetSerialNumber();
byte[] byteData = System.Text.Encoding.UTF8.GetBytes(data);
byte[] byteKey = System.Text.Encoding.UTF8.GetBytes(pub);
HMACSHA1 hmac = new HMACSHA1(byteKey);
String publicDigest = Convert.ToBase64String(hmac.ComputeHash(byteData));
publicDigest = publicDigest.Replace("\n", "");
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<input type=\"hidden\" name=\"amount\" value=\"");
sb.Append(amount);
sb.Append("\">\n<input type=\"hidden\" name=\"currency\" value=\"");
sb.Append(currency);
sb.Append("\">\n<input type=\"hidden\" name=\"orderPage_timestamp\" value=\"");
sb.Append(time);
sb.Append("\">\n<input type=\"hidden\" name=\"merchantID\" value=\"");
sb.Append(merchantID);
sb.Append("\">\n<input type=\"hidden\" name=\"orderPage_transactionType\" value=\"");
sb.Append(orderPage_transactionType);
sb.Append("\">\n<input type=\"hidden\" name=\"orderPage_signaturePublic\" value=\"");
sb.Append(publicDigest);
sb.Append("\">\n<input type=\"hidden\" name=\"orderPage_version\" value=\"4\">\n");
sb.Append("<input type=\"hidden\" name=\"orderPage_serialNumber\" value=\"");
sb.Append(serialNumber);
sb.Append("\">\n");
Response.Write(sb.ToString());
}
catch (Exception e)
{
Response.Write(e.StackTrace.ToString());
}
}
一切正常。但是,我無法在主應用程序中使用表單標籤,因爲母版頁中的所有內容都包含在表單標記中,這會導致嵌套的表單標記。我曾嘗試將表單塊放入iframe中,但無法通過來自insertSignature(...)方法的Response.Write調用來傳遞附加信息。
任何建議表示讚賞。