当前位置: 首页>>代码示例>>C#>>正文


C# CreditCard.Insert方法代码示例

本文整理汇总了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;
            }
开发者ID:CorbinDallas,项目名称:Rendition,代码行数:54,代码来源:Payment.cs


注:本文中的CreditCard.Insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。