public static void Pay() { Console.WriteLine("Kaznachey pay"); var kaznachey = new KaznacheyPaymentSystem(Configuration.KaznacheyMerchantId, Configuration.KaznacheyMerchantSecreet); foreach (var paySystem in kaznachey.GetMerchantInformation().PaySystems) { Console.WriteLine("{0} {1}", paySystem.Id, paySystem.PaySystemName); } var paySystemId = kaznachey.GetMerchantInformation().PaySystems[0].Id; var paymentRequest = new PaymentRequest(paySystemId); paymentRequest.Language = "RU"; paymentRequest.Currency = "UAH"; paymentRequest.PaymentDetail = new PaymentDetails { EMail = "*****@*****.**", MerchantInternalUserId = "user id", MerchantInternalPaymentId = "ticker id", BuyerFirstname = "Anton", BuyerLastname = "Boyko", ReturnUrl = "http://azureday-2016-06-stage.azurewebsites.net/profile/my", StatusUrl = "http://azureday-2016-06-stage.azurewebsites.net/profile/paymentconfirm" }; paymentRequest.Products = new List <Product> { new Product { ProductId = "ticket type", ProductItemsNum = 1, ProductName = "ticket type and user name", ProductPrice = 270 } }; var form = kaznachey.CreatePayment(paymentRequest).ExternalFormHtml; Console.WriteLine(form); }
private PayFormModel GetPaymentForm(List <Ticket> tickets) { if (tickets == null) { throw new ArgumentNullException(nameof(tickets)); } if (!tickets.Any()) { throw new ArgumentException(nameof(tickets)); } KaznacheyPaymentSystem kaznachey; int paySystemId; if (string.IsNullOrEmpty(tickets[0].PaymentType)) { kaznachey = new KaznacheyPaymentSystem(Configuration.KaznacheyMerchantId, Configuration.KaznacheyMerchantSecreet); paySystemId = kaznachey.GetMerchantInformation().PaySystems[0].Id; } else { switch (tickets[0].PaymentType.ToLowerInvariant()) { case "kaznachey": kaznachey = new KaznacheyPaymentSystem(Configuration.KaznacheyMerchantId, Configuration.KaznacheyMerchantSecreet); paySystemId = kaznachey.GetMerchantInformation().PaySystems[0].Id; break; case "liqpay": kaznachey = new KaznacheyPaymentSystem(Configuration.KaznacheyMerchantId, Configuration.KaznacheyMerchantSecreet); paySystemId = 1021; break; default: kaznachey = new KaznacheyPaymentSystem(Configuration.KaznacheyMerchantId, Configuration.KaznacheyMerchantSecreet); paySystemId = kaznachey.GetMerchantInformation().PaySystems[0].Id; break; } } var paymentRequest = new PaymentRequest(paySystemId); paymentRequest.Language = "RU"; paymentRequest.Currency = "UAH"; paymentRequest.PaymentDetail = new PaymentDetails { EMail = tickets[0].Attendee.EMail, MerchantInternalUserId = tickets[0].Attendee.EMail, MerchantInternalPaymentId = $"{tickets[0].Attendee.EMail}-{string.Join("-", tickets.Select(x => x.TicketType.ToString()))}", BuyerFirstname = tickets[0].Attendee.FirstName, BuyerLastname = tickets[0].Attendee.LastName, ReturnUrl = $"{Configuration.Host}/profile/my", StatusUrl = $"{Configuration.Host}/api/tickets/paymentconfirm" }; paymentRequest.Products = new List <Product> { new Product { ProductId = string.Join("-", tickets.Select(x => x.TicketType.ToString())), ProductItemsNum = 1, ProductName = $"{tickets[0].Attendee.FirstName} {tickets[0].Attendee.LastName} билет на AzureDay {Configuration.Year} ({string.Join("-", tickets.Select(x => x.TicketType.ToString()))})", ProductPrice = (decimal)tickets.Sum(x => x.Price) } }; var form = kaznachey.CreatePayment(paymentRequest).ExternalFormHtml; var model = new PayFormModel { Form = form }; return(model); }
private PayFormModel GetPaymentForm(Ticket ticket) { KaznacheyPaymentSystem kaznachey; int paySystemId; switch (ticket.PaymentType.ToLowerInvariant()) { case "kaznackey": kaznachey = new KaznacheyPaymentSystem(Configuration.KaznackeyMerchantId, Configuration.KaznackeyMerchantSecreet); paySystemId = kaznachey.GetMerchantInformation().PaySystems[0].Id; break; case "liqpay": kaznachey = new KaznacheyPaymentSystem(Configuration.LiqPayMerchantId, Configuration.LiqPayMerchantSecreet); paySystemId = kaznachey.GetMerchantInformation().PaySystems[3].Id; break; default: kaznachey = new KaznacheyPaymentSystem(Configuration.KaznackeyMerchantId, Configuration.KaznackeyMerchantSecreet); paySystemId = kaznachey.GetMerchantInformation().PaySystems[0].Id; break; } var paymentRequest = new PaymentRequest(paySystemId); paymentRequest.Language = "RU"; paymentRequest.Currency = "UAH"; paymentRequest.PaymentDetail = new PaymentDetails { EMail = ticket.Attendee.EMail, MerchantInternalUserId = ticket.Attendee.EMail, MerchantInternalPaymentId = string.Format("{0}-{1}", ticket.Attendee.EMail, ticket.TicketType), BuyerFirstname = ticket.Attendee.FirstName, BuyerLastname = ticket.Attendee.LastName, ReturnUrl = string.Format("{0}/profile/my", _host), StatusUrl = string.Format("{0}/api/tickets/paymentconfirm", _host) }; paymentRequest.Products = new List<Product> { new Product { ProductId = ticket.TicketType.ToString(), ProductItemsNum = 1, ProductName = string.Format("{0} {1} билет на AzureDay {2} ({3})", ticket.Attendee.FirstName, ticket.Attendee.LastName, Configuration.Year, ticket.TicketType.ToDisplayString()), ProductPrice = (decimal) ticket.Price } }; var form = kaznachey.CreatePayment(paymentRequest).ExternalFormHtml; var model = new PayFormModel { Form = form }; return model; }