private void OnPaymentChanged(OrderPaymentStatus previousPaymentStatus, Order o, MerchantTribeApplication app) { BusinessRules.OrderTaskContext context = new BusinessRules.OrderTaskContext(app); context.Order = o; context.UserId = o.UserID; context.Inputs.Add("bvsoftware", "PreviousPaymentStatus", previousPaymentStatus.ToString()); BusinessRules.Workflow.RunByName(context, BusinessRules.WorkflowNames.PaymentChanged); }
public override bool Execute(BusinessRules.OrderTaskContext context) { if (context.Order.PaymentStatus == Orders.OrderPaymentStatus.Paid) { bool val = BusinessRules.Workflow.RunByName(context, WorkflowNames.PaymentComplete); if (!val) { context.Errors.Add(new BusinessRules.WorkflowMessage("Error", "An Error Occurred While Trying To Process Your Request, Please Try Again.", true)); } return(val); } else { return(true); } }
public bool PayPalExpressCompleteAllPayments() { bool result = true; foreach (Orders.OrderTransaction p in svc.Transactions.FindForOrder(o.bvin)) { List<Orders.OrderTransaction> transactions = svc.Transactions.FindForOrder(o.bvin); if (p.Action == MerchantTribe.Payment.ActionType.PayPalExpressCheckoutInfo || p.Action == MerchantTribe.Payment.ActionType.PayPalHold) { // if we already have an auth or charge on the card, skip if ( p.HasSuccessfulLinkedAction(MerchantTribe.Payment.ActionType.PayPalCharge, transactions) || p.HasSuccessfulLinkedAction(MerchantTribe.Payment.ActionType.PayPalCapture, transactions) || p.HasSuccessfulLinkedAction(MerchantTribe.Payment.ActionType.PayPalHold, transactions) ) { continue; } try { MerchantTribe.Payment.Transaction t = o.GetEmptyTransaction(); t.Card = p.CreditCard; t.Amount = p.Amount; Payment.Method.PaypalExpress processor = new Payment.Method.PaypalExpress(); if (p.Action == MerchantTribe.Payment.ActionType.PayPalHold) { t.Action = MerchantTribe.Payment.ActionType.PayPalCapture; processor.Capture(t, this.MTApp); } else { t.Action = MerchantTribe.Payment.ActionType.PayPalCharge; processor.Charge(t, this.MTApp); } Orders.OrderTransaction ot = new Orders.OrderTransaction(t); ot.LinkedToTransaction = p.IdAsString; svc.AddPaymentTransactionToOrder(o, ot, this.MTApp); if (t.Result.Succeeded == false) result = false; } catch (Exception ex) { EventLog.LogEvent(ex); } } Orders.OrderPaymentStatus previousPaymentStatus = o.PaymentStatus; svc.EvaluatePaymentStatus(o); BusinessRules.OrderTaskContext context = new BusinessRules.OrderTaskContext(this.MTApp); context.Order = o; context.UserId = o.UserID; context.Inputs.Add("bvsoftware", "PreviousPaymentStatus", previousPaymentStatus.ToString()); BusinessRules.Workflow.RunByName(context, BusinessRules.WorkflowNames.PaymentChanged); } return result; }
public bool RewardsPointsAcceptAll() { bool result = true; Payment.RewardPoints processor = new RewardPoints(); processor.Settings = new RewardPointsSettings(this.MTApp.CurrentStore.Id) { PointsIssuedPerDollarSpent = pointsManager.PointsToIssueForSpend(1), PointsNeededForDollarCredit = pointsManager.PointsNeededForPurchaseAmount(1) }; foreach (Orders.OrderTransaction p in svc.Transactions.FindForOrder(o.bvin)) { List<Orders.OrderTransaction> transactions = svc.Transactions.FindForOrder(o.bvin); if (p.Action == MerchantTribe.Payment.ActionType.RewardPointsInfo || p.Action == MerchantTribe.Payment.ActionType.RewardPointsHold) { // if we already have an auth or charge on the card, skip if (p.HasSuccessfulLinkedAction(MerchantTribe.Payment.ActionType.RewardPointsDecrease, transactions) || p.HasSuccessfulLinkedAction(MerchantTribe.Payment.ActionType.RewardPointsHold, transactions) || p.HasSuccessfulLinkedAction(MerchantTribe.Payment.ActionType.RewardPointsCapture, transactions) ) { continue; } try { MerchantTribe.Payment.Transaction t = o.GetEmptyTransaction(); t.Amount = p.Amount; t.RewardPoints = pointsManager.PointsNeededForPurchaseAmount(p.Amount); t.Customer.UserId = o.UserID; if (p.Action == MerchantTribe.Payment.ActionType.RewardPointsHold) { t.Action = MerchantTribe.Payment.ActionType.RewardPointsCapture; } else { t.Action = MerchantTribe.Payment.ActionType.RewardPointsDecrease; } processor.ProcessTransaction(t); Orders.OrderTransaction ot = new Orders.OrderTransaction(t); ot.LinkedToTransaction = p.IdAsString; svc.AddPaymentTransactionToOrder(o, ot, this.MTApp); if (t.Result.Succeeded == false) result = false; } catch (Exception ex) { EventLog.LogEvent(ex); } } Orders.OrderPaymentStatus previousPaymentStatus = o.PaymentStatus; svc.EvaluatePaymentStatus(o); BusinessRules.OrderTaskContext context = new BusinessRules.OrderTaskContext(this.MTApp); context.Order = o; context.UserId = o.UserID; context.Inputs.Add("bvsoftware", "PreviousPaymentStatus", previousPaymentStatus.ToString()); BusinessRules.Workflow.RunByName(context, BusinessRules.WorkflowNames.PaymentChanged); } return result; }
private void UpdateOrderPaymentStatus() { Orders.OrderPaymentStatus previousPaymentStatus = o.PaymentStatus; svc.EvaluatePaymentStatus(o); BusinessRules.OrderTaskContext context = new BusinessRules.OrderTaskContext(this.MTApp); context.Order = o; context.UserId = o.UserID; context.Inputs.Add("bvsoftware", "PreviousPaymentStatus", previousPaymentStatus.ToString()); BusinessRules.Workflow.RunByName(context, BusinessRules.WorkflowNames.PaymentChanged); }
public override bool Rollback(BusinessRules.OrderTaskContext context) { return(true); }