本文整理汇总了C#中Nop.Services.Payments.RefundPaymentRequest类的典型用法代码示例。如果您正苦于以下问题:C# RefundPaymentRequest类的具体用法?C# RefundPaymentRequest怎么用?C# RefundPaymentRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RefundPaymentRequest类属于Nop.Services.Payments命名空间,在下文中一共展示了RefundPaymentRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.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;
}
示例2: Refund
/// <summary>
/// Refunds a payment
/// </summary>
/// <param name="refundPaymentRequest">Request</param>
/// <returns>Result</returns>
public virtual RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var paymentMethod = LoadPaymentMethodBySystemName(refundPaymentRequest.Order.PaymentMethodSystemName);
if (paymentMethod == null)
throw new NopException("Payment method couldn't be loaded");
return paymentMethod.Refund(refundPaymentRequest);
}
示例3: PartiallyRefund
/// <summary>
/// Partially refunds an order (from admin panel)
/// </summary>
/// <param name="order">Order</param>
/// <param name="amountToRefund">Amount to refund</param>
/// <returns>A list of errors; empty list if no errors</returns>
public virtual IList<string> PartiallyRefund(Order order, decimal amountToRefund)
{
if (order == null)
throw new ArgumentNullException("order");
if (!CanPartiallyRefund(order, amountToRefund))
throw new NopException("Cannot do partial refund for order.");
var request = new RefundPaymentRequest();
RefundPaymentResult result = null;
try
{
request.Order = order;
request.AmountToRefund = amountToRefund;
request.IsPartialRefund = true;
result = _paymentService.Refund(request);
if (result.Success)
{
//total amount refunded
decimal totalAmountRefunded = order.RefundedAmount + amountToRefund;
//update order info
order.RefundedAmount = totalAmountRefunded;
order.PaymentStatus = result.NewPaymentStatus;
_orderService.UpdateOrder(order);
//add a note
order.OrderNotes.Add(new OrderNote
{
Note = string.Format("Order has been partially refunded. Amount = {0}", _priceFormatter.FormatPrice(amountToRefund, true, false)),
DisplayToCustomer = false,
CreatedOnUtc = DateTime.UtcNow
});
_orderService.UpdateOrder(order);
//check order status
CheckOrderStatus(order);
//raise event
_eventPublisher.Publish(new OrderRefundedEvent(order, amountToRefund));
}
}
catch (Exception exc)
{
if (result == null)
result = new RefundPaymentResult();
result.AddError(string.Format("Error: {0}. Full exception: {1}", exc.Message, exc.ToString()));
}
//process errors
string error = "";
for (int i = 0; i < result.Errors.Count; i++)
{
error += string.Format("Error {0}: {1}", i, result.Errors[i]);
if (i != result.Errors.Count - 1)
error += ". ";
}
if (!String.IsNullOrEmpty(error))
{
//add a note
order.OrderNotes.Add(new OrderNote
{
Note = string.Format("Unable to partially refund order. {0}", error),
DisplayToCustomer = false,
CreatedOnUtc = DateTime.UtcNow
});
_orderService.UpdateOrder(order);
//log it
string logError = string.Format("Error refunding order #{0}. Error: {1}", order.Id, error);
_logger.InsertLog(LogLevel.Error, logError, logError);
}
return result.Errors;
}
示例4: Refund
/// <summary>
/// Refunds an order (from admin panel)
/// </summary>
/// <param name="order">Order</param>
/// <returns>A list of errors; empty list if no errors</returns>
public virtual IList<string> Refund(Order order)
{
if (order == null)
throw new ArgumentNullException("order");
if (!CanRefund(order))
throw new NopException("Cannot do refund for order.");
var request = new RefundPaymentRequest();
RefundPaymentResult result = null;
try
{
request.Order = order;
request.AmountToRefund = order.OrderTotal;
request.IsPartialRefund = false;
result = _paymentService.Refund(request);
if (result.Success)
{
//total amount refunded
decimal totalAmountRefunded = order.RefundedAmount + request.AmountToRefund;
//update order info
order.RefundedAmount = totalAmountRefunded;
order.PaymentStatus = result.NewPaymentStatus;
_orderService.UpdateOrder(order);
//add a note
order.OrderNotes.Add(new OrderNote
{
Note = string.Format("Order has been refunded. Amount = {0}", request.AmountToRefund),
DisplayToCustomer = false,
CreatedOnUtc = DateTime.UtcNow
});
_orderService.UpdateOrder(order);
//check order status
CheckOrderStatus(order);
//notifications
var orderRefundedCustomerNotificationQueuedEmailId = _workflowMessageService.SendOrderRefundedCustomerNotification(order, request.AmountToRefund, order.CustomerLanguageId);
if (orderRefundedCustomerNotificationQueuedEmailId > 0)
{
order.OrderNotes.Add(new OrderNote
{
Note = string.Format("\"Order refunded\" email (to customer) has been queued. Queued email identifier: {0}.", orderRefundedCustomerNotificationQueuedEmailId),
DisplayToCustomer = false,
CreatedOnUtc = DateTime.UtcNow
});
_orderService.UpdateOrder(order);
}
//raise event
_eventPublisher.Publish(new OrderRefundedEvent(order, request.AmountToRefund));
}
}
catch (Exception exc)
{
if (result == null)
result = new RefundPaymentResult();
result.AddError(string.Format("Error: {0}. Full exception: {1}", exc.Message, exc.ToString()));
}
//process errors
string error = "";
for (int i = 0; i < result.Errors.Count; i++)
{
error += string.Format("Error {0}: {1}", i, result.Errors[i]);
if (i != result.Errors.Count - 1)
error += ". ";
}
if (!String.IsNullOrEmpty(error))
{
//add a note
order.OrderNotes.Add(new OrderNote
{
Note = string.Format("Unable to refund order. {0}", error),
DisplayToCustomer = false,
CreatedOnUtc = DateTime.UtcNow
});
_orderService.UpdateOrder(order);
//log it
string logError = string.Format("Error refunding order #{0}. Error: {1}", order.Id, error);
_logger.InsertLog(LogLevel.Error, logError, logError);
}
return result.Errors;
}
示例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 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;
}
示例6: 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;
}
示例7: 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;
}
示例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
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
throw new NotImplementedException();
}
示例10: Refund
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest) { return new RefundPaymentResult(); }
示例11: 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;
}
示例12: Refund
public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = new RefundPaymentResult();
result.AddError("Возврат денег не поддерживается.");
return result;
}
示例13: 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;
}
示例14: 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":
//.........这里部分代码省略.........
示例15: 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;
}