本文整理汇总了C#中CreditCard.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# CreditCard.Insert方法的具体用法?C# CreditCard.Insert怎么用?C# CreditCard.Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CreditCard
的用法示例。
在下文中一共展示了CreditCard.Insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PayWithCreditCard
/// <summary>
/// Pays with a credit card.
/// </summary>
/// <param name="cardName">Name on the card.</param>
/// <param name="cardType">Type of card (not used or recorded).</param>
/// <param name="cardNumber">The card number.</param>
/// <param name="expMonth">The exp month (two digit).</param>
/// <param name="expYear">The exp year (two digit).</param>
/// <param name="secNumber">The security number.</param>
/// <param name="amount">The amount.</param>
/// <param name="userId">The userId.</param>
/// <param name="postingDate">The posting date.</param>
/// <param name="orderIds">The order ids.</param>
/// <param name="cn">The sql connection (or null).</param>
/// <param name="trans">The sql transaction (or null).</param>
/// <returns>{error:0,desc:"error description"}.</returns>
public static Dictionary<string, object> PayWithCreditCard( string cardName, string cardType, string cardNumber, string expMonth,
string expYear, string secNumber, decimal amount, int userId, DateTime postingDate,
List<object> orderIds, SqlConnection cn, SqlTransaction trans )
{
List<int> intIds = orderIds.ConvertAll( delegate( object i ) {
return Convert.ToInt32( i );
} );
Dictionary<string, object> j = new Dictionary<string, object>();
Guid paymentMethodId = Guid.NewGuid();
int error = 0;
string description = "";
Commerce.CreditCard card = new CreditCard( cardType, cardNumber, cardName, secNumber, expMonth, expYear );
Commerce.Order ord = Commerce.Order.GetOrderByOrderId( intIds[ 0 ] );
/* use the first order's bill to and ship to Address to validate the credit card */
Dictionary<string, object> vt = Commerce.VirtualTerminal.ChargeCreditCard( ord.BillToAddress,
ord.ShipToAddresses[ 0 ], card, amount, ord.SessionId, ord.OrderNumber + " Group", ord.PurchaseOrder + " Group", cn, trans );
if( vt == null ) {
string _msg = "Internal virtual terminal error. Unable to create virtual terminal object.";
j.Add( "error", -1754 );
j.Add( "description", _msg );
Exception e = new Exception( _msg );
String.Format( "payWithCreditCard threw an exception ==>{0}", e.Message ).Debug( 3 );
throw e;
}
error = Convert.ToInt32( vt[ "error" ].ToString() != "0" );/* 1 means error, 0 means no error */
description = vt[ "description" ].ToString();
if( error == 0 ) {
/* update orders becuase the transaction was successful
this posts the entry to the general ledger table */
card.Insert( paymentMethodId, Guid.Empty, userId, Guid.Empty, -1, "", amount, postingDate, intIds, "", cn, trans );
/* update the orders with the payment data */
UpdateOrders( orderIds, amount, paymentMethodId, cn, trans );
}
j.Add( "paymentMethodId", paymentMethodId.ToString() );
j.Add( "error", error );
j.Add( "description", description );
return j;
}