diff --git a/Libraries/Hotcakes.Commerce/BusinessRules/OrderTasks/StartPaypalExpressCheckout.cs b/Libraries/Hotcakes.Commerce/BusinessRules/OrderTasks/StartPaypalExpressCheckout.cs index b87fee3c..ee09dcf5 100644 --- a/Libraries/Hotcakes.Commerce/BusinessRules/OrderTasks/StartPaypalExpressCheckout.cs +++ b/Libraries/Hotcakes.Commerce/BusinessRules/OrderTasks/StartPaypalExpressCheckout.cs @@ -68,16 +68,16 @@ public override bool ProcessCheckout(OrderTaskContext context) EventLog.LogEvent("PayPal Express Checkout", "CartCancelUrl=" + cartCancelUrl, EventLogSeverity.Information); EventLog.LogEvent("PayPal Express Checkout", "CartReturnUrl=" + cartReturnUrl, EventLogSeverity.Information); - string mode = Constants.PAYMENT_MODE_AUTHORIZE; + string mode = PayPalConstants.PAYMENT_MODE_AUTHORIZE; if (!context.HccApp.CurrentStore.Settings.PayPal.ExpressAuthorizeOnly) { - mode = Constants.PAYMENT_MODE_CAPTURE; + mode = PayPalConstants.PAYMENT_MODE_CAPTURE; } // Accelerated boarding if (string.IsNullOrWhiteSpace(context.HccApp.CurrentStore.Settings.PayPal.UserName)) { - mode = Constants.PAYMENT_MODE_CAPTURE; + mode = PayPalConstants.PAYMENT_MODE_CAPTURE; } var solutionType = context.HccApp.CurrentStore.Settings.PayPal.RequirePayPalAccount ? SolutionTypeType.Mark : SolutionTypeType.Sole; @@ -209,11 +209,11 @@ public override bool ProcessCheckout(OrderTaskContext context) string urlTemplate; if (string.Compare(context.HccApp.CurrentStore.Settings.PayPal.Mode, "Live", true) == 0) { - urlTemplate = Constants.LIVE_URL; + urlTemplate = PayPalConstants.LIVE_URL; } else { - urlTemplate = Constants.SANDBOX_URL; + urlTemplate = PayPalConstants.SANDBOX_URL; } HttpContextBase httpContext = new HccHttpContextWrapper(HttpContext.Current); httpContext.Response.Redirect(string.Format(urlTemplate, expressResponse.Result().Id), true); diff --git a/Libraries/Hotcakes.Commerce/Common/Constants.cs b/Libraries/Hotcakes.Commerce/Common/Constants.cs index 61e61bb1..35c77895 100644 --- a/Libraries/Hotcakes.Commerce/Common/Constants.cs +++ b/Libraries/Hotcakes.Commerce/Common/Constants.cs @@ -164,41 +164,5 @@ public class Constants public const string TAG_IOGPRICECURRENCY = ""; #endregion - #region PayPal - //Payments Status - public const string PAYMENT_STATUS_COMPLETED = "COMPLETED"; - public const string PAYMENT_STATUS_COMPLETED_DESCRIPTION = "PayPal Express Payment Captured Successfully"; - public const string PAYMENT_STATUS_Pending = "PENDING"; - public const string PAYMENT_STATUS_Pending_DESCRIPTION = "PayPal Express Payment PENDING"; - public const string PAYMENT_STATUS_DENIED = "DENIED"; - public const string PAYMENT_STATUS_DENIED_DESCRIPTION = "PayPal Express Payment DENIED"; - public const string PAYMENT_STATUS_ERROR_DESCRIPTION = - "An error occurred while trying to capture your PayPal payment."; - public const string PAYMENT_CHARGE_ERROR = "An error occurred while trying to charge your PayPal payment."; - public const string PAYMENT_ERROR = "Paypal Express Payment Charge Failed."; - - //Payment Authorize - public const string PAYMENT_AUTHORIZE_SUCCESS = "PayPal Express Payment Authorized Successfully."; - public const string PAYMENT_AUTHORIZE_FAILED = "PayPal Express Payment Authorization Failed."; - - - //Payment Refund - public const string PAYMENT_REFUND_SUCCESS = "PayPal Express Payment Refunded Successfully."; - public const string PAYMENT_REFUND_FAILED = "Paypal Express Payment Refund Failed."; - - //Payment Void - public const string PAYMENT_Void_SUCCESS = "PayPal Express Payment Voided Successfully."; - public const string PAYMENT_Void_FAILED = "Paypal Express Payment Void Failed."; - - - //Payment Mode - public const string PAYMENT_MODE_AUTHORIZE = "AUTHORIZE"; - public const string PAYMENT_MODE_CAPTURE = "CAPTURE"; - - //Template URL - public const string LIVE_URL = "https://www.paypal.com/checkoutnow?token={0}"; - public const string SANDBOX_URL = "https://www.sandbox.paypal.com/checkoutnow?token={0}"; - - #endregion } } diff --git a/Libraries/Hotcakes.Commerce/Common/PayPalConstants.cs b/Libraries/Hotcakes.Commerce/Common/PayPalConstants.cs new file mode 100644 index 00000000..41e28209 --- /dev/null +++ b/Libraries/Hotcakes.Commerce/Common/PayPalConstants.cs @@ -0,0 +1,42 @@ +using System; + + +namespace Hotcakes.Commerce.Common +{ + public class PayPalConstants + { + //Payments Status + public const string PAYMENT_STATUS_COMPLETED = "COMPLETED"; + public const string PAYMENT_STATUS_COMPLETED_DESCRIPTION = "PayPal Express Payment Captured Successfully"; + public const string PAYMENT_STATUS_Pending = "PENDING"; + public const string PAYMENT_STATUS_Pending_DESCRIPTION = "PayPal Express Payment PENDING"; + public const string PAYMENT_STATUS_DENIED = "DENIED"; + public const string PAYMENT_STATUS_DENIED_DESCRIPTION = "PayPal Express Payment DENIED"; + public const string PAYMENT_STATUS_ERROR_DESCRIPTION = + "An error occurred while trying to capture your PayPal payment."; + public const string PAYMENT_CHARGE_ERROR = "An error occurred while trying to charge your PayPal payment."; + public const string PAYMENT_ERROR = "Paypal Express Payment Charge Failed."; + + //Payment Authorize + public const string PAYMENT_AUTHORIZE_SUCCESS = "PayPal Express Payment Authorized Successfully."; + public const string PAYMENT_AUTHORIZE_FAILED = "PayPal Express Payment Authorization Failed."; + + + //Payment Refund + public const string PAYMENT_REFUND_SUCCESS = "PayPal Express Payment Refunded Successfully."; + public const string PAYMENT_REFUND_FAILED = "Paypal Express Payment Refund Failed."; + + //Payment Void + public const string PAYMENT_Void_SUCCESS = "PayPal Express Payment Voided Successfully."; + public const string PAYMENT_Void_FAILED = "Paypal Express Payment Void Failed."; + + + //Payment Mode + public const string PAYMENT_MODE_AUTHORIZE = "AUTHORIZE"; + public const string PAYMENT_MODE_CAPTURE = "CAPTURE"; + + //Template URL + public const string LIVE_URL = "https://www.paypal.com/checkoutnow?token={0}"; + public const string SANDBOX_URL = "https://www.sandbox.paypal.com/checkoutnow?token={0}"; + } +} diff --git a/Libraries/Hotcakes.Commerce/Hotcakes.Commerce.csproj b/Libraries/Hotcakes.Commerce/Hotcakes.Commerce.csproj index 6fd7af8e..5cf2a99b 100644 --- a/Libraries/Hotcakes.Commerce/Hotcakes.Commerce.csproj +++ b/Libraries/Hotcakes.Commerce/Hotcakes.Commerce.csproj @@ -218,6 +218,7 @@ + diff --git a/Libraries/Hotcakes.Commerce/Payment/Methods/PaypalExpress.cs b/Libraries/Hotcakes.Commerce/Payment/Methods/PaypalExpress.cs index 99c586a4..3a80b05d 100644 --- a/Libraries/Hotcakes.Commerce/Payment/Methods/PaypalExpress.cs +++ b/Libraries/Hotcakes.Commerce/Payment/Methods/PaypalExpress.cs @@ -91,11 +91,11 @@ public bool Authorize(Transaction t, HotcakesApplication app) t.Result.Succeeded = true; t.Result.ReferenceNumber = paymentInfo.Id; t.Result.ResponseCode = "OK"; - t.Result.ResponseCodeDescription = Constants.PAYMENT_AUTHORIZE_SUCCESS; + t.Result.ResponseCodeDescription = PayPalConstants.PAYMENT_AUTHORIZE_SUCCESS; return true; } t.Result.Succeeded = false; - t.Result.Messages.Add(new Message(Constants.PAYMENT_AUTHORIZE_FAILED, string.Empty, + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_AUTHORIZE_FAILED, string.Empty, MessageType.Error)); return false; } @@ -126,38 +126,38 @@ public bool Capture(Transaction t, HotcakesApplication app) var capturedInfo = captureResponse.Result(); t.Result.ReferenceNumber = capturedInfo.Id; - if (capturedInfo.Status == Constants.PAYMENT_STATUS_Pending) + if (capturedInfo.Status == PayPalConstants.PAYMENT_STATUS_Pending) { t.Result.Succeeded = true; - t.Result.ResponseCode = Constants.PAYMENT_STATUS_Pending; - t.Result.ResponseCodeDescription = Constants.PAYMENT_STATUS_Pending_DESCRIPTION; - t.Result.Messages.Add(new Message(Constants.PAYMENT_STATUS_Pending_DESCRIPTION, "OK", + t.Result.ResponseCode = PayPalConstants.PAYMENT_STATUS_Pending; + t.Result.ResponseCodeDescription = PayPalConstants.PAYMENT_STATUS_Pending_DESCRIPTION; + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_STATUS_Pending_DESCRIPTION, "OK", MessageType.Information)); return true; } - if (capturedInfo.Status == Constants.PAYMENT_STATUS_DENIED) + if (capturedInfo.Status == PayPalConstants.PAYMENT_STATUS_DENIED) { t.Result.Succeeded = true; - t.Result.ResponseCode = Constants.PAYMENT_STATUS_DENIED; - t.Result.ResponseCodeDescription = Constants.PAYMENT_STATUS_DENIED_DESCRIPTION; - t.Result.Messages.Add(new Message(Constants.PAYMENT_STATUS_DENIED_DESCRIPTION, "OK", + t.Result.ResponseCode = PayPalConstants.PAYMENT_STATUS_DENIED; + t.Result.ResponseCodeDescription = PayPalConstants.PAYMENT_STATUS_DENIED_DESCRIPTION; + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_STATUS_DENIED_DESCRIPTION, "OK", MessageType.Information)); return true; } - if (capturedInfo.Status == Constants.PAYMENT_STATUS_COMPLETED) + if (capturedInfo.Status == PayPalConstants.PAYMENT_STATUS_COMPLETED) { t.Result.Succeeded = true; - t.Result.Messages.Add(new Message(Constants.PAYMENT_STATUS_COMPLETED_DESCRIPTION, "OK", + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_STATUS_COMPLETED_DESCRIPTION, "OK", MessageType.Information)); return true; } t.Result.Succeeded = false; - t.Result.Messages.Add(new Message(Constants.PAYMENT_STATUS_ERROR_DESCRIPTION, + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_STATUS_ERROR_DESCRIPTION, string.Empty, MessageType.Error)); return false; } t.Result.Succeeded = false; - t.Result.Messages.Add(new Message(Constants.PAYMENT_ERROR, string.Empty, + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_ERROR, string.Empty, MessageType.Error)); return false; } @@ -186,29 +186,29 @@ public bool Charge(Transaction t, HotcakesApplication app) t.Result.ReferenceNumber = paymentInfo.Id; - if (paymentInfo.Status == Constants.PAYMENT_STATUS_COMPLETED) + if (paymentInfo.Status == PayPalConstants.PAYMENT_STATUS_COMPLETED) { t.Result.Succeeded = true; - t.Result.Messages.Add(new Message(Constants.PAYMENT_STATUS_COMPLETED_DESCRIPTION, "OK", + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_STATUS_COMPLETED_DESCRIPTION, "OK", MessageType.Information)); return true; } - if (paymentInfo.Status == Constants.PAYMENT_STATUS_Pending) + if (paymentInfo.Status == PayPalConstants.PAYMENT_STATUS_Pending) { t.Result.Succeeded = true; - t.Result.ResponseCode = Constants.PAYMENT_STATUS_Pending; - t.Result.ResponseCodeDescription = Constants.PAYMENT_STATUS_Pending_DESCRIPTION; - t.Result.Messages.Add(new Message(Constants.PAYMENT_STATUS_Pending_DESCRIPTION, "OK", + t.Result.ResponseCode = PayPalConstants.PAYMENT_STATUS_Pending; + t.Result.ResponseCodeDescription = PayPalConstants.PAYMENT_STATUS_Pending_DESCRIPTION; + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_STATUS_Pending_DESCRIPTION, "OK", MessageType.Information)); return true; } t.Result.Succeeded = false; - t.Result.Messages.Add(new Message(Constants.PAYMENT_CHARGE_ERROR, + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_CHARGE_ERROR, string.Empty, MessageType.Error)); return false; } t.Result.Succeeded = false; - t.Result.Messages.Add(new Message(Constants.PAYMENT_ERROR, string.Empty, + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_ERROR, string.Empty, MessageType.Error)); return false; @@ -238,12 +238,12 @@ public bool Refund(Transaction t, HotcakesApplication app) if (refundResponse.StatusCode == HttpStatusCode.Created) { t.Result.Succeeded = true; - t.Result.Messages.Add(new Message(Constants.PAYMENT_REFUND_SUCCESS, "OK", + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_REFUND_SUCCESS, "OK", MessageType.Information)); return true; } t.Result.Succeeded = false; - t.Result.Messages.Add(new Message(Constants.PAYMENT_REFUND_FAILED, string.Empty, + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_REFUND_FAILED, string.Empty, MessageType.Error)); return false; } @@ -267,12 +267,12 @@ public bool Void(Transaction t, HotcakesApplication app) if (voidResponse.StatusCode == HttpStatusCode.NoContent) { t.Result.Succeeded = true; - t.Result.Messages.Add(new Message(Constants.PAYMENT_Void_SUCCESS, "OK", + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_Void_SUCCESS, "OK", MessageType.Information)); return true; } t.Result.Succeeded = false; - t.Result.Messages.Add(new Message(Constants.PAYMENT_Void_FAILED, string.Empty, + t.Result.Messages.Add(new Message(PayPalConstants.PAYMENT_Void_FAILED, string.Empty, MessageType.Error)); return false; }