public ActionResult TokenNoPayment() { IRapidClient ewayClient = RapidClientFactory.NewRapidClient(apiKey, password, rapidEndpoint); Customer customer = new Customer() { Title = "Ms.", FirstName = "Jane", LastName = "Smith", Address = new Address() { Country = "nz" }, CompanyName = "SKIDS HO[DisableForTesting]", Url = "http://localhost:53738", RedirectURL = "http://localhost:53738/Home/Ewayresponse" }; CreateCustomerResponse Customerresponse = ewayClient.Create(PaymentMethod.ResponsiveShared, customer); if (Customerresponse.Errors != null) { foreach (string errorCode in Customerresponse.Errors) { Console.WriteLine("Error Message: " + RapidClientFactory.UserDisplayMessage(errorCode, "EN")); } } return(Redirect(Customerresponse.SharedPaymentUrl)); }
public ActionResult UseToken(string token) { IRapidClient ewayClient = RapidClientFactory.NewRapidClient(apiKey, password, rapidEndpoint); //1. Charging the customer with token ... note refer to https://eway.io/api-v3/#token-payments // tokenpayment method is not used in rapid sdk Api Transaction transaction = new Transaction() { Customer = new Customer() { TokenCustomerID = token, }, PaymentDetails = new PaymentDetails() { TotalAmount = 10000, InvoiceNumber = "14632" }, RedirectURL = "http://localhost:53738/Home/Ewayresponse", TransactionType = TransactionTypes.Recurring }; CreateTransactionResponse response = ewayClient.Create(PaymentMethod.Direct, transaction); if (response.Errors != null) { foreach (string errorCode in response.Errors) { Console.WriteLine("Error Message: " + RapidClientFactory.UserDisplayMessage(errorCode, "EN")); } } ViewBag.token = token; ViewBag.response = response; //ViewBag.totalamount = int totalamount = response.Transaction.PaymentDetails.TotalAmount / 100; ViewBag.totalamount = totalamount; return(View()); }
public ActionResult TokenWithPayment() { IRapidClient ewayClient = RapidClientFactory.NewRapidClient(apiKey, password, rapidEndpoint); Customer customer = new Customer() { Title = "Ms.", FirstName = "Jane", LastName = "Smith", Address = new Address() { Country = "nz" }, CompanyName = "SKIDS HO[DisableForTesting]", Url = "http://localhost:53738", RedirectURL = "http://localhost:53738/Home/Ewayresponse" }; Transaction transaction = new Transaction() { Customer = customer, PaymentDetails = new PaymentDetails() { TotalAmount = 10000, InvoiceDescription = "Parent subscription", InvoiceNumber = "4536", }, RedirectURL = "http://localhost:53738/Home/Ewayresponse", TransactionType = TransactionTypes.Purchase, SaveCustomer = true, }; CreateTransactionResponse transactionresponse = ewayClient.Create(PaymentMethod.ResponsiveShared, transaction); if (transactionresponse.Errors != null) { foreach (string errorCode in transactionresponse.Errors) { Console.WriteLine("Error Message: " + RapidClientFactory.UserDisplayMessage(errorCode, "EN")); } } return(Redirect(transactionresponse.SharedPaymentUrl)); }
public void Multithread_CreatingMultipleClientsInManyThreads_ReturnsValidData() { RunInMultipleThreads(20, () => { IRapidClient client = CreateRapidApiClient(); Transaction transaction = new Transaction() { Customer = TestUtil.CreateCustomer(), PaymentDetails = new PaymentDetails() { TotalAmount = 200 }, TransactionType = TransactionTypes.MOTO, }; CreateTransactionResponse response = client.Create(PaymentMethod.Direct, transaction); }); }
public ActionResult DonatingDetails(DirectPay directPayModel) { IRapidClient ewayClient = RapidClientFactory.NewRapidClient(APIKEY, PASSWORD, ENDPOINT); Transaction transaction = new Transaction() { Customer = new Customer() { Title = directPayModel.Title, FirstName = directPayModel.FirstName, LastName = directPayModel.LastName, Email = directPayModel.Email, CardDetails = new CardDetails() { Name = directPayModel.CardName, Number = directPayModel.CardNumber, ExpiryMonth = directPayModel.CardExpiryMonth, ExpiryYear = directPayModel.CardExpiryYear, CVN = directPayModel.CVN, } }, PaymentDetails = new PaymentDetails() { TotalAmount = directPayModel.TotalAmount }, TransactionType = TransactionTypes.Purchase, }; CreateTransactionResponse response = ewayClient.Create(PaymentMethod.Direct, transaction); if (response.Errors != null) { foreach (string errorCode in response.Errors) { if (errorCode == "V6100") { Message = "Error message: Invalid Credit card name entered, please check the name and try again!!!."; } else if (errorCode == "V6101" || errorCode == "V6102") { Message = "Error message: Invalid Expiryd Date entered,please check the date and try again!!!."; } else if (errorCode == "V6106") { Message = "Error message: Invalid CVN entered,please check the CVN and try again!!!."; } else if (errorCode == "V6110") { Message = "Error message: Invalid card number entered,please check the cardnumber and try again!!!."; } resultModel = new Result { Status = "Payment Failure!!!", Description = Message }; } } else { if ((bool)response.TransactionStatus.Status) { Message = ("Thanks for donating to Charity. Please note your transaction ID: " + response.TransactionStatus.TransactionID); resultModel = new Result { Status = "Payment Success!!!", Description = Message }; } } return(RedirectToAction("Result", "Results", resultModel)); }