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 CreateCustomerResponse Updatetokendetails(string tokenid)
        {
            IRapidClient ewayClient = RapidClientFactory.NewRapidClient(apiKey, password, rapidEndpoint);

            Customer customer = new Customer()
            {
                Title     = "Mr.",
                FirstName = "Tom",
                LastName  = "Jones",
                Address   = new Address()
                {
                    Country = "au"
                },
                CardDetails = new CardDetails()
                {
                    Name        = "Tom Jones",
                    Number      = "4444333322221111",
                    ExpiryMonth = "12",
                    ExpiryYear  = "25",
                    CVN         = "123"
                },
                TokenCustomerID = tokenid,
            };

            CreateCustomerResponse response = ewayClient.UpdateCustomer(PaymentMethod.Direct, customer);

            ViewBag.response = response;
            QueryCustomerResponse customerresponse = ewayClient.QueryCustomer(long.Parse(tokenid));

            return(response);
        }
        public ActionResult Ewayresponse(String AccessCode)
        {
            IRapidClient ewayClient = RapidClientFactory.NewRapidClient(apiKey, password, rapidEndpoint);

            QueryTransactionResponse response = ewayClient.QueryTransaction(AccessCode);
            string tokenid = response.Transaction.Customer.TokenCustomerID;

            //save the tokenid and response for the view
            ViewBag.token    = tokenid;
            ViewBag.response = response;


            if ((bool)response.TransactionStatus.Status)
            {
                Console.WriteLine("Payment successful! ID: " + response.TransactionStatus.TransactionID);
                //Get organisation name to save in CssPaymentSetup
                QueryCustomerResponse customerresponse = ewayClient.QueryCustomer(long.Parse(tokenid));

                string[] orgN    = customerresponse.Customers.Select(c => c.CompanyName).ToArray();
                string   orgname = orgN[0];

                int orgid;
                using (AimyEntities db = new AimyEntities())
                {
                    int[] orgids = db.Orgs.Where(o => o.Name == orgname).Select(o => o.Id).ToArray();
                    orgid = orgids[0];
                }
                //Get the credit card details to save in CssPaymentSetup
                string[] cd         = customerresponse.Customers.Select(cc => cc.CardDetails).Select(d => d.Number).ToArray();
                string   creditcard = cd[0];

                using (AimyEntities db = new AimyEntities())
                {
                    CssPaymentSetup savetoken = new CssPaymentSetup();
                    savetoken.CustomerId       = tokenid;
                    savetoken.IsActive         = true;
                    savetoken.MaskedCardNumber = creditcard;
                    savetoken.OrgId            = orgid;
                    savetoken.CreatedOn        = DateTime.Today;
                    //CreatedBy is the userid that can be retrieve from session current user -- for now we assign 3694
                    savetoken.CreatedBy = 3694;

                    db.CssPaymentSetups.Add(savetoken);
                    db.SaveChanges();
                };
            }
            else if (tokenid == null)
            {
                string[] errorCodes = response.TransactionStatus.ProcessingDetails.ResponseMessage.Split(new[] { ", " }, StringSplitOptions.None);

                foreach (string errorCode in errorCodes)
                {
                    Console.WriteLine("Response Message: "
                                      + RapidClientFactory.UserDisplayMessage(errorCode, "EN"));
                }
            }

            return(View());
        }
        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));
        }
Exemple #6
0
 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);
     });
 }
Exemple #7
0
        public ActionResult PaymentDetails(DirectPay model, IRapidClient eway)
        {
            DirectPay paymodel = new DirectPay
            {
                //customer details
                Title     = Request["txt-title"].ToString(),
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Email     = model.Email,
                //card details
                CardName        = model.CardName,
                CardNumber      = model.CardNumber,
                CardExpiryMonth = Request["txt-cardmonth"].ToString(),
                CardExpiryYear  = Request["txt-cardyear"].ToString(),
                CVN             = model.CVN,
                //donation amount
                TotalAmount = Convert.ToInt16(model.TotalAmount)
            };

            return(RedirectToAction("DonatingDetails", "DirectPay", paymodel));
        }
Exemple #8
0
 public HomeController(ILogger <HomeController> logger, IRapidClient rapidClient)
 {
     _logger      = logger;
     _rapidClient = rapidClient;
 }
 public void Initialize()
 {
     _client = CreateRapidApiClient();
 }
Exemple #10
0
        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));
        }
Exemple #11
0
 public void Initial()
 {
     _client  = CreateRapidApiClient();
     _request = TestUtil.CreateEnrollRequest();
 }