public override async Task <SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session) { if (AlexaUtils.IsRequestInvalid(session)) { return(await Task.FromResult <SpeechletResponse>(InvalidApplicationId(session))); } var intent = intentRequest.Intent; var intentName = intent?.Name; switch (intentName.ToUpper()) { case "BALANCE": return(await GetBalance.GetResults(session)); case "TRANSACTIONS": return(await GetTransactions.GetResults(session, intentRequest.Intent.Slots["date"].Value)); case "PAYMENT": return(await MakePayment.GetResults(session, decimal.Parse(intentRequest.Intent.Slots["amount"].Value), intentRequest.Intent.Slots["account"].Value)); case "WINNERS": return(await Winners.GetResults()); case "MORTGAGE": return(await Mortgage.GetResults(session)); case "SAVINGS": return(await Insights.GetResults(session)); default: return(await Task.FromResult <SpeechletResponse>(GetOnLaunchAsyncResult(session))); } }
public BillingInfoController(GovimithuroDbContext context, IConfiguration config, IMailService mailService, MakePayment makePayment) { _context = context; _config = config; _mailService = mailService; _makePayment = makePayment; }
/// <summary> /// Handle the event. /// </summary> /// <param name="event">The <see cref="IEvent"/> to handle.</param> public Task HandleAsync(SeatsReserved @event) { this.spy.Spy("SeatsReserved"); MakePayment makePayment = new MakePayment(); return(this.EventContext.Request.Processor.ProcessAsync(makePayment)); }
protected void Page_Load(object sender, EventArgs e) { if (Session["login"] == null) { lblcartcount.Text = "0"; } else { lblcartcount.Text = (Count.countcart(Convert.ToInt32(Session["login"])).ToString()); } if (Session["USERNAME"] != null) { MakePayment master = (MakePayment)Page.Master; Label lblusernameshow = (Label)master.FindControl("lblusernameshow"); Label lblusernameshow2 = (Label)master.FindControl("lblusernameshow2"); Label lblsignin = (Label)master.FindControl("lblsignin"); LinkButton lbllogout = (LinkButton)master.FindControl("lbllogout"); lblusernameshow.Visible = true; lblsignin.Visible = false; lbllogout.Visible = true; lblusernameshow.Text = "Hi" + " " + Session["USERNAME"]; lblusernameshow2.Text = "Hi" + " " + Session["USERNAME"]; } }
public IAggregate Handle(MakePayment command) { var basket = _domainRepository.GetById <Basket>(command.Id); var order = basket.MakePayment(command.Payment); return(order); }
protected void Page_Load(object sender, EventArgs e) { string orderid; if (!IsPostBack) { //orderid = Request.QueryString[0]; //lblorderid.Text = orderid; } if (Session["USERNAME"] != null) { MakePayment master = (MakePayment)Page.Master; Label lblusernameshow = (Label)master.FindControl("lblusernameshow"); lblcartcount = (Label)master.FindControl("lblcartcount"); Label lblusernameshow2 = (Label)master.FindControl("lblusernameshow2"); Label lblsignin = (Label)master.FindControl("lblsignin"); LinkButton lbllogout = (LinkButton)master.FindControl("lbllogout"); lblusernameshow.Visible = true; lblsignin.Visible = false; lbllogout.Visible = true; lblusernameshow.Text = "Hi" + " " + Session["USERNAME"]; lblusernameshow2.Text = "Hi" + " " + Session["USERNAME"]; } }
public PaymentsController(OnlineDBContext context, IConfiguration config, MakePayment makePayment) { _context = context; _config = config; /*_mailService = mailService;*/ _makePayment = makePayment; }
// this action implements payment with paystack public ActionResult MakePayment(MakePayment payment) { if (!ModelState.IsValid) { return(View("CreatePaymentForm")); } //get the secret key from appsettings //then pass into the paystackApi var TestSecret = ConfigurationManager.AppSettings["PayStackSecret"]; var api = new PayStackApi(TestSecret); //unique ref var result = Guid.NewGuid(); string UniqueReference = result.ToString(); //tryig to initialze transaction, wich in turn gives a refrence code var response = api.Transactions.Initialize(payment.Email, payment.Amount, UniqueReference); if (response.Status) { Response.AddHeader("Access-Control-Allow-Origin", "*"); Response.AppendHeader("Access-Control-Allow-Origin", "*"); Response.Redirect(response.Data.AuthorizationUrl); // response.Data.Reference; } else { //Handling Error } //Verifiyng response var verifyresponse = api.Transactions.Verify(response.Data.Reference); string authcode = null; if (verifyresponse.Status) { var authcode1 = response.Data.AccessCode; authcode = authcode1; } else { //Handling Error } //List transaction var listTransaction = api.Transactions.List(); //fetch transaction var fetchTransaction = api.Transactions.Fetch(UniqueReference); //charge Authorization var chargeAuthorization = api.Transactions.ChargeAuthorization(authcode, payment.Email, payment.Amount, response.Data.Reference); if (chargeAuthorization.Status) { // return } //Paystack Logic here return(View("Payment Succesfull")); }
public async Task <IActionResult> Pay(PaymentModel pm) { if (await MakePayment.PayAsync(pm.CardNumber, pm.Month, pm.Year, pm.Cvc, pm.Value)) { return(Ok()); } return(BadRequest("Charge Failed")); }
public void Handle(MakePayment makePayment) { var paymentReceipt = _paymentHandler.Handle(makePayment.Payment); if (paymentReceipt is FailureReceipt) { _eventAggregator.Publish(new Events.PaymentRejected()); } }
public JsonResult MakePayment(MakePayment makePayment) { try { using (var webService = new TransactionProcessingService.TransactionProcessingSoapClient()) { var result = webService.TestConnection(); var credResponse = webService.TestCredentials(storeId, storeKey, entityID, locationId, terminalNumber); WSTransaction transactionRequest = new WSTransaction() { EntityId = entityID, LocationId = Convert.ToInt32(locationId), PaymentOrigin = TransactionProcessingService.WSPaymentOrigin.Internet, AccountType = TransactionProcessingService.WSAccountType.Checking, OperationType = TransactionProcessingService.WSOperationType.Sale, SettlementType = TransactionProcessingService.WSSettlementType.ACH, EffectiveDate = DateTime.Now, Description = makePayment.Description, TotalAmount = makePayment.TotalAmount, TransactionNumber = makePayment.TransactionNumber, // "TestImage75", Field1 = "", Field2 = "", Field3 = "", //CheckMICRLine = "", //CheckMICRSymbolSet = "toad ?", RoutingNumber = makePayment.RoutingNumber, AccountNumber = makePayment.AccountNumber, CheckNumber = "1362", IsBusinessPayment = makePayment.IsBusinessPayment, NameOnAccount = makePayment.NameOnAccount, CheckFrontImageBytes_TiffG4 = null, CheckRearImageBytes_TiffG4 = null, PresentmentNumber = 0 }; var authTranResponse = webService.AuthorizeTransaction(storeId, storeKey, transactionRequest, WSOwnerApplication.Web_Service); return(Json(authTranResponse)); } } catch (Exception e) { throw e; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["USERNAME"] != null) { MakePayment master = (MakePayment)Page.Master; Label lblusernameshow = (Label)master.FindControl("lblusernameshow"); Label lblusernameshow2 = (Label)master.FindControl("lblusernameshow2"); Label lblsignin = (Label)master.FindControl("lblsignin"); LinkButton lbllogout = (LinkButton)master.FindControl("lbllogout"); lblusernameshow.Visible = true; lblsignin.Visible = false; lbllogout.Visible = true; lblusernameshow.Text = "Hi" + " " + Session["USERNAME"]; lblusernameshow2.Text = "Hi" + " " + Session["USERNAME"]; } }
/// <summary> /// Make a payment /// It is with this resource that we carry out our purchases. /// The checkout resource is used when we want to make a payment from A (buyer) to B (seller) and its validation depends on the stimulus of A. /// A checkout has a monetary value in currency (value), acronym for currency (currency), blockchain for transaction (blockchain), /// card number (pan), card password (password) and vendor identifier (vendorKey) /// </summary> /// <param name="makePayment"></param> /// <returns>Checkout</returns> public Checkout MakePayment(MakePayment makePayment) { try { //Convert to Sha256 makePayment.pan = Converts.ComputeSha256Hash(makePayment.pan); makePayment.password = Converts.ComputeSha256Hash(makePayment.password); string urlBase = this.SandBox ? GlobalType.URL_BASE_SANDBOX : GlobalType.URL_BASE_DEFAULT; string strJson = JsonConvert.SerializeObject(makePayment); byte[] buffer = Encoding.UTF8.GetBytes(strJson); HttpWebRequest httpWebRequest = HttpWebRequest.CreateHttp(urlBase + GlobalType.URL_CHECKOUT); httpWebRequest.Method = "POST"; httpWebRequest.Accept = "application/json"; httpWebRequest.ContentType = "application/json"; httpWebRequest.ContentLength = buffer.Length; httpWebRequest.GetRequestStream().Write(buffer, 0, buffer.Length); using (HttpWebResponse objResponse = httpWebRequest.GetResponse() as HttpWebResponse) { using (StreamReader strReader = new StreamReader(objResponse.GetResponseStream())) return(JsonConvert.DeserializeObject <Checkout>(strReader.ReadToEnd())); } } catch (Exception ex) { return(new Checkout() { status = new Status() { code = "-1", message = ex.Message } }); } }
public BookingStateMachine() { InstanceState(x => x.CurrentState); SubState(() => SuccessNotified, Succeeded); SubState(() => FailureNotified, Failed); SetCompletedWhenFinalized(); Initially( When(BookingCreatedEvent) .Then(context => { _logger.Information($"{GetType().Name}: {BookingCreatedEvent.Name} received: {JsonSerializer.Serialize(context.Data)}"); }) .Send(context => { var command = new MakePayment(context.Data.BookingId, DateTime.UtcNow); _logger.Information($"{GetType().Name}: {BookingCreatedEvent.Name}: Sending {command.GetType().Name}: {JsonSerializer.Serialize(command)}"); return(command); }) .TransitionTo(Created)); During(Created, When(PaymentInitiatedEvent) .Then(context => { _logger.Information($"{GetType().Name}: {PaymentInitiatedEvent.Name} received: {JsonSerializer.Serialize(context.Data)}"); }) .TransitionTo(PaymentInitiated)); During(PaymentInitiated, When(PaymentSucceededEvent) .Then(context => { _logger.Information($"{GetType().Name}: {PaymentSucceededEvent.Name} received: {JsonSerializer.Serialize(context.Data)}"); }) .Send(context => { var command = new NotifyBookingSuccess(context.Data.BookingId, DateTime.UtcNow); _logger.Information($"{GetType().Name}: {PaymentSucceededEvent.Name}: Sending {command.GetType().Name}: {JsonSerializer.Serialize(command)}"); return(command); }) .TransitionTo(Succeeded)); During(Succeeded, When(BookingSuccessNotifiedEvent) .Then(context => { _logger.Information($"{GetType().Name}: {BookingSuccessNotifiedEvent.Name} received: {JsonSerializer.Serialize(context.Data)}"); }) .TransitionTo(SuccessNotified) .Finalize()); During(PaymentInitiated, When(PaymentFailedEvent) .Then(context => { _logger.Information($"{GetType().Name}: {PaymentFailedEvent.Name} received: {JsonSerializer.Serialize(context.Data)}"); }) .Send(context => { var command = new NotifyBookingFailure(context.Data.BookingId, context.Data.Reason, DateTime.UtcNow); _logger.Information($"{GetType().Name}: {PaymentFailedEvent.Name}: Sending {command.GetType().Name}: {JsonSerializer.Serialize(command)}"); return(command); }) .TransitionTo(Failed)); During(Failed, When(BookingFailureNotifiedEvent) .Then(context => { _logger.Information($"{GetType().Name}: {BookingFailureNotifiedEvent.Name} received: {JsonSerializer.Serialize(context.Data)}"); }) .TransitionTo(FailureNotified) .Finalize()); Event(() => BookingCreatedEvent, x => x.CorrelateById(context => context.Message.BookingId)); Event(() => PaymentInitiatedEvent, x => x.CorrelateById(context => context.Message.BookingId)); Event(() => PaymentSucceededEvent, x => x.CorrelateById(context => context.Message.BookingId)); Event(() => BookingSuccessNotifiedEvent, x => x.CorrelateById(context => context.Message.BookingId)); Event(() => PaymentFailedEvent, x => x.CorrelateById(context => context.Message.BookingId)); Event(() => BookingFailureNotifiedEvent, x => x.CorrelateById(context => context.Message.BookingId)); Event(() => BookingCancelledEvent, x => x.CorrelateById(context => context.Message.BookingId)); }
public async Task <IActionResult> Pay([FromBody] PaymentModel pm) { var response = await MakePayment.PayAsync(pm.CardNumber, pm.Month, pm.Year, pm.Cvc, pm.Value); return(Ok(response)); }
public async Task <dynamic> Pay(Models.PaymentModel pm) { return(await MakePayment.PayAsync(pm.cardnumber, pm.month, pm.year, pm.cvc, pm.value)); }
public void Handle(MakePayment command) { var basket = this.basketRepository.GetById(command.Id); basket.MakePayment(command.Payment); }
public async Task <dynamic> Pay(Models.Payment p) { return(await MakePayment.PayAsync(p.CardNumber, p.Month, p.Year, p.Cvc, p.Value)); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); //#region Factory design pattern //ConsoleColorMethod("Factory design pattern"); //IFactory factory = CreateFactory.GetObject(ObjectType.Customer); //Console.WriteLine("Get customer object : " + factory.getName()); //factory = CreateFactory.GetObject(ObjectType.Supplier); //Console.WriteLine("Get supplier object : " + factory.getName()); //#endregion //#region Adapter design pattern //IExport target = new PDF_Class(); //target.Export(); //target = new XLS_Class_ObjectAdapter(); //target.Export(); //target = new XLS_Class_ClassAdapter(); //target.Export(); //#endregion //#region Builder design pattern //// Client Code //ReportDirector reportDirector = new ReportDirector(); //ExcelReport excelReport = new ExcelReport(); //Report report = reportDirector.MakeReport(excelReport); ////report.DisplayReport(); //#endregion #region Decorator design pattern IMemoryCache _memoryCache = new MemoryCache(new MemoryCacheOptions()); IWeatherService innerService = new WeatherService(); IWeatherService withCachingDecorator = new WeatherServiceCachingDecorator(innerService, _memoryCache); IWeatherService withLoggingDecorator = new WeatherServiceLoggingDecorator(withCachingDecorator); // with no cache - first time Console.WriteLine(withCachingDecorator.GetCurrentWeather("Bangalore")); // with cache - second time Console.WriteLine(withCachingDecorator.GetCurrentWeather("Bangalore")); // with no cache - first time Console.WriteLine(withLoggingDecorator.GetCurrentWeather("Bangalore")); // with cache - second time Console.WriteLine(withLoggingDecorator.GetCurrentWeather("Bangalore")); Console.ReadLine(); #endregion //#region Prototype Design Pattern //Employee emp1 = new Employee(); //emp1.Name = "Amit Naik"; //emp1.Department = "IT"; //Employee emp2 = emp1.GetClone(); //emp2.Name = "Shwetha"; //Console.WriteLine("Emplpyee 1: "); //Console.WriteLine("Name: " + emp1.Name + ", Department: " + emp1.Department); //Console.WriteLine("Emplpyee 2: "); //Console.WriteLine("Name: " + emp2.Name + ", Department: " + emp2.Department); //#endregion //#region Memento Design Pattern //Employee emp1 = new Employee(); //emp1.Name = "Amit Naik"; //emp1.Department = "IT"; //Employee emp2 = emp1.GetClone(); //emp2.Name = "Shwetha"; //Console.WriteLine("Emplpyee 1: "); //Console.WriteLine("Name: " + emp1.Name + ", Department: " + emp1.Department); ////Console.WriteLine("Emplpyee 2: "); ////Console.WriteLine("Name: " + emp2.Name + ", Department: " + emp2.Department); //Employee emp3 = emp1.Revert(); //Console.WriteLine("Reverting "); //Console.WriteLine("Name: " + emp3.Name + ", Department: " + emp3.Department); //#endregion //#region Aggregate root design pattern //Customer customer = new Customer(); //customer.Add(new Address { Type = 1 }); //customer.Add(new Address { Type = 1 }); //#endregion //#region Iterator design pattern //Customer customer = new Customer(); //customer.Add(new Address { Type = 1 }); //customer.Add(new Address { Type = 2 }); //// we can avoid manipulating methods like below in Iterator design pattern ////customer.addresses.Add(new Address { Type = 3 }); //// Implementing via Ienumerable //foreach (var item in customer.GetAddresses()) //{ // Console.WriteLine($"customer address type : {item.Type}"); //} //// Implementing via IEnumerator //foreach (var item in customer) //{ // Console.WriteLine($"customer address type : {item.Type}"); //} ////var x = customer.GetEnumerator(); //#endregion #region Generic Repository Design Pattern ConsoleColorMethod("Generic Repository design pattern"); // Generic IGenericRepository <Employee> repository = null; repository = new GenericRepository <Employee>(); try { var employee = new Employee() { Name = "Amit", Salary = 60000, Gender = "Male", Dept = "IT" }; repository.Add(employee); repository.Save(); repository = new GenericRepository <Employee>(); var id = repository.GetById(1); repository = new GenericRepository <Employee>(); var all = repository.GetAll(); repository = new GenericRepository <Employee>(); var id1 = repository.GetById(1); if (id1 != null) { id1.Name = "Amit Naik"; repository.Update(id1); repository.Save(); repository = new GenericRepository <Employee>(); repository.Delete(1); repository.Save(); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Error : ID not found"); Console.ForegroundColor = ConsoleColor.White; } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Error :{ex.Message}"); Console.ForegroundColor = ConsoleColor.White; } #endregion #region Non Generic Repository Design Pattern ConsoleColorMethod("Non Generic Repository design pattern"); // Generic EmployeeRepository employeeRepository = null; employeeRepository = new EmployeeRepository(); try { var employee = new Employee() { Name = "Shweta", Salary = 600000, Gender = "Female", Dept = "IT" }; employeeRepository.Add(employee); employeeRepository.Save(); employeeRepository = new EmployeeRepository(); var id = employeeRepository.GetById(1); employeeRepository = new EmployeeRepository(); var all = employeeRepository.GetAll(); employeeRepository = new EmployeeRepository(); var id1 = employeeRepository.GetById(2); if (id1 != null) { id1.Name = "Shweta Naik"; employeeRepository.Update(id1); employeeRepository.Save(); employeeRepository = new EmployeeRepository(); employeeRepository.Delete(1); employeeRepository.Save(); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Error : ID not found"); Console.ForegroundColor = ConsoleColor.White; } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Error :{ex.Message}"); Console.ForegroundColor = ConsoleColor.White; } #endregion #region UOW design pattern for Generic Repository ConsoleColorMethod("UOW design pattern for Generic Repository"); UOW_Generic <Employee> uowG = new UOW_Generic <Employee>(new EmployeeDBContext()); try { var employee = new Employee() { Name = "Shweta", Salary = 600000, Gender = "Female", Dept = "IT UOW generic" }; uowG.employeeRepository.Add(employee); uowG.Complete(); } catch (Exception ex) { uowG.Dispose(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Error : {ex.Message}"); Console.ForegroundColor = ConsoleColor.White; } #endregion #region UOW design pattern for Non Generic Repository ConsoleColorMethod("UOW design pattern for Non Generic Repository"); UnitOfWork uow = new UnitOfWork(new EmployeeDBContext()); try { var employee = new Employee() { Name = "Shweta", Salary = 600000, Gender = "Female", Dept = "IT UOW non generic" }; uow.employeeRepository.Add(employee); uow.Complete(); } catch (Exception ex) { uow.Dispose(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Error : {ex.Message}"); Console.ForegroundColor = ConsoleColor.White; } #endregion #region Template design pattern ConsoleColorMethod("Template design pattern"); TemplateHiringProcess hiringProcess = new CSDepartment(); Console.WriteLine("*** Hiring CS students"); hiringProcess.HireFreshers(); Console.WriteLine(Environment.NewLine); hiringProcess = new EEEDepartment(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("*** Hiring EEE students"); hiringProcess.HireFreshers(); #endregion #region Singleton Design Pattern ConsoleColorMethod("Singleton design pattern"); Singleton s1 = Singleton.getInstance(); Singleton s2 = Singleton.getInstance(); s1.myMethod(); // Test for same instance //if (s1 == s2) //{ // Console.WriteLine("Objects are the same instance"); //} #endregion #region Replace IF with Polyphormism ConsoleColorMethod("Replace IF with Polyphormism"); Console.WriteLine("Enter your skill set for job opening (like JavaScript,c#,Net)"); //string knowledge = Console.ReadLine(); string knowledge = "javascript"; Console.WriteLine(SimpleFactoryRIP.Create(knowledge.ToLower())); #endregion #region Abstract Factory design pattern ConsoleColorMethod("Abstract Factory design pattern"); var investmentPrivateFactory = InvestmentFactory.CreateFactory("Private"); string productType = investmentPrivateFactory.GetProduct("ICICI").FD(1000); Console.WriteLine(productType); Console.WriteLine(InvestmentFactory.CreateFactory("Public").GetProduct("SBI").MF(50000)); #endregion #region IOC DI Unity ConsoleColorMethod("IOC DI Unity"); IUnityContainer container = new UnityContainer(); container.RegisterType <IRechargeHandler, RechargeJIO>("JIO"); container.RegisterType <IRechargeHandler, RechargeVodafone>("Vodafone"); IRechargeHandler recharge = container.Resolve <IRechargeHandler>("JIO"); recharge.DoRecharge(); #endregion #region Lazy loading ConsoleColorMethod("Lazy loading"); Console.WriteLine("Enter your skill set for job opening (like JavaScript,c#,Net)"); string knowledgeLazyLoading = "Javascript"; Console.WriteLine(LazyLoadingFactory.Create(knowledgeLazyLoading.ToLower())); // When we call second time, it doesn't add to temp Dictionary in LazyLoadingFactory class file Console.WriteLine(LazyLoadingFactory.Create(knowledgeLazyLoading.ToLower())); #endregion #region Bridge design pattern ConsoleColorMethod("Bridge design pattern"); Payment order = new CardPayment(); order.IPaymentSystem = new CitiPaymentSystem(); order.MakePayment(); order.IPaymentSystem = new ICICIPaymentSystem(); order.MakePayment(); order = new NetBankingPayment(); order.IPaymentSystem = new CitiPaymentSystem(); order.MakePayment(); #endregion #region Composite design pattern ConsoleColorMethod("Composite design pattern"); IEmployeeCDP John = new EmployeeCDP("John", "IT"); IEmployeeCDP Mike = new EmployeeCDP("Mike", "IT"); IEmployeeCDP Jason = new EmployeeCDP("Jason", "HR"); IEmployeeCDP Eric = new EmployeeCDP("Eric", "HR"); IEmployeeCDP Henry = new EmployeeCDP("Henry", "HR"); IEmployeeCDP James = new ManagerCDP("James", "IT") { SubOrdinates = { John, Mike } }; IEmployeeCDP Philip = new ManagerCDP("Philip", "HR") { SubOrdinates = { Jason, Eric, Henry } }; IEmployeeCDP Bob = new ManagerCDP("Bob", "Head") { SubOrdinates = { James, Philip } }; James.GetDetails(1); #endregion #region Facade design pattern ConsoleColorMethod("Facade design pattern"); AadharFacade aadharFacade = new AadharFacade(); aadharFacade.CreateAadhar(); #endregion #region Chain of Responsibility design pattern ConsoleColorMethod("Chain of Responsibility design pattern"); NewVehicle selection = new SelectVehicle(); NewVehicle payment = new MakePayment(); NewVehicle serviceBook = new GenerateServiceBook(); NewVehicle insurance = new Insurance(); NewVehicle delivery = new Delivery(); selection.SetProcess(payment); payment.SetProcess(serviceBook); serviceBook.SetProcess(insurance); insurance.SetProcess(delivery); selection.Proceed("Bajaj Pulsar"); #endregion #region Strategy design pattern ConsoleColorMethod("Strategy design pattern"); HashingContext context; context = new HashingContext(new MD5Hash()); string strSHA1 = context.HashPassword("Amit Naik"); Console.WriteLine("Amit Naik - " + strSHA1); context = new HashingContext(new SHA384Hash()); string StrSHA384 = context.HashPassword("Shwetha Naik"); Console.WriteLine("Shwetha Naik - " + StrSHA384); #endregion #region Strategy design pattern ConsoleColorMethod("Strategy design pattern"); IImage Image1 = new ProxyImage("Tiger Image"); Console.WriteLine("Image1 calling DisplayImage first time :"); Image1.DisplayImage(); // loading necessary Console.WriteLine("Image1 calling DisplayImage second time :"); Image1.DisplayImage(); // loading unnecessary Console.WriteLine("Image1 calling DisplayImage third time :"); Image1.DisplayImage(); // loading unnecessary Console.WriteLine(); IImage Image2 = new ProxyImage("Lion Image"); Console.WriteLine("Image2 calling DisplayImage first time :"); Image2.DisplayImage(); // loading necessary Console.WriteLine("Image2 calling DisplayImage second time :"); Image2.DisplayImage(); // loading unnecessary #endregion #region Strategy design pattern ConsoleColorMethod("Strategy design pattern"); //Create a Product with Out Of Stock Status Subject IPhone = new Subject("IPhone Mobile", 10000, "Out Of Stock"); //User Anurag will be created and user1 object will be registered to the subject Observer user1 = new Observer("Amit", IPhone); //User Pranaya will be created and user1 object will be registered to the subject Observer user2 = new Observer("Shweta", IPhone); //User Priyanka will be created and user3 object will be registered to the subject Observer user3 = new Observer("Krishna", IPhone); Console.WriteLine("IPhone Mobile current state : " + IPhone.getAvailability()); Console.WriteLine(); // Now product is available IPhone.setAvailability("Available"); #endregion #region State design pattern ConsoleColorMethod("State design pattern"); // Initially Vending Machine will be 'noMoneyState' VendingMachine vendingMachine = new VendingMachine(); Console.WriteLine("Current VendingMachine State : " + vendingMachine.vendingMachineState.GetType().Name + "\n"); vendingMachine.DispenseProduct(); vendingMachine.SelectProductAndInsertMoney(50, "Pepsi"); // Money has been inserted so vending Machine internal state // changed to 'hasMoneyState' Console.WriteLine("\nCurrent VendingMachine State : " + vendingMachine.vendingMachineState.GetType().Name + "\n"); vendingMachine.SelectProductAndInsertMoney(50, "Fanta"); vendingMachine.DispenseProduct(); // Product has been dispensed so vending Machine internal state // changed to 'NoMoneyState' Console.WriteLine("\nCurrent VendingMachine State : " + vendingMachine.vendingMachineState.GetType().Name); #endregion }
public async Task <dynamic> Pay(Models.PaymentModel pm) { return(await MakePayment.PayAsync(pm.value, pm.currency, pm.stripeId)); }
public void buildExport() { Fbexplore fbexplore = new Fbexplore(ConfigurationManager.AppSettings["estream"]); if (!String.IsNullOrEmpty(fbexplore.LatestPath)) { Console.WriteLine($"Attempting to connect to latest DB : {fbexplore.LatestPath}\n"); try { // =================================== // Export new invoices to kiple home // =================================== Console.WriteLine($"Checking invoices for the past {ConfigurationManager.AppSettings["datespan"]} days.\n"); Ariv ariv = new Ariv(fbexplore.LatestPath); FbDataReader invoices = ariv.queryInvoice(); if (invoices.HasRows) { PosthocBill posthocBill = new PosthocBill(ref invoices); if (posthocBill.InvoiceLst.Count() != 0) { Console.WriteLine($"Invoice count: {posthocBill.InvoiceLst.Count()}\n"); ExportBill.dump(posthocBill.InvoiceLst, 0); } else { Console.WriteLine($"No invoice(s) found for the past {ConfigurationManager.AppSettings["datespan"]} days.\n"); } } else { Console.WriteLine($"No invoice(s) found for the past {ConfigurationManager.AppSettings["datespan"]} days.\n"); } // =================================================================================== // Check kiple home for pending invoices. Export payments back to kiple home if any. // =================================================================================== Console.WriteLine("Checking for pending payments: Connecting to Kiple Home ...\n"); AssertBills assertBills = new AssertBills(); if (!(assertBills.Bills is null) && assertBills.Bills.Count != 0) { Console.WriteLine($"Outstanding Bills from KipleHome : {assertBills.Bills.Count} \n"); UpdateBills updateBills = new UpdateBills(assertBills.Bills, fbexplore.LatestPath); updateBills.exportPayment(); } else { Console.WriteLine("No outstanding bills. \n"); } // ===================================================== // Check kiple home for payments made through KipleBiz // ===================================================== Console.WriteLine("Checking for payments made via KipleHome App ... \n"); AdyenPayment adyenPayment = new AdyenPayment(); if (!(adyenPayment.Payments is null) && adyenPayment.Payments.Count != 0) { Console.WriteLine($"Inserting {adyenPayment.Payments.Count} payment(s) to local database ... \n"); MakePayment makePayment = new MakePayment(adyenPayment.Payments, fbexplore.LatestPath); makePayment.insertPayments(); }
static void Main(string[] args) { ApusPaymentsAPI apusPaymentsAPI = new ApusPaymentsAPI(EnviromentType.SandBox); string pan = "9999999999999999"; string password = "******"; string vendorKey = "5f5bdaed-f82b-4b82-b3f5-1d562633da5b"; string vendorPassword = "******"; // Make a payment MakePayment makePayment = new MakePayment(); makePayment.pan = pan; makePayment.password = password; makePayment.blockchain = BlockChainType.LTC; makePayment.amount = 13.88; makePayment.currency = CurrencyType.BRL; makePayment.vendorKey = vendorKey; var makePaymentReturn = apusPaymentsAPI.MakePayment(makePayment); Console.WriteLine("MakePayment: " + JsonConvert.SerializeObject(makePaymentReturn)); Console.WriteLine(""); // Make a recurring payment MakeRecurringPayment makeRecurringPayment = new MakeRecurringPayment(); makeRecurringPayment.pan = pan; makeRecurringPayment.password = password; makeRecurringPayment.blockchain = BlockChainType.LTC; makeRecurringPayment.amount = 13.88; makeRecurringPayment.currency = CurrencyType.BRL; makeRecurringPayment.period = PeriodType.M; makeRecurringPayment.vendorKey = vendorKey; var makeRecurringPaymentReturn = apusPaymentsAPI.MakeRecurringPayment(makeRecurringPayment); Console.WriteLine("Make a Recurring Payment: " + JsonConvert.SerializeObject(makeRecurringPaymentReturn)); Console.WriteLine(""); // Search payment SearchPayment searchPayment = new SearchPayment(); searchPayment.vendorKey = vendorKey; searchPayment.txId = ""; searchPayment.timestamp = ""; searchPayment.blockchain = BlockChainType.LTC; searchPayment.currency = CurrencyType.BRL; searchPayment.coinAmount = ""; searchPayment.currencyAmount = ""; searchPayment.buyer = ""; var searchPaymentReturn = apusPaymentsAPI.SearchPayment(searchPayment); Console.WriteLine("Search Payment: " + JsonConvert.SerializeObject(searchPaymentReturn)); Console.WriteLine(""); // Cancel CancelPayment cancelPayment = new CancelPayment(); cancelPayment.txId = "2bf779e2a311c2629df977b0bb105879411fd71f5839972c4ed1d3278f80170f"; cancelPayment.password = vendorPassword; cancelPayment.vendorKey = vendorKey; var cancelPaymentReturn = apusPaymentsAPI.CancelPayment(cancelPayment); Console.WriteLine("Cancel a Payment: " + JsonConvert.SerializeObject(cancelPaymentReturn)); Console.WriteLine(""); RechargeCryptoBalance rechargeCryptoBalance = new RechargeCryptoBalance(); rechargeCryptoBalance.pan = pan; rechargeCryptoBalance.password = password; rechargeCryptoBalance.blockchain = BlockChainType.LTC; rechargeCryptoBalance.amount = 13.88; rechargeCryptoBalance.currency = CurrencyType.BRL; rechargeCryptoBalance.vendorKey = vendorKey; var rechargeCryptoBalanceReturn = apusPaymentsAPI.RechargeCryptoBalance(rechargeCryptoBalance); Console.WriteLine("Recharge of Crypto Balance: " + JsonConvert.SerializeObject(rechargeCryptoBalanceReturn)); Console.WriteLine(""); Console.ReadKey(); }