public async System.Threading.Tasks.Task <HttpStatusCodeResult> ProcessIPN() { PaymentGatewayManager _gatewayManager = new PaymentGatewayManager(Globals.DBConnectionKey); NetworkHelper network = new NetworkHelper(); string ip = network.GetClientIpAddress(this.Request); #if DEBUG string ipnSample = @"mc_gross = 19.95 & protection_eligibility = Eligible & address_status = confirmed & payer_id = LPLWNMTBWMFAY & tax = 0.00 & address_street = 1 + Main + St & payment_date = 20 % 3A12 % 3A59 + Jan + 13 % 2C + 2009 + PST & payment_status = Completed & charset = windows - 1252 & address_zip = 95131 & first_name = Test & mc_fee = 0.88 & address_country_code = US & address_name = Test + User & notify_version = 2.6 & custom = d5422cf40f364cd99cac5fb3df7c12f6 &payer_status = verified & address_country = United + States & address_city = San + Jose & quantity = 1 & verify_sign = AtkOfCXbDm2hu0ZELryHFjY - Vb7PAUvS6nMXgysbElEn9v - 1XcmSoGtf & payer_email = gpmac_1231902590_per % 40paypal.com & txn_id = 61E67681CH3238416 & payment_type = instant & last_name = User & address_state = CA & receiver_email = gpmac_1231902686_biz % 40paypal.com & payment_fee = 0.88 & receiver_id = S8XGHLYDW9T3S & txn_type = express_checkout & item_name = &mc_currency = USD & item_number = &residence_country = US & test_ipn = 1 & handling_amount = 0.00 & transaction_subject = &payment_gross = 19.95 & shipping = 0.00"; _gatewayManager.ProcessIpn(ipnSample, ip); #else byte[] paramArray = await Request.Content.ReadAsByteArrayAsync(); var content = System.Text.Encoding.ASCII.GetString(paramArray); //Fire and forget verification task //Thread t = new Thread(() => _gatewayManager.ProcessIpn(content, ip)); //t.Start(); #endif return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
static void Main(string[] args) { IInventory inventory = new InventoryManager(); IOrderVerify orderVerify = new OrderVerificationManager(); ICosting costManger = new CostManager(); IPaymentGateway paymentGateWay = new PaymentGatewayManager(); ILogistics logistics = new LogisticsManager(); // Creating the Order/Product details OrderDetails orderDetails = new OrderDetails("C# Design Pattern Book", "Simplified book on design patterns in C#", 500, 10, "Street No 1", "Educational Area", 1212, "4156213754" ); // Client Code without Facade. // Updating the inventory. inventory.Update(orderDetails.ProductNo); // Verfying various details for the order such as the shipping address. orderVerify.VerifyShippingAddress(orderDetails.PinCode); // Calculating the final cost after applying various discounts. orderDetails.Price = costManger.ApplyDiscounts(orderDetails.Price, orderDetails.DiscountPercent ); // Going through various steps if payment gateway like card verification, charging from the card. paymentGateWay.VerifyCardDetails(orderDetails.CardNo); paymentGateWay.ProcessPayment(orderDetails.CardNo, orderDetails.Price); // Completing the order by providing Logistics. logistics.ShipProduct(orderDetails.ProductName, string.Format("{0}, {1} - {2}.", orderDetails.AddressLine1, orderDetails.AddressLine2, orderDetails.PinCode)); //Facade OrderOnlineFacade facade = new OrderOnlineFacade(inventory, costManger, logistics, orderVerify, paymentGateWay); facade.FinalizeOrder(orderDetails); Console.ReadLine(); }
public PaymentServiceFixture() { var paymentGatewayManager = new PaymentGatewayManager(); var cheapPaymentGateway = new CheapPaymentGateway(paymentGatewayManager); var expensivePaymentGateway = new ExpensivePaymentGateway(paymentGatewayManager); var premiumPaymentGateway = new PremiumPaymentGateway(paymentGatewayManager); var unitOfWork = new Mock <IUnitOfWork>(); unitOfWork.Setup(uow => uow.Payments.Add(It.IsAny <Payment>())); PaymentService = new Services.Business.PaymentService(cheapPaymentGateway, expensivePaymentGateway, premiumPaymentGateway, unitOfWork.Object); }
private static void OnlineShoppingSystem() { Console.WriteLine(""); Console.WriteLine("================ Online Shopping Without Facade Object ==============="); Console.WriteLine(""); // Creating the Order/Product details OrderDetails orderDetails = new OrderDetails( "C# Design Pattern Book", //Product Name "Simplified book on design patterns in C#", //Description 500, //Price 10, //Discount in % "SF-1, Chitrakut Complex", //Address Line 1 "Nr. Pasha Bhai Park, Gotri, Vadodara, Gujarat, India", //Address Line 2 390007, // Pincode "4156213754" //Card details ); // Updating the inventory. IInventory inventory = new InventoryManager(); inventory.Update(orderDetails.ProductNo); // Verfying various details for the order such as the shipping address. IOrderVerify orderVerify = new OrderVerificationManager(); orderVerify.VerifyShippingAddress(orderDetails.PinCode); // Calculating the final cost after applying various discounts. ICosting costManger = new CostManager(); orderDetails.Price = costManger.ApplyDiscounts(orderDetails.Price, orderDetails.DiscountPercent); // Going through various steps if payment gateway like card verification, charging from the card. IPaymentGateway paymentGateWay = new PaymentGatewayManager(); paymentGateWay.VerifyCardDetails(orderDetails.CardNo); paymentGateWay.ProcessPayment(orderDetails.CardNo, orderDetails.Price); // Completing the order by providing Logistics. ILogistics logistics = new LogisticsManager(); logistics.ShipProduct(orderDetails.ProductName, $"{orderDetails.AddressLine1}, {orderDetails.AddressLine2} - {orderDetails.PinCode}."); }
public PaymentGateway() { _gatewayManager = new PaymentGatewayManager(Globals.DBConnectionKey); _logger = new SystemLogger(Globals.DBConnectionKey); }