本文整理汇总了C#中Nop.Services.Payments.RefundPaymentResult.AddError方法的典型用法代码示例。如果您正苦于以下问题:C# RefundPaymentResult.AddError方法的具体用法?C# RefundPaymentResult.AddError怎么用?C# RefundPaymentResult.AddError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nop.Services.Payments.RefundPaymentResult
的用法示例。
在下文中一共展示了RefundPaymentResult.AddError方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
string transactionId = refundPaymentRequest.Order.CaptureTransactionId;
var req = new RefundTransactionReq();
req.RefundTransactionRequest = new RefundTransactionRequestType();
//NOTE: Specify amount in partial refund
req.RefundTransactionRequest.RefundType = RefundType.FULL;
req.RefundTransactionRequest.Version = GetApiVersion();
req.RefundTransactionRequest.TransactionID = transactionId;
var service = GetService();
RefundTransactionResponseType response = service.RefundTransaction(req);
string error;
bool success = PaypalHelper.CheckSuccess(response, out error);
if (success)
{
result.NewPaymentStatus = PaymentStatus.Refunded;
//cancelPaymentResult.RefundTransactionID = response.RefundTransactionID;
}
else
{
result.AddError(error);
}
return result;
}
示例2: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
result.AddError("Refund method not supported");
return result;
}
示例3: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
var webClient = new WebClient();
var form = new NameValueCollection();
form.Add("x_login", _authorizeNetPaymentSettings.LoginId);
form.Add("x_tran_key", _authorizeNetPaymentSettings.TransactionKey);
form.Add("x_delim_data", "TRUE");
form.Add("x_delim_char", "|");
form.Add("x_encap_char", "");
form.Add("x_version", GetApiVersion());
form.Add("x_relay_response", "FALSE");
form.Add("x_method", "CC");
form.Add("x_currency_code", _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode);
string[] codes = refundPaymentRequest.Order.CaptureTransactionId == null ?
refundPaymentRequest.Order.AuthorizationTransactionCode.Split(',') : refundPaymentRequest.Order.CaptureTransactionId.Split(',');
//x_trans_id. When x_test_request (sandbox) is set to a positive response,
//or when Test mode is enabled on the payment gateway, this value will be "0".
form.Add("x_trans_id", codes[0]);
string maskedCreditCardNumberDecrypted = _encryptionService.DecryptText(refundPaymentRequest.Order.MaskedCreditCardNumber);
if (String.IsNullOrEmpty(maskedCreditCardNumberDecrypted) || maskedCreditCardNumberDecrypted.Length < 4)
{
result.AddError("Last four digits of Credit Card Not Available");
return result;
}
var lastFourDigitsCardNumber = maskedCreditCardNumberDecrypted.Substring(maskedCreditCardNumberDecrypted.Length - 4);
form.Add("x_card_num", lastFourDigitsCardNumber); // only last four digits are required for doing a credit
form.Add("x_amount", refundPaymentRequest.AmountToRefund.ToString("0.00", CultureInfo.InvariantCulture));
//x_invoice_num is 20 chars maximum. hece we also pass x_description
form.Add("x_invoice_num", refundPaymentRequest.Order.OrderGuid.ToString().Substring(0, 20));
form.Add("x_description", string.Format("Full order #{0}", refundPaymentRequest.Order.OrderGuid));
form.Add("x_type", "CREDIT");
// Send Request to Authorize and Get Response
var responseData = webClient.UploadValues(GetAuthorizeNetUrl(), form);
var reply = Encoding.ASCII.GetString(responseData);
if (!String.IsNullOrEmpty(reply))
{
string[] responseFields = reply.Split('|');
switch (responseFields[0])
{
case "1":
var isOrderFullyRefunded = (refundPaymentRequest.AmountToRefund + refundPaymentRequest.Order.RefundedAmount == refundPaymentRequest.Order.OrderTotal);
result.NewPaymentStatus = isOrderFullyRefunded ? PaymentStatus.Refunded : PaymentStatus.PartiallyRefunded;
break;
case "2":
result.AddError(string.Format("Declined ({0}: {1})", responseFields[2], responseFields[3]));
break;
case "3":
result.AddError(string.Format("Error: {0}", reply));
break;
}
}
else
{
result.AddError("Authorize.NET unknown error");
}
return result;
}
示例4: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
string transactionId = refundPaymentRequest.Order.CaptureTransactionId;
var 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 = GetApiVersion();
req.RefundTransactionRequest.TransactionID = transactionId;
using (var service1 = new PayPalAPISoapBinding())
{
if (!_paypalDirectPaymentSettings.UseSandbox)
service1.Url = "https://api-3t.paypal.com/2.0/";
else
service1.Url = "https://api-3t.sandbox.paypal.com/2.0/";
service1.RequesterCredentials = new CustomSecurityHeaderType();
service1.RequesterCredentials.Credentials = new UserIdPasswordType();
service1.RequesterCredentials.Credentials.Username = _paypalDirectPaymentSettings.ApiAccountName;
service1.RequesterCredentials.Credentials.Password = _paypalDirectPaymentSettings.ApiAccountPassword;
service1.RequesterCredentials.Credentials.Signature = _paypalDirectPaymentSettings.Signature;
service1.RequesterCredentials.Credentials.Subject = "";
RefundTransactionResponseType response = service1.RefundTransaction(req);
string error = string.Empty;
bool Success = PaypalHelper.CheckSuccess(response, out error);
if (Success)
{
result.NewPaymentStatus = PaymentStatus.Refunded;
//cancelPaymentResult.RefundTransactionID = response.RefundTransactionID;
}
else
{
result.AddError(error);
}
}
return result;
}
示例5: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
var config = new HpsServicesConfig();
config.SecretApiKey = _secureSubmitPaymentSettings.SecretApiKey;
config.DeveloperId = "002914";
config.VersionNumber = "1513";
var creditService = new HpsCreditService(config);
try
{
creditService.Refund(
refundPaymentRequest.AmountToRefund,
_currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
refundPaymentRequest.Order.CaptureTransactionId);
var isOrderFullyRefunded = (refundPaymentRequest.AmountToRefund + refundPaymentRequest.Order.RefundedAmount == refundPaymentRequest.Order.OrderTotal);
result.NewPaymentStatus = isOrderFullyRefunded ? PaymentStatus.Refunded : PaymentStatus.PartiallyRefunded;
}
catch (HpsException ex)
{
result.AddError(ex.Message);
}
return result;
}
开发者ID:JacobSteelsmith,项目名称:heartland-nopcommerce-plugin,代码行数:33,代码来源:SecureSubmitPaymentProcessor.cs
示例6: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
string transactionId = refundPaymentRequest.Order.CaptureTransactionId;
var req = new RefundTransactionReq();
req.RefundTransactionRequest = new RefundTransactionRequestType
{
Version = GetApiVersion(),
TransactionID = transactionId
};
if (refundPaymentRequest.IsPartialRefund)
{
req.RefundTransactionRequest.RefundType = RefundType.PARTIAL;
req.RefundTransactionRequest.Amount = new BasicAmountType
{
currencyID = PaypalHelper.GetPaypalCurrency(_currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)),
value = refundPaymentRequest.AmountToRefund.ToString()
};
}
else
req.RefundTransactionRequest.RefundType = RefundType.FULL;
var service = GetService();
RefundTransactionResponseType response = service.RefundTransaction(req);
string error;
bool success = PaypalHelper.CheckSuccess(response, out error);
if (success)
{
result.NewPaymentStatus = (refundPaymentRequest.IsPartialRefund &&
refundPaymentRequest.Order.RefundedAmount + refundPaymentRequest.AmountToRefund < refundPaymentRequest.Order.OrderTotal) ?
PaymentStatus.PartiallyRefunded : PaymentStatus.Refunded;
//set refund transaction id for preventing refund twice
_genericAttributeService.SaveAttribute(refundPaymentRequest.Order, "RefundTransactionId", response.RefundTransactionID);
}
else
result.AddError(error);
return result;
}
示例7: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
PayfirmaTransaction payfirma = new PayfirmaTransaction();
PayfirmaTransactionResponse payfirmaResponse =
payfirma.ProcessRefund(this.PopulateMerchantCredentials(), refundPaymentRequest.Order.AuthorizationTransactionId,
Convert.ToDouble(refundPaymentRequest.AmountToRefund), _payfirmaPaymentSettings.IsTest);
if (!String.IsNullOrEmpty(payfirmaResponse.Error))
{
result.AddError(payfirmaResponse.Error);
}
else if (!payfirmaResponse.Result)
{
result.AddError(payfirmaResponse.ResultMessage);
}
else
{
var isOrderFullyRefunded = (refundPaymentRequest.AmountToRefund + refundPaymentRequest.Order.RefundedAmount == refundPaymentRequest.Order.OrderTotal);
result.NewPaymentStatus = isOrderFullyRefunded ? PaymentStatus.Refunded : PaymentStatus.PartiallyRefunded;
}
return result;
}
示例8: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
// Check license
bool isLicensed = this._licenseService.IsLicensed(HttpContext.Current.Request.Url.Host);
if (!isLicensed && refundPaymentRequest.Order.OrderTotal > 5.00M)
{
result.AddError("The trial license can be used to submit order of $5.00 or less. Please purchase a full license at our website.");
return result;
}
string transactionId = refundPaymentRequest.Order.CaptureTransactionId;
// Create the Payflow Data Objects.
// Create the User data object with the required user details.
UserInfo payflowUser = _payPalHelper.GetUserInfo();
// Create the Payflow Connection data object with the required connection details.
PayflowConnectionData payflowConn = new PayflowConnectionData(_payPalHelper.GetPayflowProHost());
// Create a new Invoice data object with the Amount, Billing Address etc. details.
Invoice invoice = new Invoice();
// Set Amount.
PayPal.Payments.DataObjects.Currency refundAmount = new PayPal.Payments.DataObjects.Currency(refundPaymentRequest.AmountToRefund);
invoice.Amt = refundAmount;
invoice.PoNum = refundPaymentRequest.Order.Id.ToString();
invoice.InvNum = refundPaymentRequest.Order.Id.ToString();
CreditTransaction trans = new CreditTransaction(transactionId, payflowUser, payflowConn, invoice, PayflowUtility.RequestId);
Response resp = trans.SubmitTransaction();
// Process the Payflow response.
if (resp != null)
{
// Get the Transaction Response parameters.
TransactionResponse trxResp = resp.TransactionResponse;
if (trxResp != null)
{
if (trxResp.Result == 0)
{
if (refundPaymentRequest.IsPartialRefund)
result.NewPaymentStatus = PaymentStatus.PartiallyRefunded;
else
result.NewPaymentStatus = PaymentStatus.Refunded;
}
else
{
result.AddError(string.Format("Refund RESULT: {0}-{1}", trxResp.Result, trxResp.RespMsg));
}
}
}
return result;
}
开发者ID:CloudberrySoftware,项目名称:PayPalAdvanced-Payments-Plugin,代码行数:61,代码来源:PayPalAdvancedPaymentProcessor.cs
示例9: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
var refundResult = _sagePayServerWorkflowService.RefundTransaction(refundPaymentRequest.Order.OrderGuid.ToString(), refundPaymentRequest.Order.OrderTotal, refundPaymentRequest.Order.CustomerCurrencyCode);
if (!refundResult.Success)
{
result.AddError(refundResult.Message);
}
else
{
result.NewPaymentStatus = PaymentStatus.Refunded;
}
return result;
}
示例10: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
var orderGuid = refundPaymentRequest.Order.OrderGuid;
if (orderGuid == Guid.NewGuid())
{
result.AddError("Order Unique identifier code does not exist!");
return result;
}
var transx = _sagePayServerTransactionService.GetSagePayServerTransactionByVendorTxCode(orderGuid.ToString());
if (transx == null)
{
result.AddError(String.Format("SagePay Server vendor transaction code {0} does not exist.", orderGuid.ToString()));
return result;
}
var webClient = new WebClient();
var data = new NVPCodec();
data.Add("VPSProtocol", SagePayHelper.GetProtocol());
data.Add("TxType", "REFUND");
data.Add("Vendor", _sagePayServerPaymentSettings.VendorName);
var returnGuid = Guid.NewGuid();
data.Add("VendorTxCode", returnGuid.ToString());
data.Add("VPSTxId", transx.VPSTxId);
data.Add("SecurityKey", transx.SecurityKey);
data.Add("TxAuthNo", transx.TxAuthNo);
data.Add("Amount", refundPaymentRequest.AmountToRefund.ToString("F2", CultureInfo.InvariantCulture));
data.Add("Currency", refundPaymentRequest.Order.CustomerCurrencyCode);
data.Add("Description", "---");
data.Add("RelatedVPSTxId", transx.VPSTxId);
data.Add("RelatedVendorTxCode", orderGuid.ToString());
data.Add("RelatedSecurityKey", transx.SecurityKey);
data.Add("RelatedTxAuthNo", transx.TxAuthNo);
var postURL = SagePayHelper.GetSageSystemUrl(_sagePayServerPaymentSettings.ConnectTo, "refund");
string strResponse = string.Empty;
try
{
Byte[] responseData = webClient.UploadValues(postURL, data);
strResponse = Encoding.ASCII.GetString(responseData);
}
catch (WebException ex)
{
result.AddError(String.Format(
@"Your server was unable to release this transaction with Sage Pay.
Check that you do not have a firewall restricting the POST and
that your server can correctly resolve the address {0}. <br/>
The Status Number is: {1}<br/>
The Description given is: {2}", postURL, ex.Status, ex.Message));
return result;
}
if (string.IsNullOrWhiteSpace(strResponse))
{
result.AddError(String.Format(
@"Your server was unable to register this transaction with Sage Pay.
Check that you do not have a firewall restricting the POST and
that your server can correctly resolve the address {0}.", postURL));
return result;
}
var strStatus = SagePayHelper.FindField("Status", strResponse);
var strStatusDetail = SagePayHelper.FindField("StatusDetail", strResponse);
switch (strStatus)
{
case "OK":
result.NewPaymentStatus = PaymentStatus.Refunded;
break;
case "MALFORMED":
result.AddError(string.Format("Error ({0}: {1}) <br/> {2}", strStatus, strStatusDetail, data.Encode()));
return result;
case "INVALID":
//.........这里部分代码省略.........
示例11: Refund
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
if (refundPaymentRequest.IsPartialRefund)
{
result.AddError("Partial refund is not supported.");
return result;
}
var order = refundPaymentRequest.Order;
if (string.IsNullOrWhiteSpace(order.CaptureTransactionId))
{
result.AddError("Cannot refund. CaptureTransactionId is missing from the order. Has the order been shipped?");
return result;
}
try
{
_klarnaCheckoutPaymentService.FullRefund(refundPaymentRequest.Order);
result.NewPaymentStatus = PaymentStatus.Refunded;
}
catch (KlarnaCheckoutException kce)
{
_logger.Error(string.Format(CultureInfo.CurrentCulture, "KlarnaCheckout: Error refunding klarna order. Reservation Number: {0}; Invoice Number: {1}",
order.AuthorizationTransactionId, order.CaptureTransactionId),
exception: kce,
customer: order.Customer);
result.AddError("An error occurred while refundinging the order. See the error log for more information.");
}
return result;
}
示例12: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
//result.AddError("Refund method not supported");
try
{
NumberFormatInfo nfi = CultureInfo.CurrentCulture.NumberFormat;
nfi = (NumberFormatInfo)nfi.Clone();
nfi.CurrencySymbol = "";
var order = refundPaymentRequest.Order;
string transactioncode = order.AuthorizationTransactionCode;
string amount = string.Format(nfi, "{0:c}", refundPaymentRequest.AmountToRefund);
Regex digitsOnly = new Regex(@"[^\d]");
amount = digitsOnly.Replace(amount, "");
string apiobject = "refunds";
string buildurl = _PayMillPaymentSettings.apiUrl + apiobject + "/" + transactioncode + "?amount=" + amount;
string response = GetPMAPIResponse(buildurl, _PayMillPaymentSettings.privateKey);
if (response != null)
{
}
}
catch (Exception ex)
{
_logger.InsertLog(Core.Domain.Logging.LogLevel.Error, ex.Message, ex.ToString());
result.AddError(ex.ToString());
}
return result;
}