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


C# TransactionRequest.Execute方法代码示例

本文整理汇总了C#中TransactionRequest.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# TransactionRequest.Execute方法的具体用法?C# TransactionRequest.Execute怎么用?C# TransactionRequest.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TransactionRequest的用法示例。


在下文中一共展示了TransactionRequest.Execute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        private static void Main()
        {
            var cust = new
                       {
                           Id = "3",
                           Name = "Test",
                           Email = "[email protected]",
                           Address1 = "123 Main St",
                           City = "Charlotte",
                           State = "NC",
                           Zip = "29028",
                       };

            var card = new
                       {
                           AccountType = AccountTypes.C,
                           NameOnCard = "Test",
                           AccountNumber = "4012000033330026",
                           RoutingNumber = "123456780",
                           ExpMonth = (string)null,
                           ExpYear = (string)null,
                       };

            var trnx = new
                       {
                           Amount = 1234.56m,
                       };

            var conn = new VancoConnection(ConfigurationManager.ConnectionStrings["Vanco"].ConnectionString);

            // Login
            var loginRequest = new LoginRequest();
            var loginResponse = loginRequest.Execute(conn);
            Console.WriteLine("SessionId: " + loginResponse.SessionId);

            // Add Payment method
            var eftRequest = new EftRequest
                             {
                                 CustomerId = cust.Id,
                                 AddNewCustomer = true,
                                 Name = cust.Name,
                                 Email = cust.Email,
                                 BillingAddr1 = cust.Address1,
                                 BillingCity = cust.City,
                                 BillingState = cust.State,
                                 BillingZip = cust.Zip,
                                 AccountType = card.AccountType,
                                 NameOnCard = card.NameOnCard,
                                 AccountNumber = card.AccountNumber,
                                 RoutingNumber = card.RoutingNumber,
                                 ExpMonth = card.ExpMonth,
                                 ExpYear = card.ExpYear,
                             };
            var eftResponse = eftRequest.Execute(conn);
            Console.WriteLine("PaymentMethodRef: " + eftResponse.PaymentMethodRef);

            // Get Payment Methods
            var methodsRequest = new PaymentMethodsRequest
                          {
                              CustomerId = cust.Id,
                          };
            var methodsResponse = methodsRequest.Execute(conn);
            Console.WriteLine("PaymentMethods: " + methodsResponse.PaymentMethodCount);

            // Transaction
            var trnxRequest = new TransactionRequest
                       {
                           CustomerId = cust.Id,
                           PaymentMethodRef = methodsResponse.PaymentMethods[methodsResponse.PaymentMethods.Count - 1].PaymentMethodRef,
                           Amount = trnx.Amount,
                           FrequencyCode = Frequencies.O,
                       };
            var trnxResponse = trnxRequest.Execute(conn);
            if (!string.IsNullOrWhiteSpace(trnxResponse.ErrorList))
            {
                Console.WriteLine("Error: " + VancoConnection.GetErrorMessages(trnxResponse.ErrorList));
            }
            Console.WriteLine("TrnxId: " + trnxResponse.TransactionRef);

            // Logout
            var logout = new LogoutRequest().Execute(conn);
            Console.WriteLine("Logout: " + logout);

            Console.ReadKey();
        }
开发者ID:pwhe23,项目名称:VancoApi,代码行数:85,代码来源:Program.cs


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