private void ProcessOnPayPalProUSPayment(CheckoutDetails checkout) { PayPalProUSPaymentMethod paypalPayment = (PayPalProUSPaymentMethod)checkout.PaymentMethod; bool result = false; PaymentAppResult paymentResult; RecurringPaymentResult recurringPaymentResult; ProcessPaymentService process = ProcessPaymentService.CreateNew(new HttpService(), StoreContext.ShoppingCart); result = process.ProcessPayPalProUSPayment( StoreContext.GetOrderAmount().Total, DataAccessContext.CurrencyRepository.GetOne(DataAccessContext.Configurations.GetValue("PaymentCurrency")), StoreContext.Culture, checkout, StoreContext.ShoppingCart, StoreContext.Customer, UrlPath.StorefrontUrl, WebUtilities.GetVisitorIP(), out paymentResult, out recurringPaymentResult); if (result) { OrderCreateService orderCreateService = new OrderCreateService( StoreContext.ShoppingCart, StoreContext.CheckoutDetails, StoreContext.Culture, CurrenntCurrency, AffiliateHelper.GetAffiliateCode(), WebUtilities.GetVisitorIP(), recurringPaymentResult ); Order order; OrderAmount amount = orderCreateService.GetOrderAmount(StoreContext.Customer) .Add(CartItemPromotion.CalculatePromotionShippingAndTax( StoreContext.CheckoutDetails, StoreContext.ShoppingCart.SeparateCartItemGroups(), StoreContext.Customer)); order = orderCreateService.PlaceOrder(amount, StoreContext.Customer, DataAccessContext.StoreRetriever, StoreContext.Culture); GiftRegistry.UpdateGiftRegistryQuantity(StoreContext.ShoppingCart, StoreContext.CheckoutDetails); CustomerRewardPoint.UpdateRedeemPoint(StoreContext.CheckoutDetails, StoreContext.Customer, order); OrderNotifyService orderBusiness = new OrderNotifyService(order.OrderID); ProcessCreditCardPaymentSuccess( orderBusiness, paymentResult.GatewayOrderID, paymentResult.PaymentLog, paymentResult.CvvStatus, paymentResult.AvsAddrStatus, paymentResult.AvsZipStatus); } else { ProcessCreditCardPaymentFailure(paymentResult.ErrorMessage); } }
private string GetPaymentName() { PaymentMethod payment; if (!String.IsNullOrEmpty(Invoice)) { return("PayPal"); } else { payment = new PayPalProUSPaymentMethod(); } return(payment.Name); }
private void ProcessRecurringCancelPayPalPro(string referenceID, int recurringID, string emailCustomer, string username, string orderID) { string errorMessage; Order order = DataAccessContext.OrderRepository.GetOne(orderID); Store store = DataAccessContext.StoreRepository.GetOne(order.StoreID); string companyEmail = DataAccessContext.Configurations.GetValue("CompanyEmail", store); if (PayPalProUSPaymentMethod.ManageRecurring( referenceID, emailCustomer, username, orderID, PayPalProUSPaymentMethod.RecurringStatus.Cancel, companyEmail, String.Empty, out errorMessage)) { ProcessRecurringCancelComplete(referenceID); } else { uxMessage.DisplayError(errorMessage); } }
private void ProcessOnPayPalProUSPayment(CheckoutDetails checkout) { PayPalProUSPaymentMethod paypalPayment = (PayPalProUSPaymentMethod)checkout.PaymentMethod; bool result = false; PaymentAppResult paymentResult; RecurringPaymentResult recurringPaymentResult; ProcessPaymentService process = ProcessPaymentService.CreateNew(new HttpService(), StoreContext.ShoppingCart); result = process.ProcessPayPalProUSPayment( StoreContext.GetOrderAmount().Total, DataAccessContext.CurrencyRepository.GetOne(DataAccessContext.Configurations.GetValue("PaymentCurrency")), StoreContext.Culture, checkout, StoreContext.ShoppingCart, StoreContext.Customer, UrlPath.StorefrontUrl, WebUtilities.GetVisitorIP(), out paymentResult, out recurringPaymentResult); if (result) { OrderCreateService orderCreateService = new OrderCreateService( StoreContext.ShoppingCart, StoreContext.CheckoutDetails, StoreContext.Culture, StoreContext.Currency, AffiliateHelper.GetAffiliateCode(), WebUtilities.GetVisitorIP(), recurringPaymentResult ); Order order; OrderAmount orderAmount; if (!IsAnonymousCheckout()) { order = PlaceOrder(orderCreateService, out orderAmount); } else { order = PlaceOrderAnonymous(SystemConst.UnknownUser, orderCreateService, checkout, out orderAmount); } AffiliateOrder affiliateorder = new AffiliateOrder(); affiliateorder.AffiliateCode = AffiliateHelper.GetAffiliateCode(); affiliateorder.CreateAffiliateOrder(order.OrderID, orderAmount.Subtotal, orderAmount.Discount); OrderNotifyService orderBusiness = new OrderNotifyService(order.OrderID); ProcessCreditCardPaymentSuccess( orderBusiness, paymentResult.GatewayOrderID, paymentResult.PaymentLog, paymentResult.CvvStatus, paymentResult.AvsAddrStatus, paymentResult.AvsZipStatus); } else { ProcessCreditCardPaymentFailure(paymentResult.ErrorMessage); } }
private void ProcessRecurringPayment() { try { Log.Debug(" ----- Start ProcessRecurringPayment() ----- "); Log.Debug(" PaymentStatus : " + PaymentStatus); String orderID = ""; if (PaymentStatus == "Completed") { Log.Debug("++++++++++ Enter CreateChildOrderByPayPalRefenceID ++++++++++"); int allSequence; orderID = PayPalProUSPaymentMethod.CreateChildOrderByPayPalRefenceID( RecurringReferenceID, RecurringAmount, RecurringStatus, PaymentStatus, ReceiptID, PeriodType, DateTime.Now, out allSequence); Log.Debug("++++++++++ End CreateChildOrderByPayPalRefenceID ++++++++++"); Log.Debug(" OrderID : " + orderID); Log.Debug(" RecurringReferenceID : " + RecurringReferenceID); Log.Debug(" RecurringAmount : " + RecurringAmount); Log.Debug(" RecurringStatus : " + RecurringStatus); Log.Debug(" PaymentStatus : " + PaymentStatus); Log.Debug(" ReceiptID : " + ReceiptID); Log.Debug(" PeriodType : " + PeriodType); Log.Debug(" allSequence : " + allSequence); if (!String.IsNullOrEmpty(orderID)) { if (allSequence > 1) { Log.Debug(" Enter AllSequence > 1"); OrderNotifyService order = new OrderNotifyService(orderID); order.SendOrderEmail(); Log.Debug(" SendOrderEmail() "); Log.Debug(" End AllSequence > 1"); } else if (allSequence == 1) { Log.Debug(" Enter AllSequence == 1"); string recurringID = DataAccessContext.RecurringProfileRepository.GetRecurringIDFromReferenceID( RecurringReferenceID); RecurringProfile recurringProfile = DataAccessContext.RecurringProfileRepository.GetOne(recurringID); Log.Debug(" RecurringID : " + recurringID); recurringProfile.RecurringStatus = SystemConst.RecurringStatus.Ongoing.ToString(); recurringProfile.UpdateTime = DateTime.Now; DataAccessContext.RecurringProfileRepository.Save(recurringProfile); bool isAllRecurringPaymentComplete = true; IList <OrderItem> orderItemList = DataAccessContext.OrderItemRepository.GetByOrderID(orderID); Log.Debug(" OrderItemList : " + orderItemList.Count); int count = 0; foreach (OrderItem item in orderItemList) { Log.Debug(" Count : " + count); Log.Debug(" item.RecurringID : " + item.RecurringID); if (item.RecurringID != "0") { recurringProfile = DataAccessContext.RecurringProfileRepository.GetOne(item.RecurringID); Log.Debug(" RecurringProfile.RecurringStatus : " + recurringProfile.RecurringStatus); if (recurringProfile.RecurringStatus != SystemConst.RecurringStatus.Ongoing.ToString() && recurringProfile.RecurringStatus != SystemConst.RecurringStatus.Expired.ToString()) { Log.Debug("RecurringStatus != Ongoing && RecurringStatus != Expired"); isAllRecurringPaymentComplete = false; Log.Debug(" Break;"); break; } } count++; } Log.Debug("isAllRecurringPaymentComplete :" + isAllRecurringPaymentComplete); if (isAllRecurringPaymentComplete) { Log.Debug(" Enter AllRecurringPaymentComplete"); Order orderDetails = DataAccessContext.OrderRepository.GetOne(orderID); orderDetails.PaymentComplete = true; DataAccessContext.OrderRepository.Save(orderDetails); Log.Debug(" Exit AllRecurringPaymentComplete"); } Log.Debug(" End AllSequence == 1"); } if (RecurringStatus == SystemConst.RecurringStatus.Expired.ToString()) { Log.Debug(" Enter Expired Recurring Status"); string recurringID = DataAccessContext.RecurringProfileRepository.GetRecurringIDFromReferenceID( RecurringReferenceID); RecurringProfile recurringProfile = DataAccessContext.RecurringProfileRepository.GetOne(recurringID); recurringProfile.RecurringStatus = SystemConst.RecurringStatus.Expired.ToString(); recurringProfile.UpdateTime = DateTime.Now; DataAccessContext.RecurringProfileRepository.Save(recurringProfile); Log.Debug(" RecurringStatus : " + recurringProfile.RecurringStatus); Log.Debug(" UpdateTime : " + DateTime.Now.ToString()); Log.Debug(" End Expired Recurring Status"); } } else { PaymentLog paymentLog = new PaymentLog(); paymentLog.OrderID = "0"; paymentLog.PaymentResponse = Request.Form.ToString(); paymentLog.PaymentGateway = GetPaymentName(); paymentLog.PaymentType = "PayPalRecurringPaymentFailedByNullOrderID"; DataAccessContext.PaymentLogRepository.Save(paymentLog); Log.Debug("OrderID : " + orderID); Log.Debug("PaymentResponse : " + Request.Form.ToString()); Log.Debug("PaymentGateway : " + GetPaymentName()); Log.Debug("PaymentType : " + paymentLog.PaymentType); } } else { PaymentLog paymentLog = new PaymentLog(); paymentLog.OrderID = orderID; paymentLog.PaymentResponse = Request.Form.ToString(); paymentLog.PaymentGateway = GetPaymentName(); paymentLog.PaymentType = "PayPalRecurringPaymentNotCompleted"; DataAccessContext.PaymentLogRepository.Save(paymentLog); Log.Debug("OrderID : " + orderID); Log.Debug("PaymentResponse : " + Request.Form.ToString()); Log.Debug("PaymentGateway : " + GetPaymentName()); Log.Debug("PaymentType : " + paymentLog.PaymentType); } Log.Debug(" ----- End ProcessRecurringPayment() ----- "); } catch (Exception ex) { Log.Debug(" ***** Start ProcessRecurringPayment() Exception ***** "); PaymentLog paymentLog = new PaymentLog(); paymentLog.OrderID = "0"; paymentLog.PaymentResponse = Request.Form.ToString() + "&Exception:" + ex.Message; paymentLog.PaymentGateway = GetPaymentName(); paymentLog.PaymentType = "PayPalRecurringPaymentFailed"; DataAccessContext.PaymentLogRepository.Save(paymentLog); Log.Debug(" Error : " + ex); Log.Debug(" ***** End ProcessRecurringPayment() Exception ***** "); Log.Debug(" ----- End ProcessRecurringPayment() ----- "); } }