我继承了一个使用 Cybersource 作为信用卡处理公司的应用程序。它目前使用 CyberSource API,我正在尝试将其转换为使用他们托管的订单页面 - 特别是静默订单发布方法。CyberSource 给出的运行它的示例如下:
<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 调用传递附加信息。
任何建议表示赞赏。