本文整理汇总了C#中Nop.Services.Payments.CapturePaymentResult类的典型用法代码示例。如果您正苦于以下问题:C# CapturePaymentResult类的具体用法?C# CapturePaymentResult怎么用?C# CapturePaymentResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CapturePaymentResult类属于Nop.Services.Payments命名空间,在下文中一共展示了CapturePaymentResult类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Capture
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
var order = capturePaymentRequest.Order;
if (!string.IsNullOrEmpty(order.CaptureTransactionId))
{
result.AddError("The payment has already been captured.");
return result;
}
try
{
var activationResult = _klarnaCheckoutPaymentService.Activate(order);
result.NewPaymentStatus = PaymentStatus.Paid;
result.CaptureTransactionId = activationResult.InvoiceNumber;
order.OrderNotes.Add(new OrderNote
{
Note = string.Format(CultureInfo.CurrentCulture, "KlarnaCheckout: Klarna order has been captured. Reservation: {0}, RiskStatus: {1}, InvoiceNumber: {2}",
order.AuthorizationTransactionId, activationResult.RiskStatus, activationResult.InvoiceNumber),
CreatedOnUtc = DateTime.UtcNow,
DisplayToCustomer = false
});
_orderService.UpdateOrder(order);
var klarnaRequest = _repository.Table.FirstOrDefault(x => x.OrderGuid == order.OrderGuid);
if (klarnaRequest != null)
{
klarnaRequest.Status = KlarnaCheckoutStatus.Activated;
_repository.Update(klarnaRequest);
}
}
catch (KlarnaCheckoutException ex)
{
order.OrderNotes.Add(new OrderNote
{
Note = "KlarnaCheckout: An error occurred when the payment was being captured. See the error log for more information.",
CreatedOnUtc = DateTime.UtcNow,
DisplayToCustomer = false
});
_orderService.UpdateOrder(order);
_logger.Error(string.Format(CultureInfo.CurrentCulture, "KlarnaCheckout: Error capturing payment. Order Number: {0}",
order.Id),
exception: ex,
customer: order.Customer);
result.AddError("An error occurred while capturing the payment. See the error log for more information.");
}
return result;
}
示例2: Capture
/// <summary>
/// Captures payment
/// </summary>
/// <param name="capturePaymentRequest">Capture payment request</param>
/// <returns>Capture payment result</returns>
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
result.AddError("Capture method not supported");
return result;
}
示例3: Capture
/// <summary>
/// Captures payment
/// </summary>
/// <param name="capturePaymentRequest">Capture payment request</param>
/// <returns>Capture payment result</returns>
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
string authorizationId = capturePaymentRequest.Order.AuthorizationTransactionId;
var req = new DoCaptureReq();
req.DoCaptureRequest = new DoCaptureRequestType();
req.DoCaptureRequest.Version = GetApiVersion();
req.DoCaptureRequest.AuthorizationID = authorizationId;
req.DoCaptureRequest.Amount = new BasicAmountType();
req.DoCaptureRequest.Amount.value = Math.Round(capturePaymentRequest.Order.OrderTotal, 2).ToString("N", new CultureInfo("en-us"));
req.DoCaptureRequest.Amount.currencyID = PaypalHelper.GetPaypalCurrency(_currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId));
req.DoCaptureRequest.CompleteType = CompleteCodeType.COMPLETE;
var service = GetService();
DoCaptureResponseType response = service.DoCapture(req);
string error;
bool success = PaypalHelper.CheckSuccess(response, out error);
if (success)
{
result.NewPaymentStatus = PaymentStatus.Paid;
result.CaptureTransactionId = response.DoCaptureResponseDetails.PaymentInfo.TransactionID;
result.CaptureTransactionResult = response.Ack.ToString();
}
else
{
result.AddError(error);
}
return result;
}
示例4: Capture
/// <summary>
/// Captures payment
/// </summary>
/// <param name="capturePaymentRequest">Capture payment request</param>
/// <returns>Capture payment result</returns>
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
string authorizationId = capturePaymentRequest.Order.AuthorizationTransactionId;
var req = new DoCaptureReq();
req.DoCaptureRequest = new DoCaptureRequestType();
req.DoCaptureRequest.Version = GetApiVersion();
req.DoCaptureRequest.AuthorizationID = authorizationId;
req.DoCaptureRequest.Amount = new BasicAmountType();
req.DoCaptureRequest.Amount.Value = Math.Round(capturePaymentRequest.Order.OrderTotal, 2).ToString("N", new CultureInfo("en-us"));
req.DoCaptureRequest.Amount.currencyID = PaypalHelper.GetPaypalCurrency(_currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId));
req.DoCaptureRequest.CompleteType = CompleteCodeType.Complete;
using (var service2 = new PayPalAPIAASoapBinding())
{
if (!_paypalDirectPaymentSettings.UseSandbox)
service2.Url = "https://api-3t.paypal.com/2.0/";
else
service2.Url = "https://api-3t.sandbox.paypal.com/2.0/";
service2.RequesterCredentials = new CustomSecurityHeaderType();
service2.RequesterCredentials.Credentials = new UserIdPasswordType();
service2.RequesterCredentials.Credentials.Username = _paypalDirectPaymentSettings.ApiAccountName;
service2.RequesterCredentials.Credentials.Password = _paypalDirectPaymentSettings.ApiAccountPassword;
service2.RequesterCredentials.Credentials.Signature = _paypalDirectPaymentSettings.Signature;
service2.RequesterCredentials.Credentials.Subject = "";
DoCaptureResponseType response = service2.DoCapture(req);
string error = "";
bool success = PaypalHelper.CheckSuccess(response, out error);
if (success)
{
result.NewPaymentStatus = PaymentStatus.Paid;
result.CaptureTransactionId = response.DoCaptureResponseDetails.PaymentInfo.TransactionID;
result.CaptureTransactionResult = response.Ack.ToString();
}
else
{
result.AddError(error);
}
}
return result;
}
示例5: Capture
/// <summary>
/// Capture 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> Capture(Order order)
{
if (order == null)
throw new ArgumentNullException("order");
if (!CanCapture(order))
throw new NopException("Cannot do capture for order.");
var request = new CapturePaymentRequest();
CapturePaymentResult result = null;
try
{
//old info from placing order
request.Order = order;
result = _paymentService.Capture(request);
if (result.Success)
{
var paidDate = order.PaidDateUtc;
if (result.NewPaymentStatus == PaymentStatus.Paid)
paidDate = DateTime.UtcNow;
order.CaptureTransactionId = result.CaptureTransactionId;
order.CaptureTransactionResult = result.CaptureTransactionResult;
order.PaymentStatus = result.NewPaymentStatus;
order.PaidDateUtc = paidDate;
_orderService.UpdateOrder(order);
//add a note
order.OrderNotes.Add(new OrderNote
{
Note = "Order has been captured",
DisplayToCustomer = false,
CreatedOnUtc = DateTime.UtcNow
});
_orderService.UpdateOrder(order);
CheckOrderStatus(order);
if (order.PaymentStatus == PaymentStatus.Paid)
{
ProcessOrderPaid(order);
}
}
}
catch (Exception exc)
{
if (result == null)
result = new CapturePaymentResult();
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 capture order. {0}", error),
DisplayToCustomer = false,
CreatedOnUtc = DateTime.UtcNow
});
_orderService.UpdateOrder(order);
//log it
string logError = string.Format("Error capturing order #{0}. Error: {1}", order.Id, error);
_logger.InsertLog(LogLevel.Error, logError, logError);
}
return result.Errors;
}
示例6: Capture
/// <summary>
/// Captures payment
/// </summary>
/// <param name="capturePaymentRequest">Capture payment request</param>
/// <returns>Capture payment result</returns>
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
var webClient = new WebClient();
var form = new NameValueCollection();
form.Add("x_login", _authorizeNetPaymentSettings.LoginId);
form.Add("x_tran_key", _authorizeNetPaymentSettings.TransactionKey);
//we should not send "x_test_request" parameter. otherwise, the transaction won't be logged in the sandbox
//if (_authorizeNetPaymentSettings.UseSandbox)
// form.Add("x_test_request", "TRUE");
//else
// form.Add("x_test_request", "FALSE");
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);
form.Add("x_type", "PRIOR_AUTH_CAPTURE");
var orderTotal = Math.Round(capturePaymentRequest.Order.OrderTotal, 2);
form.Add("x_amount", orderTotal.ToString("0.00", CultureInfo.InvariantCulture));
string[] codes = capturePaymentRequest.Order.AuthorizationTransactionCode.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]);
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":
result.CaptureTransactionId = string.Format("{0},{1}", responseFields[6], responseFields[4]);
result.CaptureTransactionResult = string.Format("Approved ({0}: {1})", responseFields[2], responseFields[3]);
//result.AVSResult = responseFields[5];
//responseFields[38];
result.NewPaymentStatus = PaymentStatus.Paid;
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;
}
示例7: Capture
/// <summary>
/// Captures payment
/// </summary>
/// <param name="capturePaymentRequest">Capture payment request</param>
/// <returns>Capture payment result</returns>
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
string googleOrderNumber = capturePaymentRequest.Order.AuthorizationTransactionId;
var chargeOrderRequest = new GCheckout.OrderProcessing.ChargeOrderRequest(googleOrderNumber);
var chargeOrderResponse = chargeOrderRequest.Send();
if (chargeOrderResponse.IsGood)
{
result.NewPaymentStatus = PaymentStatus.Paid;
result.CaptureTransactionResult = chargeOrderResponse.ResponseXml;
}
else
{
result.AddError(chargeOrderResponse.ErrorMessage);
}
return result;
}
示例8: Capture
/// <summary>
/// Captures payment
/// </summary>
/// <param name="capturePaymentRequest">Capture payment request</param>
/// <returns>Capture payment result</returns>
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
return result;
}
示例9: Capture
/// <summary>
/// Captures payment
/// </summary>
/// <param name="capturePaymentRequest">Capture payment request</param>
/// <returns>Capture payment result</returns>
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
var config = new HpsServicesConfig();
config.SecretApiKey = _secureSubmitPaymentSettings.SecretApiKey;
config.DeveloperId = "002914";
config.VersionNumber = "1513";
var creditService = new HpsCreditService(config);
try
{
var response = creditService.Capture(Convert.ToInt32(capturePaymentRequest.Order.AuthorizationTransactionId), capturePaymentRequest.Order.OrderTotal);
result.NewPaymentStatus = PaymentStatus.Paid;
result.CaptureTransactionId = response.TransactionId.ToString();
result.CaptureTransactionResult = response.ResponseText;
}
catch (HpsException ex)
{
result.AddError(ex.Message);
}
return result;
}
开发者ID:JacobSteelsmith,项目名称:heartland-nopcommerce-plugin,代码行数:31,代码来源:SecureSubmitPaymentProcessor.cs
示例10: Capture
/// <summary>
/// Captures payment
/// </summary>
/// <param name="capturePaymentRequest">Capture payment request</param>
/// <returns>Capture payment result</returns>
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
// Check license
bool isLicensed = this._licenseService.IsLicensed(HttpContext.Current.Request.Url.Host);
if (!isLicensed && capturePaymentRequest.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 authorizationId = capturePaymentRequest.Order.AuthorizationTransactionId;
// 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());
CaptureTransaction trans = new CaptureTransaction(authorizationId, payflowUser, payflowConn, 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)
{
result.NewPaymentStatus = PaymentStatus.Paid;
result.CaptureTransactionId = trxResp.Pnref;
result.CaptureTransactionResult = trxResp.RespMsg;
}
else
{
result.AddError(string.Format("Capture RESULT: {0}-{1}", trxResp.Result, trxResp.RespMsg));
}
}
}
return result;
}
开发者ID:CloudberrySoftware,项目名称:PayPalAdvanced-Payments-Plugin,代码行数:51,代码来源:PayPalAdvancedPaymentProcessor.cs
示例11: Capture
/// <summary>
/// Captures payment
/// </summary>
/// <param name="capturePaymentRequest">Capture payment request</param>
/// <returns>Capture payment result</returns>
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
PayfirmaTransaction payfirma = new PayfirmaTransaction();
PayfirmaTransactionResponse payfirmaResponse =
payfirma.ProcessCapture(this.PopulateMerchantCredentials(), capturePaymentRequest.Order.AuthorizationTransactionId,
Convert.ToDouble(capturePaymentRequest.Order.OrderTotal), _payfirmaPaymentSettings.IsTest);
if (!String.IsNullOrEmpty(payfirmaResponse.Error))
{
result.AddError(payfirmaResponse.Error);
}
else if (!payfirmaResponse.Result)
{
result.AddError(payfirmaResponse.ResultMessage);
}
else
{
result.CaptureTransactionId = payfirmaResponse.TransactionId;
result.CaptureTransactionResult = payfirmaResponse.ResultMessage;
result.NewPaymentStatus = PaymentStatus.Paid;
}
return result;
}
示例12: Capture
/// <summary>
/// Captures payment
/// </summary>
/// <param name="capturePaymentRequest">Capture payment request</param>
/// <returns>Capture payment result</returns>
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
var releaseResult = _sagePayServerWorkflowService.ReleaseTransaction(capturePaymentRequest.Order.OrderGuid.ToString(), capturePaymentRequest.Order.OrderTotal);
if (!releaseResult.Success)
{
result.AddError(releaseResult.Message);
}
else
{
result.NewPaymentStatus = PaymentStatus.Paid;
result.CaptureTransactionResult = releaseResult.Message;
}
return result;
}
示例13: Capture
/// <summary>
/// Captures payment
/// </summary>
/// <param name="capturePaymentRequest">Capture payment request</param>
/// <returns>Capture payment result</returns>
public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = new CapturePaymentResult();
var orderGuid = capturePaymentRequest.Order.OrderGuid;
if (orderGuid == Guid.NewGuid())
{
result.AddError("Order Unique identifier 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", "RELEASE");
data.Add("Vendor", _sagePayServerPaymentSettings.VendorName);
data.Add("VendorTxCode", orderGuid.ToString());
data.Add("VPSTxId", transx.VPSTxId);
data.Add("SecurityKey", transx.SecurityKey);
data.Add("TxAuthNo", transx.TxAuthNo);
data.Add("ReleaseAmount", capturePaymentRequest.Order.OrderTotal.ToString("F2", CultureInfo.InvariantCulture));
var postURL = SagePayHelper.GetSageSystemUrl(_sagePayServerPaymentSettings.ConnectTo, "release");
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.Paid;
//result.CaptureTransactionId = null;
result.CaptureTransactionResult = strStatusDetail;
break;
case "MALFORMED":
result.AddError(string.Format("Error ({0}: {1}) <br/> {2}", strStatus, strStatusDetail, data.Encode()));
return result;
case "INVALID":
result.AddError(string.Format("Error ({0}: {1}) <br/> {2}", strStatus, strStatusDetail, data.Encode()));
return result;
default:
result.AddError(string.Format("Error ({0}: {1})", strStatus, strStatusDetail));
return result;
}
//.........这里部分代码省略.........