本文整理汇总了C#中NopSolutions.NopCommerce.BusinessLogic.Payment.CancelPaymentResult类的典型用法代码示例。如果您正苦于以下问题:C# CancelPaymentResult类的具体用法?C# CancelPaymentResult怎么用?C# CancelPaymentResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CancelPaymentResult类属于NopSolutions.NopCommerce.BusinessLogic.Payment命名空间,在下文中一共展示了CancelPaymentResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CancelRecurringPayment
/// <summary>
/// Cancels recurring payment
/// </summary>
/// <param name="order">Order</param>
/// <param name="cancelPaymentResult">Cancel payment result</param>
public static void CancelRecurringPayment(Order order, ref CancelPaymentResult cancelPaymentResult)
{
var paymentMethod = PaymentMethodManager.GetPaymentMethodById(order.PaymentMethodId);
if (paymentMethod == null)
throw new NopException("Payment method couldn't be loaded");
var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;
iPaymentMethod.CancelRecurringPayment(order, ref cancelPaymentResult);
}
示例2: CancelRecurringPayment
/// <summary>
/// Cancels recurring payment
/// </summary>
/// <param name="order">Order</param>
/// <param name="cancelPaymentResult">Cancel payment result</param>
public void CancelRecurringPayment(Order order, ref CancelPaymentResult cancelPaymentResult)
{
throw new NotImplementedException();
}
示例3: Void
/// <summary>
/// Voids order (from admin panel)
/// </summary>
/// <param name="orderId">Order identifier</param>
/// <param name="error">Error</param>
/// <returns>Voided order</returns>
public static Order Void(int orderId, ref string error)
{
var order = GetOrderById(orderId);
if (order == null)
return order;
if (!CanVoid(order))
throw new NopException("Can not do void for order.");
var cancelPaymentResult = new CancelPaymentResult();
try
{
//old info from placing order
cancelPaymentResult.AuthorizationTransactionId = order.AuthorizationTransactionId;
cancelPaymentResult.CaptureTransactionId = order.CaptureTransactionId;
cancelPaymentResult.Amount = order.OrderTotal;
cancelPaymentResult.PaymentStatus = order.PaymentStatus;
PaymentManager.Void(order, ref cancelPaymentResult);
if (String.IsNullOrEmpty(cancelPaymentResult.Error))
{
order = UpdateOrder(order.OrderId, order.OrderGuid, order.CustomerId, order.CustomerLanguageId,
order.CustomerTaxDisplayType, order.CustomerIP, order.OrderSubtotalInclTax, order.OrderSubtotalExclTax, order.OrderShippingInclTax,
order.OrderShippingExclTax, order.PaymentMethodAdditionalFeeInclTax, order.PaymentMethodAdditionalFeeExclTax,
order.TaxRates, order.OrderTax, order.OrderTotal,
order.RefundedAmount, order.OrderDiscount,
order.OrderSubtotalInclTaxInCustomerCurrency, order.OrderSubtotalExclTaxInCustomerCurrency,
order.OrderShippingInclTaxInCustomerCurrency, order.OrderShippingExclTaxInCustomerCurrency,
order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency,
order.TaxRatesInCustomerCurrency, order.OrderTaxInCustomerCurrency,
order.OrderTotalInCustomerCurrency,
order.OrderDiscountInCustomerCurrency,
order.CheckoutAttributeDescription, order.CheckoutAttributesXml,
order.CustomerCurrencyCode, order.OrderWeight,
order.AffiliateId, order.OrderStatus, order.AllowStoringCreditCardNumber,
order.CardType, order.CardName, order.CardNumber, order.MaskedCreditCardNumber,
order.CardCvv2, order.CardExpirationMonth, order.CardExpirationYear,
order.PaymentMethodId, order.PaymentMethodName,
cancelPaymentResult.AuthorizationTransactionId,
order.AuthorizationTransactionCode,
order.AuthorizationTransactionResult,
cancelPaymentResult.CaptureTransactionId,
order.CaptureTransactionResult,
order.SubscriptionTransactionId, order.PurchaseOrderNumber,
cancelPaymentResult.PaymentStatus, order.PaidDate,
order.BillingFirstName, order.BillingLastName, order.BillingPhoneNumber,
order.BillingEmail, order.BillingFaxNumber, order.BillingCompany, order.BillingAddress1,
order.BillingAddress2, order.BillingCity,
order.BillingStateProvince, order.BillingStateProvinceId, order.BillingZipPostalCode,
order.BillingCountry, order.BillingCountryId, order.ShippingStatus,
order.ShippingFirstName, order.ShippingLastName, order.ShippingPhoneNumber,
order.ShippingEmail, order.ShippingFaxNumber, order.ShippingCompany,
order.ShippingAddress1, order.ShippingAddress2, order.ShippingCity,
order.ShippingStateProvince, order.ShippingStateProvinceId, order.ShippingZipPostalCode,
order.ShippingCountry, order.ShippingCountryId,
order.ShippingMethod, order.ShippingRateComputationMethodId,
order.ShippedDate, order.DeliveryDate,
order.TrackingNumber, order.VatNumber, order.Deleted, order.CreatedOn);
InsertOrderNote(order.OrderId, string.Format("Order has been voided"), false, DateTime.UtcNow);
}
else
{
InsertOrderNote(order.OrderId, string.Format("Unable to void order. Error: {0}", cancelPaymentResult.Error), false, DateTime.UtcNow);
}
order = CheckOrderStatus(order.OrderId);
}
catch (Exception exc)
{
cancelPaymentResult.Error = exc.Message;
cancelPaymentResult.FullError = exc.ToString();
}
if (!String.IsNullOrEmpty(cancelPaymentResult.Error))
{
error = cancelPaymentResult.Error;
LogManager.InsertLog(LogTypeEnum.OrderError, string.Format("Error voiding order. {0}", cancelPaymentResult.Error), cancelPaymentResult.FullError);
}
return order;
}
示例4: CancelRecurringPayment
/// <summary>
/// Cancels a recurring payment
/// </summary>
/// <param name="recurringPaymentId">Recurring payment identifier</param>
/// <param name="throwException">A value indicating whether to throw the exception after an error has occupied.</param>
public static RecurringPayment CancelRecurringPayment(int recurringPaymentId,
bool throwException)
{
var recurringPayment = GetRecurringPaymentById(recurringPaymentId);
try
{
if (recurringPayment != null)
{
//update recurring payment
UpdateRecurringPayment(recurringPayment.RecurringPaymentId, recurringPayment.InitialOrderId,
recurringPayment.CycleLength, recurringPayment.CyclePeriod,
recurringPayment.TotalCycles, recurringPayment.StartDate,
false, recurringPayment.Deleted, recurringPayment.CreatedOn);
var initialOrder = recurringPayment.InitialOrder;
if (initialOrder == null)
return recurringPayment;
//old info from placing order
var cancelPaymentResult = new CancelPaymentResult();
cancelPaymentResult.AuthorizationTransactionId = initialOrder.AuthorizationTransactionId;
cancelPaymentResult.CaptureTransactionId = initialOrder.CaptureTransactionId;
cancelPaymentResult.SubscriptionTransactionId = initialOrder.SubscriptionTransactionId;
cancelPaymentResult.Amount = initialOrder.OrderTotal;
PaymentManager.CancelRecurringPayment(initialOrder, ref cancelPaymentResult);
if (String.IsNullOrEmpty(cancelPaymentResult.Error))
{
InsertOrderNote(initialOrder.OrderId, string.Format("Recurring payment has been cancelled"), false, DateTime.UtcNow);
}
else
{
InsertOrderNote(initialOrder.OrderId, string.Format("Error cancelling recurring payment. Error: {0}", cancelPaymentResult.Error), false, DateTime.UtcNow);
}
}
}
catch (Exception exc)
{
LogManager.InsertLog(LogTypeEnum.OrderError, "Error cancelling recurring payment", exc);
if (throwException)
throw;
}
return recurringPayment;
}
示例5: CancelRecurringPayment
/// <summary>
/// Cancels recurring payment
/// </summary>
/// <param name="order">Order</param>
/// <param name="cancelPaymentResult">Cancel payment result</param>
public void CancelRecurringPayment(Order order, ref CancelPaymentResult cancelPaymentResult)
{
InitSettings();
MerchantAuthenticationType authentication = PopulateMerchantAuthentication();
long subscriptionID = 0;
long.TryParse(cancelPaymentResult.SubscriptionTransactionId, out subscriptionID);
ARBCancelSubscriptionResponseType response = webService.ARBCancelSubscription(authentication, subscriptionID);
if (response.resultCode == MessageTypeEnum.Ok)
{
//ok
}
else
{
cancelPaymentResult.Error = "Error cancelling subscription, please contact customer support. " + GetErrors(response);
cancelPaymentResult.FullError = "Error cancelling subscription, please contact customer support. " + GetErrors(response);
}
}
示例6: Void
public void Void(Order order, ref CancelPaymentResult cancelPaymentResult)
{
var usaepay = new USAePayAPI.USAePay();
usaepay.SourceKey = sourceKey;
usaepay.Pin = pin;
try
{
usaepay.Void(order.AuthorizationTransactionId);
switch (usaepay.ResultCode)
{
case "A":
cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Voided;
//cancelPaymentResult.AuthorizationTransactionId = usaepay.RefNum;
break;
case "D":
cancelPaymentResult.Error = "Void Declined: " + usaepay.ErrorMesg;
cancelPaymentResult.FullError = "Void Declined : " + usaepay.ErrorMesg;
break;
default:
cancelPaymentResult.Error = "Error during void";
cancelPaymentResult.FullError = "Error during void: " + usaepay.ErrorMesg;
break;
}
}
catch
{
cancelPaymentResult.Error = "Error during void";
cancelPaymentResult.FullError = "Error during void";
}
}
示例7: CancelRecurringPayment
/// <summary>
/// Cancels recurring payment
/// </summary>
/// <param name="order">Order</param>
/// <param name="cancelPaymentResult">Cancel payment result</param>
public void CancelRecurringPayment(Order order, ref CancelPaymentResult cancelPaymentResult)
{
}
示例8: Void
/// <summary>
/// Voids order (from admin panel)
/// </summary>
/// <param name="orderId">Order identifier</param>
/// <param name="error">Error</param>
/// <returns>Voided order</returns>
public Order Void(int orderId, ref string error)
{
var order = GetOrderById(orderId);
if (order == null)
return order;
if (!CanVoid(order))
throw new NopException("Can not do void for order.");
var cancelPaymentResult = new CancelPaymentResult();
try
{
//old info from placing order
cancelPaymentResult.AuthorizationTransactionId = order.AuthorizationTransactionId;
cancelPaymentResult.CaptureTransactionId = order.CaptureTransactionId;
cancelPaymentResult.Amount = order.OrderTotal;
cancelPaymentResult.PaymentStatus = order.PaymentStatus;
IoC.Resolve<IPaymentService>().Void(order, ref cancelPaymentResult);
if (String.IsNullOrEmpty(cancelPaymentResult.Error))
{
order.AuthorizationTransactionId = cancelPaymentResult.AuthorizationTransactionId;
order.CaptureTransactionId = cancelPaymentResult.CaptureTransactionId;
order.PaymentStatusId = (int)cancelPaymentResult.PaymentStatus;
UpdateOrder(order);
InsertOrderNote(order.OrderId, string.Format("Order has been voided"), false, DateTime.UtcNow);
}
else
{
InsertOrderNote(order.OrderId, string.Format("Unable to void order. Error: {0}", cancelPaymentResult.Error), false, DateTime.UtcNow);
}
order = CheckOrderStatus(order.OrderId);
}
catch (Exception exc)
{
cancelPaymentResult.Error = exc.Message;
cancelPaymentResult.FullError = exc.ToString();
}
if (!String.IsNullOrEmpty(cancelPaymentResult.Error))
{
error = cancelPaymentResult.Error;
IoC.Resolve<ILogService>().InsertLog(LogTypeEnum.OrderError, string.Format("Error voiding order. {0}", cancelPaymentResult.Error), cancelPaymentResult.FullError);
}
return order;
}
示例9: DoCancel
//This only works when a payment have been authorized and not captured.
private void DoCancel(Order order, ref CancelPaymentResult cancelPaymentResult, bool alreadyTriedRefund)
{
string merchant = SettingManager.GetSettingValue(QuickPayConstants.SETTING_MERCHANTID);
string protocol = "3";
string capturePostUrl = "https://secure.quickpay.dk/api";
string msgtype = "cancel";
string transaction = order.AuthorizationTransactionId;
string md5secret = SettingManager.GetSettingValue(QuickPayConstants.SETTING_MD5SECRET);
string stringToMd5 = string.Concat(protocol, msgtype, merchant, transaction, md5secret);
string querystring = string.Empty;
string md5check = GetMD5(stringToMd5);
querystring += string.Format("protocol={0}&", protocol);
querystring += string.Format("msgtype={0}&", msgtype);
querystring += string.Format("merchant={0}&", merchant);
querystring += string.Format("transaction={0}&", transaction);
querystring += string.Format("md5check={0}", md5check);
string retval = HttpRequestsFunctions.HttpPost(capturePostUrl, querystring);
try
{
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(retval);
XmlElement xmlElement = xmlDocument.DocumentElement;
string rep_qpstatmsg = xmlElement.SelectSingleNode("qpstatmsg").InnerText;
string rep_qpstat = xmlElement.SelectSingleNode("qpstat").InnerText;
string rep_transaction = xmlElement.SelectSingleNode("transaction").InnerText;
//refund successful
if (rep_qpstat == "000")
{
cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Refunded;
}
else if (rep_qpstat == "004" && (!alreadyTriedRefund))
{
DoRefund(order, ref cancelPaymentResult, true);
}
else
{
cancelPaymentResult.Error = "Quickpay Cancel did not succeed, qpstat is:" + rep_qpstat;
cancelPaymentResult.FullError = "Quickpay Cancel did not succeed, qpstat is:" + rep_qpstat;
}
}
catch (Exception exception)
{
throw new NopException("XML response for Quickpay Capture was not successfull. Reasons could be that the host did not respond. Below is stacktrace:" + exception.Message + exception.StackTrace + exception.Source, exception.InnerException);
}
}
示例10: DoRefund
//This works only on refund to customer (refund what has already been captured...)
private void DoRefund(Order order, ref CancelPaymentResult cancelPaymentResult, bool alreadyTriedCancel)
{
string merchant = SettingManager.GetSettingValue(QuickPayConstants.SETTING_MERCHANTID);
string protocol = "3";
string capturePostUrl = "https://secure.quickpay.dk/api";
string msgtype = "refund";
string amount = (cancelPaymentResult.Amount * 100).ToString("0", CultureInfo.InvariantCulture); //NOTE: Primary store should be changed to DKK, if you do not have internatinal agreement with pbs and quickpay. Otherwise you need to do currency conversion here.
string transaction = order.AuthorizationTransactionId;
string md5secret = SettingManager.GetSettingValue(QuickPayConstants.SETTING_MD5SECRET);
string stringToMd5 = string.Concat(protocol, msgtype, merchant, amount, transaction, md5secret);
string querystring = string.Empty;
string md5check = GetMD5(stringToMd5);
querystring += string.Format("protocol={0}&", protocol);
querystring += string.Format("msgtype={0}&", msgtype);
querystring += string.Format("merchant={0}&", merchant);
querystring += string.Format("amount={0}&", amount);
querystring += string.Format("transaction={0}&", transaction);
querystring += string.Format("md5check={0}", md5check);
string retval = HttpRequestsFunctions.HttpPost(capturePostUrl, querystring);
try
{
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(retval);
XmlElement xmlElement = xmlDocument.DocumentElement;
string rep_qpstatmsg = xmlElement.SelectSingleNode("qpstatmsg").InnerText;
string rep_qpstat = xmlElement.SelectSingleNode("qpstat").InnerText;
string rep_transaction = xmlElement.SelectSingleNode("transaction").InnerText;
//refund successful
if (rep_qpstat == "000")
{
cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Refunded;
}
//not allowed in current state. This probably means that it has not been caputered yet.
//we therefore try to just cancel, but not refund
else if (rep_qpstat == "004" && (!alreadyTriedCancel))
{
DoCancel(order, ref cancelPaymentResult, true);
}
else
{
cancelPaymentResult.Error = "Quickpay Caputure refund did not succeed, qpstat is:" + rep_qpstat;
cancelPaymentResult.FullError = "Quickpay Caputure refund did not succeed, qpstat is:" + rep_qpstat;
}
}
catch (Exception exception)
{
throw new NopException("XML response for Quickpay Capture was not successfull. Reasons could be that the host did not respond. Below is stacktrace:" + exception.Message + exception.StackTrace + exception.Source, exception.InnerException);
}
}
示例11: Refund
/// <summary>
/// Refunds payment
/// </summary>
/// <param name="order">Order</param>
/// <param name="cancelPaymentResult">Cancel payment result</param>
public void Refund(Order order, ref CancelPaymentResult cancelPaymentResult)
{
DoRefund(order, ref cancelPaymentResult, false);
}
示例12: Void
/// <summary>
/// Voids payment
/// </summary>
/// <param name="order">Order</param>
/// <param name="cancelPaymentResult">Cancel payment result</param>
public void Void(Order order, ref CancelPaymentResult cancelPaymentResult)
{
InitSettings();
string transactionID = cancelPaymentResult.AuthorizationTransactionId;
if (String.IsNullOrEmpty(transactionID))
transactionID = cancelPaymentResult.CaptureTransactionId;
DoVoidReq req = new DoVoidReq();
req.DoVoidRequest = new DoVoidRequestType();
req.DoVoidRequest.Version = this.APIVersion;
req.DoVoidRequest.AuthorizationID = transactionID;
DoVoidResponseType response = service2.DoVoid(req);
string error = string.Empty;
bool Success = PaypalHelper.CheckSuccess(response, out error);
if (Success)
{
cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Voided;
//cancelPaymentResult.VoidTransactionID = response.RefundTransactionID;
}
else
{
cancelPaymentResult.Error = error;
}
}
示例13: Refund
/// <summary>
/// Refunds payment
/// </summary>
/// <param name="order">Order</param>
/// <param name="cancelPaymentResult">Cancel payment result</param>
public void Refund(Order order, ref CancelPaymentResult cancelPaymentResult)
{
InitSettings();
string transactionID = cancelPaymentResult.CaptureTransactionId;
RefundTransactionReq req = new RefundTransactionReq();
req.RefundTransactionRequest = new RefundTransactionRequestType();
//NOTE: Specify amount in partial refund
req.RefundTransactionRequest.RefundType = RefundType.Full;
req.RefundTransactionRequest.RefundTypeSpecified = true;
req.RefundTransactionRequest.Version = this.APIVersion;
req.RefundTransactionRequest.TransactionID = transactionID;
RefundTransactionResponseType response = service1.RefundTransaction(req);
string error = string.Empty;
bool Success = PaypalHelper.CheckSuccess(response, out error);
if (Success)
{
cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Refunded;
//cancelPaymentResult.RefundTransactionID = response.RefundTransactionID;
}
else
{
cancelPaymentResult.Error = error;
}
}
示例14: Void
/// <summary>
/// Voids paymen
/// </summary>
/// <param name="order">Order</param>
/// <param name="cancelPaymentResult">Cancel payment result</param>
public void Void(Order order, ref CancelPaymentResult cancelPaymentResult)
{
throw new NotImplementedException();
}
示例15: Refund
/// <summary>
/// Refunds payment
/// </summary>
/// <param name="order">Order</param>
/// <param name="cancelPaymentResult">Cancel payment result</param>
public void Refund(Order order, ref CancelPaymentResult cancelPaymentResult)
{
try
{
using(usaepayService svc = new usaepayService())
{
svc.Url = EPaymentFormSettings.ServiceUrl;
TransactionResponse rsp = svc.refundTransaction(EPaymentFormHelper.ServiceSecurityToken, cancelPaymentResult.CaptureTransactionId, (double)cancelPaymentResult.Amount);
switch(rsp.ResultCode)
{
case "A":
{
if (cancelPaymentResult.IsPartialRefund)
cancelPaymentResult.PaymentStatus = PaymentStatusEnum.PartiallyRefunded;
else
cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Refunded;
}
break;
case "D":
case "E":
default:
cancelPaymentResult.Error = rsp.ErrorCode;
cancelPaymentResult.FullError = rsp.Error;
break;
}
}
}
catch(Exception ex)
{
cancelPaymentResult.Error = ex.Message;
cancelPaymentResult.FullError = ex.Message;
}
}