public void TestMethod1() { var mock = new Mock <INextPaymentCreator>(); DateTime dt = DateTime.Now; var current = new RecurringProfile(mock.Object, dt, TimeSpan.FromDays(30)); current.ActivateProfile(); mock.Verify(c => c.CreateNextPayment(current), Times.Once()); }
private void ProcessRecurringCancelComplete(string referenceID) { string recurringID = DataAccessContext.RecurringProfileRepository.GetRecurringIDFromReferenceID(referenceID); RecurringProfile recurringProfile = DataAccessContext.RecurringProfileRepository.GetOne(recurringID); recurringProfile.RecurringStatus = SystemConst.RecurringStatus.Canceled.ToString(); recurringProfile.UpdateTime = DateTime.Now; DataAccessContext.RecurringProfileRepository.Save(recurringProfile); uxMessage.DisplayMessage("The recurring is canceled completly."); //CurrentOrder.RefreshAllPricing(); //uxFormView.DataBind(); uxItemGrid.DataBind(); }
protected void uxCancelLinkButton_Command(object sender, CommandEventArgs e) { string recurringID = e.CommandArgument.ToString(); RecurringProfile recurringProfile = DataAccessContext.RecurringProfileRepository.GetOne(recurringID); Order order = DataAccessContext.OrderRepository.GetOne(CurrentOrderID); //if (details.GatewayName == SystemConst.PayPalPro) // *** use email from customer object if the customer repository return null use email from order object Customer customer = DataAccessContext.CustomerRepository.GetOne(order.CustomerID); string email = order.Email; if (customer != null) { email = customer.Email; } ProcessRecurringCancelPayPalPro(recurringProfile.ReferenceID, ConvertUtilities.ToInt32(recurringID), email, order.UserName, CurrentOrderID); //else // ProcessRecurringCancelAuthorize( recurringID, username ); }
protected DateTime GetRecurringEndDate(object recurringID) { RecurringProfile recurringProfile = DataAccessContext.RecurringProfileRepository.GetOne(recurringID.ToString()); return(recurringProfile.EndRecurringDate); }
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() ----- "); } }
private void ProcessRecurringPaymentProfileCreated() { try { Log.Debug(" ----- Start ProcessRecurringPaymentProfileCreated() ----- "); Log.Debug(" Recurring ReferenceID : " + RecurringReferenceID); string orderItemID = DataAccessContext.RecurringProfileRepository.GetOrderItemIDByReferenceID( RecurringReferenceID); Log.Debug(" OrderItemID : " + orderItemID); Log.Debug("********************* Create PayPalIpn() ************************"); PayPalIpn payPalIpn = new PayPalIpn(); payPalIpn.ReferenceID = RecurringReferenceID; payPalIpn.IpnResponse = Request.Form.ToString(); payPalIpn.IsRecurringProfileCreated = false; payPalIpn.ReceiveDate = DateTime.Now; payPalIpn = DataAccessContext.PayPalIpnRepository.Save(payPalIpn); Log.Debug("********************* Create PayPalIpn() Finished ************************"); if (!String.IsNullOrEmpty(orderItemID)) { Log.Debug("-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Have orderItemID -*-*-*-*-*-*-*-*-*-*-*-*-*-*-"); Log.Debug("IpnID : " + payPalIpn.PayPalIpnID); OrderItem orderItem = DataAccessContext.OrderItemRepository.GetOne(orderItemID); Log.Debug(" orderItem : " + orderItem.ToString()); Log.Debug("orderItem.RecurringID : " + orderItem.RecurringID); RecurringProfile recurringProfile = DataAccessContext.RecurringProfileRepository.GetOne(orderItem.RecurringID); recurringProfile = DataAccessContext.RecurringProfileRepository.GetOne(recurringProfile.RecurringID); recurringProfile.RecurringStatus = SystemConst.RecurringStatus.CreateVerified.ToString(); recurringProfile.UpdateTime = DateTime.Now; DataAccessContext.RecurringProfileRepository.Save(recurringProfile); orderItem.OrderItemRecurring.RecurringStatus = SystemConst.RecurringStatus.CreateVerified.ToString(); orderItem.OrderItemRecurring.UpdateTime = DateTime.Now; DataAccessContext.OrderItemRepository.UpdateRecurringItem(orderItem.OrderItemRecurring); PaymentLog paymentLog = new PaymentLog(); paymentLog.OrderID = orderItem.OrderID; paymentLog.PaymentResponse = Request.Form.ToString(); paymentLog.PaymentGateway = GetPaymentName(); paymentLog.PaymentType = "PayPalRecurringCreate"; DataAccessContext.PaymentLogRepository.Save(paymentLog); payPalIpn.IsRecurringProfileCreated = true; DataAccessContext.PayPalIpnRepository.Save(payPalIpn); Log.Debug(" orderItemID : " + orderItemID); Log.Debug(" RecurringStatus : " + SystemConst.RecurringStatus.CreateVerified.ToString()); Log.Debug(" UpdateTime : " + DateTime.Now.ToString()); Log.Debug(" PaymentType : " + paymentLog.PaymentType); } Log.Debug(" ----- End ProcessRecurringPaymentProfileCreated() ----- "); } catch (Exception ex) { Log.Debug(" ***** Start ProcessRecurringPaymentProfileCreated() Exception ***** "); PaymentLog paymentLog = new PaymentLog(); paymentLog.OrderID = "0"; paymentLog.PaymentResponse = Request.Form.ToString() + "&Exception:" + ex.Message; paymentLog.PaymentGateway = GetPaymentName(); paymentLog.PaymentType = "PayPalRecurringCreateFailed"; DataAccessContext.PaymentLogRepository.Save(paymentLog); Log.Debug(" Error : " + ex); Log.Debug(" ***** End ProcessRecurringPaymentProfileCreated() Exception ***** "); Log.Debug(" ----- End ProcessRecurringPaymentProfileCreated() ----- "); } }