本文整理汇总了C#中Nop.Services.Payments.ProcessPaymentResult类的典型用法代码示例。如果您正苦于以下问题:C# ProcessPaymentResult类的具体用法?C# ProcessPaymentResult怎么用?C# ProcessPaymentResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcessPaymentResult类属于Nop.Services.Payments命名空间,在下文中一共展示了ProcessPaymentResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessPayment
/// <summary>
/// Process a payment
/// </summary>
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
/// <returns>Process payment result</returns>
public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = new ProcessPaymentResult();
result.AllowStoringCreditCardNumber = true;
switch (_manualPaymentSettings.TransactMode)
{
case TransactMode.Pending:
result.NewPaymentStatus = PaymentStatus.Pending;
break;
case TransactMode.Authorize:
result.NewPaymentStatus = PaymentStatus.Authorized;
break;
case TransactMode.AuthorizeAndCapture:
result.NewPaymentStatus = PaymentStatus.Paid;
break;
default:
{
result.AddError("Not supported transaction type");
return result;
}
}
return result;
}
示例2: ProcessPayment
/// <summary>
/// Process a payment
/// </summary>
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
/// <returns>Process payment result</returns>
public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = new ProcessPaymentResult();
var orderGuid = processPaymentRequest.OrderGuid;
if (orderGuid == Guid.NewGuid())
{
result.AddError("SagePay Server transaction code does not exist!");
return result;
}
var transx = _sagePayServerTransactionService.GetSagePayServerTransactionByVendorTxCode(orderGuid.ToString());
if (transx == null)
{
result.AddError(String.Format("SagePay Server transaction code {0} does not exist.", orderGuid.ToString()));
return result;
}
if ((transx.Status == "OK") || (transx.Status == "AUTHENTICATED") || (transx.Status == "REGISTERED"))
{
if (_sagePayServerPaymentSettings.TransactType == SagePayServerPaymentSettings.TransactTypeValues.PAYMENT)
result.NewPaymentStatus = PaymentStatus.Paid;
else if (_sagePayServerPaymentSettings.TransactType == SagePayServerPaymentSettings.TransactTypeValues.DEFERRED)
result.NewPaymentStatus = PaymentStatus.Authorized;
else
result.NewPaymentStatus = PaymentStatus.Pending;
result.AuthorizationTransactionId = transx.Id.ToString();
result.AuthorizationTransactionCode = transx.VPSTxId;
result.AuthorizationTransactionResult = transx.ToString();
}
else
{
result.AddError(transx.StatusDetail);
}
return result;
}
示例3: ProcessRecurringPayment
/// <summary>
/// Process recurring payment
/// </summary>
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
/// <returns>Process payment result</returns>
public ProcessPaymentResult ProcessRecurringPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = new ProcessPaymentResult();
result.AllowStoringCreditCardNumber = true;
return result;
}
示例4: ProcessRecurringPayment
/// <summary>
/// Process recurring payment
/// </summary>
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
/// <returns>Process payment result</returns>
public ProcessPaymentResult ProcessRecurringPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = new ProcessPaymentResult();
result.AddError("Recurring payment not supported");
return result;
}
示例5: ProcessRecurringPayment
/// <summary>
/// Process recurring payment
/// </summary>
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
/// <returns>Process payment result</returns>
public ProcessPaymentResult ProcessRecurringPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = new ProcessPaymentResult();
var customer = _customerService.GetCustomerById(processPaymentRequest.CustomerId);
var req = new CreateRecurringPaymentsProfileReq();
req.CreateRecurringPaymentsProfileRequest = new CreateRecurringPaymentsProfileRequestType();
req.CreateRecurringPaymentsProfileRequest.Version = GetApiVersion();
var details = new CreateRecurringPaymentsProfileRequestDetailsType();
req.CreateRecurringPaymentsProfileRequest.CreateRecurringPaymentsProfileRequestDetails = details;
details.CreditCard = new CreditCardDetailsType();
details.CreditCard.CreditCardNumber = processPaymentRequest.CreditCardNumber;
details.CreditCard.CreditCardType = GetPaypalCreditCardType(processPaymentRequest.CreditCardType);
details.CreditCard.ExpMonth = processPaymentRequest.CreditCardExpireMonth;
details.CreditCard.ExpYear = processPaymentRequest.CreditCardExpireYear;
details.CreditCard.CVV2 = processPaymentRequest.CreditCardCvv2;
details.CreditCard.CardOwner = new PayerInfoType();
var country = EngineContext.Current.Resolve<ICountryService>().GetCountryById(customer.BillingAddress.CountryId);
details.CreditCard.CardOwner.PayerCountry = GetPaypalCountryCodeType(country);
details.CreditCard.CardOwner.Address = new AddressType();
details.CreditCard.CardOwner.Address.Street1 = customer.BillingAddress.Address1;
details.CreditCard.CardOwner.Address.Street2 = customer.BillingAddress.Address2;
details.CreditCard.CardOwner.Address.CityName = customer.BillingAddress.City;
if (customer.BillingAddress.StateProvinceId != 0)
{
var state = EngineContext.Current.Resolve<IStateProvinceService>().GetStateProvinceById(customer.BillingAddress.StateProvinceId);
details.CreditCard.CardOwner.Address.StateOrProvince = state.Abbreviation;
}
else
details.CreditCard.CardOwner.Address.StateOrProvince = "CA";
details.CreditCard.CardOwner.Address.Country = GetPaypalCountryCodeType(country);
details.CreditCard.CardOwner.Address.PostalCode = customer.BillingAddress.ZipPostalCode;
details.CreditCard.CardOwner.Payer = customer.BillingAddress.Email;
details.CreditCard.CardOwner.PayerName = new PersonNameType();
details.CreditCard.CardOwner.PayerName.FirstName = customer.BillingAddress.FirstName;
details.CreditCard.CardOwner.PayerName.LastName = customer.BillingAddress.LastName;
//start date
details.RecurringPaymentsProfileDetails = new RecurringPaymentsProfileDetailsType();
details.RecurringPaymentsProfileDetails.BillingStartDate = DateTime.UtcNow.ToString("s", CultureInfo.InvariantCulture);
details.RecurringPaymentsProfileDetails.ProfileReference = processPaymentRequest.OrderGuid.ToString();
//schedule
details.ScheduleDetails = new ScheduleDetailsType();
details.ScheduleDetails.Description = "Recurring payment";
details.ScheduleDetails.PaymentPeriod = new BillingPeriodDetailsType();
details.ScheduleDetails.PaymentPeriod.Amount = new BasicAmountType();
details.ScheduleDetails.PaymentPeriod.Amount.value = Math.Round(processPaymentRequest.OrderTotal, 2).ToString("N", new CultureInfo("en-us"));
details.ScheduleDetails.PaymentPeriod.Amount.currencyID = PaypalHelper.GetPaypalCurrency(_currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId));
details.ScheduleDetails.PaymentPeriod.BillingFrequency = processPaymentRequest.RecurringCycleLength;
switch (processPaymentRequest.RecurringCyclePeriod)
{
case RecurringProductCyclePeriod.Days:
details.ScheduleDetails.PaymentPeriod.BillingPeriod = BillingPeriodType.DAY;
break;
case RecurringProductCyclePeriod.Weeks:
details.ScheduleDetails.PaymentPeriod.BillingPeriod = BillingPeriodType.WEEK;
break;
case RecurringProductCyclePeriod.Months:
details.ScheduleDetails.PaymentPeriod.BillingPeriod = BillingPeriodType.MONTH;
break;
case RecurringProductCyclePeriod.Years:
details.ScheduleDetails.PaymentPeriod.BillingPeriod = BillingPeriodType.YEAR;
break;
default:
throw new NopException("Not supported cycle period");
}
details.ScheduleDetails.PaymentPeriod.TotalBillingCycles = processPaymentRequest.RecurringTotalCycles;
var service = GetService();
CreateRecurringPaymentsProfileResponseType response = service.CreateRecurringPaymentsProfile(req);
string error;
bool success = PaypalHelper.CheckSuccess(response, out error);
if (success)
{
result.NewPaymentStatus = PaymentStatus.Pending;
if (response.CreateRecurringPaymentsProfileResponseDetails != null)
{
result.SubscriptionTransactionId = response.CreateRecurringPaymentsProfileResponseDetails.ProfileID;
}
}
else
{
result.AddError(error);
}
return result;
}
示例6: AuthorizeOrSale
protected ProcessPaymentResult AuthorizeOrSale(ProcessPaymentRequest processPaymentRequest, bool authorizeOnly)
{
var result = new ProcessPaymentResult();
var customer = _customerService.GetCustomerById(processPaymentRequest.CustomerId);
if (customer == null)
throw new Exception("Customer cannot be loaded");
var req = new DoDirectPaymentReq();
req.DoDirectPaymentRequest = new DoDirectPaymentRequestType();
req.DoDirectPaymentRequest.Version = GetApiVersion();
var details = new DoDirectPaymentRequestDetailsType();
req.DoDirectPaymentRequest.DoDirectPaymentRequestDetails = details;
details.IPAddress = _webHelper.GetCurrentIpAddress() ?? "";
if (authorizeOnly)
details.PaymentAction = PaymentActionCodeType.Authorization;
else
details.PaymentAction = PaymentActionCodeType.Sale;
//credit card
details.CreditCard = new CreditCardDetailsType();
details.CreditCard.CreditCardNumber = processPaymentRequest.CreditCardNumber;
details.CreditCard.CreditCardType = GetPaypalCreditCardType(processPaymentRequest.CreditCardType);
details.CreditCard.ExpMonthSpecified = true;
details.CreditCard.ExpMonth = processPaymentRequest.CreditCardExpireMonth;
details.CreditCard.ExpYearSpecified = true;
details.CreditCard.ExpYear = processPaymentRequest.CreditCardExpireYear;
details.CreditCard.CVV2 = processPaymentRequest.CreditCardCvv2;
details.CreditCard.CardOwner = new PayerInfoType();
details.CreditCard.CardOwner.PayerCountry = GetPaypalCountryCodeType(customer.BillingAddress.Country);
details.CreditCard.CreditCardTypeSpecified = true;
//billing address
details.CreditCard.CardOwner.Address = new AddressType();
details.CreditCard.CardOwner.Address.CountrySpecified = true;
details.CreditCard.CardOwner.Address.Street1 = customer.BillingAddress.Address1;
details.CreditCard.CardOwner.Address.Street2 = customer.BillingAddress.Address2;
details.CreditCard.CardOwner.Address.CityName = customer.BillingAddress.City;
if (customer.BillingAddress.StateProvince != null)
details.CreditCard.CardOwner.Address.StateOrProvince = customer.BillingAddress.StateProvince.Abbreviation;
else
details.CreditCard.CardOwner.Address.StateOrProvince = "CA";
details.CreditCard.CardOwner.Address.Country = GetPaypalCountryCodeType(customer.BillingAddress.Country);
details.CreditCard.CardOwner.Address.PostalCode = customer.BillingAddress.ZipPostalCode;
details.CreditCard.CardOwner.Payer = customer.BillingAddress.Email;
details.CreditCard.CardOwner.PayerName = new PersonNameType();
details.CreditCard.CardOwner.PayerName.FirstName = customer.BillingAddress.FirstName;
details.CreditCard.CardOwner.PayerName.LastName = customer.BillingAddress.LastName;
//order totals
var payPalCurrency = PaypalHelper.GetPaypalCurrency(_currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId));
details.PaymentDetails = new PaymentDetailsType();
details.PaymentDetails.OrderTotal = new BasicAmountType();
details.PaymentDetails.OrderTotal.Value = Math.Round(processPaymentRequest.OrderTotal, 2).ToString("N", new CultureInfo("en-us"));
details.PaymentDetails.OrderTotal.currencyID = payPalCurrency;
details.PaymentDetails.Custom = processPaymentRequest.OrderGuid.ToString();
details.PaymentDetails.ButtonSource = "nopCommerceCart";
//pass product names and totals to PayPal
//if (_paypalDirectPaymentSettings.PassProductNamesAndTotals)
//{
// //individual items
//var cart = customer.ShoppingCartItems
// .Where(x=>x.ShoppingCartType == ShoppingCartType.ShoppingCart)
// .LimitPerStore(processPaymentRequest.StoreId)
// .ToList();
// var cartItems = new PaymentDetailsItemType[cart.Count];
// for (int i = 0; i < cart.Count; i++)
// {
// var sc = cart[i];
// decimal taxRate = decimal.Zero;
// var customer = processPaymentRequest.Customer;
// decimal scUnitPrice = _priceCalculationService.GetUnitPrice(sc, true);
// decimal scSubTotal = _priceCalculationService.GetSubTotal(sc, true);
// decimal scUnitPriceInclTax = _taxService.GetProductPrice(sc.ProductVariant, scUnitPrice, true, customer, out taxRate);
// decimal scUnitPriceExclTax = _taxService.GetProductPrice(sc.ProductVariant, scUnitPrice, false, customer, out taxRate);
// //decimal scSubTotalInclTax = _taxService.GetProductPrice(sc.ProductVariant, scSubTotal, true, customer, out taxRate);
// //decimal scSubTotalExclTax = _taxService.GetProductPrice(sc.ProductVariant, scSubTotal, false, customer, out taxRate);
// cartItems[i] = new PaymentDetailsItemType()
// {
// Name = sc.ProductVariant.FullProductName,
// Number = sc.ProductVariant.Id.ToString(),
// Quantity = sc.Quantity.ToString(),
// Amount = new BasicAmountType()
// {
// currencyID = payPalCurrency,
// Value = scUnitPriceExclTax.ToString("N", new CultureInfo("en-us")),
// },
// Tax = new BasicAmountType()
// {
// currencyID = payPalCurrency,
// Value = (scUnitPriceInclTax - scUnitPriceExclTax).ToString("N", new CultureInfo("en-us")),
// },
// };
// };
// details.PaymentDetails.PaymentDetailsItem = cartItems;
// //other totals (undone)
// details.PaymentDetails.ItemTotal = null;
// details.PaymentDetails.ShippingTotal = null;
// details.PaymentDetails.TaxTotal = null;
// details.PaymentDetails.HandlingTotal = null;
//}
//shipping
if (customer.ShippingAddress != null)
//.........这里部分代码省略.........
示例7: ProcessRecurringPayment
/// <summary>
/// Process recurring payment
/// </summary>
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
/// <returns>Process payment result</returns>
public virtual ProcessPaymentResult ProcessRecurringPayment(ProcessPaymentRequest processPaymentRequest)
{
if (processPaymentRequest.OrderTotal == decimal.Zero)
{
var result = new ProcessPaymentResult()
{
NewPaymentStatus = PaymentStatus.Paid
};
return result;
}
else
{
var paymentMethod = LoadPaymentMethodBySystemName(processPaymentRequest.PaymentMethodSystemName);
if (paymentMethod == null)
throw new NopException("Payment method couldn't be loaded");
return paymentMethod.ProcessRecurringPayment(processPaymentRequest);
}
}
示例8: ProcessRecurringPayment
/// <summary>
/// Process recurring payment
/// </summary>
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
/// <returns>Process payment result</returns>
public ProcessPaymentResult ProcessRecurringPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = new ProcessPaymentResult();
if (!processPaymentRequest.IsRecurringPayment)
{
var customer = _customerService.GetCustomerById(processPaymentRequest.CustomerId);
var subscription = new ARBSubscriptionType();
var creditCard = new net.authorize.api.CreditCardType();
subscription.name = processPaymentRequest.OrderGuid.ToString();
creditCard.cardNumber = processPaymentRequest.CreditCardNumber;
creditCard.expirationDate = processPaymentRequest.CreditCardExpireYear + "-" + processPaymentRequest.CreditCardExpireMonth; // required format for API is YYYY-MM
creditCard.cardCode = processPaymentRequest.CreditCardCvv2;
subscription.payment = new PaymentType();
subscription.payment.Item = creditCard;
subscription.billTo = new NameAndAddressType();
subscription.billTo.firstName = customer.BillingAddress.FirstName;
subscription.billTo.lastName = customer.BillingAddress.LastName;
subscription.billTo.address = customer.BillingAddress.Address1;
//subscription.billTo.address = customer.BillingAddress.Address1 + " " + customer.BillingAddress.Address2;
subscription.billTo.city = customer.BillingAddress.City;
if (customer.BillingAddress.StateProvince != null)
{
subscription.billTo.state = customer.BillingAddress.StateProvince.Abbreviation;
}
subscription.billTo.zip = customer.BillingAddress.ZipPostalCode;
if (customer.ShippingAddress != null)
{
subscription.shipTo = new NameAndAddressType();
subscription.shipTo.firstName = customer.ShippingAddress.FirstName;
subscription.shipTo.lastName = customer.ShippingAddress.LastName;
subscription.shipTo.address = customer.ShippingAddress.Address1;
//subscription.shipTo.address = customer.ShippingAddress.Address1 + " " + customer.ShippingAddress.Address2;
subscription.shipTo.city = customer.ShippingAddress.City;
if (customer.ShippingAddress.StateProvince != null)
{
subscription.shipTo.state = customer.ShippingAddress.StateProvince.Abbreviation;
}
subscription.shipTo.zip = customer.ShippingAddress.ZipPostalCode;
}
subscription.customer = new CustomerType();
subscription.customer.email = customer.BillingAddress.Email;
subscription.customer.phoneNumber = customer.BillingAddress.PhoneNumber;
subscription.order = new OrderType();
subscription.order.description = "Recurring payment";
// Create a subscription that is leng of specified occurrences and interval is amount of days ad runs
subscription.paymentSchedule = new PaymentScheduleType();
DateTime dtNow = DateTime.UtcNow;
subscription.paymentSchedule.startDate = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day);
subscription.paymentSchedule.startDateSpecified = true;
subscription.paymentSchedule.totalOccurrences = Convert.ToInt16(processPaymentRequest.RecurringTotalCycles);
subscription.paymentSchedule.totalOccurrencesSpecified = true;
var orderTotal = Math.Round(processPaymentRequest.OrderTotal, 2);
subscription.amount = orderTotal;
subscription.amountSpecified = true;
// Interval can't be updated once a subscription is created.
subscription.paymentSchedule.interval = new PaymentScheduleTypeInterval();
switch (processPaymentRequest.RecurringCyclePeriod)
{
case RecurringProductCyclePeriod.Days:
subscription.paymentSchedule.interval.length = Convert.ToInt16(processPaymentRequest.RecurringCycleLength);
subscription.paymentSchedule.interval.unit = ARBSubscriptionUnitEnum.days;
break;
case RecurringProductCyclePeriod.Weeks:
subscription.paymentSchedule.interval.length = Convert.ToInt16(processPaymentRequest.RecurringCycleLength * 7);
subscription.paymentSchedule.interval.unit = ARBSubscriptionUnitEnum.days;
break;
case RecurringProductCyclePeriod.Months:
subscription.paymentSchedule.interval.length = Convert.ToInt16(processPaymentRequest.RecurringCycleLength);
subscription.paymentSchedule.interval.unit = ARBSubscriptionUnitEnum.months;
break;
case RecurringProductCyclePeriod.Years:
subscription.paymentSchedule.interval.length = Convert.ToInt16(processPaymentRequest.RecurringCycleLength * 12);
subscription.paymentSchedule.interval.unit = ARBSubscriptionUnitEnum.months;
break;
default:
throw new NopException("Not supported cycle period");
}
using (var webService = new net.authorize.api.Service())
{
//.........这里部分代码省略.........
示例9: ProcessPayment
/// <summary>
/// Process a payment
/// </summary>
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
/// <returns>Process payment result</returns>
public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = new ProcessPaymentResult();
result.NewPaymentStatus = PaymentStatus.Pending;
result.AuthorizationTransactionId = processPaymentRequest.GoogleOrderNumber;
return result;
}
示例10: PlaceOrder
/// <summary>
/// Places an order
/// </summary>
/// <param name="processPaymentRequest">Process payment request</param>
/// <returns>Place order result</returns>
public virtual PlaceOrderResult PlaceOrder(ProcessPaymentRequest processPaymentRequest)
{
if (processPaymentRequest == null)
throw new ArgumentNullException("processPaymentRequest");
var result = new PlaceOrderResult();
try
{
if (processPaymentRequest.OrderGuid == Guid.Empty)
processPaymentRequest.OrderGuid = Guid.NewGuid();
//prepare order details
var details = PreparePlaceOrderDetails(processPaymentRequest);
#region Payment workflow
//process payment
ProcessPaymentResult processPaymentResult = null;
//skip payment workflow if order total equals zero
var skipPaymentWorkflow = details.OrderTotal == decimal.Zero;
if (!skipPaymentWorkflow)
{
var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(processPaymentRequest.PaymentMethodSystemName);
if (paymentMethod == null)
throw new NopException("Payment method couldn't be loaded");
//ensure that payment method is active
if (!paymentMethod.IsPaymentMethodActive(_paymentSettings))
throw new NopException("Payment method is not active");
if (details.IsRecurringShoppingCart)
{
//recurring cart
switch (_paymentService.GetRecurringPaymentType(processPaymentRequest.PaymentMethodSystemName))
{
case RecurringPaymentType.NotSupported:
throw new NopException("Recurring payments are not supported by selected payment method");
case RecurringPaymentType.Manual:
case RecurringPaymentType.Automatic:
processPaymentResult = _paymentService.ProcessRecurringPayment(processPaymentRequest);
break;
default:
throw new NopException("Not supported recurring payment type");
}
}
else
//standard cart
processPaymentResult = _paymentService.ProcessPayment(processPaymentRequest);
}
else
//payment is not required
processPaymentResult = new ProcessPaymentResult { NewPaymentStatus = PaymentStatus.Paid };
if (processPaymentResult == null)
throw new NopException("processPaymentResult is not available");
#endregion
if (processPaymentResult.Success)
{
#region Save order details
var order = SaveOrderDetails(processPaymentRequest, processPaymentResult, details);
result.PlacedOrder = order;
//move shopping cart items to order items
foreach (var sc in details.Cart)
{
//prices
decimal taxRate;
List<Discount> scDiscounts;
decimal discountAmount;
var scUnitPrice = _priceCalculationService.GetUnitPrice(sc);
var scSubTotal = _priceCalculationService.GetSubTotal(sc, true, out discountAmount, out scDiscounts);
var scUnitPriceInclTax = _taxService.GetProductPrice(sc.Product, scUnitPrice, true, details.Customer, out taxRate);
var scUnitPriceExclTax = _taxService.GetProductPrice(sc.Product, scUnitPrice, false, details.Customer, out taxRate);
var scSubTotalInclTax = _taxService.GetProductPrice(sc.Product, scSubTotal, true, details.Customer, out taxRate);
var scSubTotalExclTax = _taxService.GetProductPrice(sc.Product, scSubTotal, false, details.Customer, out taxRate);
var discountAmountInclTax = _taxService.GetProductPrice(sc.Product, discountAmount, true, details.Customer, out taxRate);
var discountAmountExclTax = _taxService.GetProductPrice(sc.Product, discountAmount, false, details.Customer, out taxRate);
foreach (var disc in scDiscounts)
if (!details.AppliedDiscounts.ContainsDiscount(disc))
details.AppliedDiscounts.Add(disc);
//attributes
var attributeDescription = _productAttributeFormatter.FormatAttributes(sc.Product, sc.AttributesXml, details.Customer);
var itemWeight = _shippingService.GetShoppingCartItemWeight(sc);
//save order item
var orderItem = new OrderItem
{
OrderItemGuid = Guid.NewGuid(),
Order = order,
//.........这里部分代码省略.........
示例11: ProcessPayment
public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = new ProcessPaymentResult();
var customer = _customerService.GetCustomerById(processPaymentRequest.CustomerId);
// Credit Card Info
PayfirmaCreditCard cc = new PayfirmaCreditCard()
{
Number = processPaymentRequest.CreditCardNumber,
ExpMonth = processPaymentRequest.CreditCardExpireMonth,
ExpYear = processPaymentRequest.CreditCardExpireYear,
CVV2 = processPaymentRequest.CreditCardCvv2
};
// Extra Meta Data
PayfirmaMetaData payfirmaMeta = new PayfirmaMetaData();
payfirmaMeta.Firstname = customer.BillingAddress.FirstName;
payfirmaMeta.Lastname = customer.BillingAddress.LastName;
if (!String.IsNullOrEmpty(customer.BillingAddress.Company)) { payfirmaMeta.Company = customer.BillingAddress.Company; }
payfirmaMeta.Address1 = customer.BillingAddress.Address1;
if (!String.IsNullOrEmpty(customer.BillingAddress.Address2)) { payfirmaMeta.Address2 = customer.BillingAddress.Address2; }
payfirmaMeta.City = customer.BillingAddress.City;
if (customer.BillingAddress.StateProvince != null)
{
payfirmaMeta.Province = customer.BillingAddress.StateProvince.Name;
}
payfirmaMeta.PostalCode = customer.BillingAddress.ZipPostalCode;
if (customer.BillingAddress.Country != null)
{
payfirmaMeta.Country = customer.BillingAddress.Country.Name;
}
payfirmaMeta.Email = customer.BillingAddress.Email;
String currencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
payfirmaMeta.Currency = "CA$";
if (currencyCode == "USD") { payfirmaMeta.Currency = "US$"; }
payfirmaMeta.OrderId = processPaymentRequest.OrderGuid.ToString();
if (!String.IsNullOrEmpty(customer.BillingAddress.PhoneNumber)) { payfirmaMeta.Telephone = customer.BillingAddress.PhoneNumber; }
payfirmaMeta.Description = "Payment via nopCommerce.";
PayfirmaTransaction payfirma = new PayfirmaTransaction();
PayfirmaTransactionResponse payfirmaResponse;
if (_payfirmaPaymentSettings.TransactMode == TransactMode.Authorize)
{
payfirmaResponse = payfirma.ProcessAuthorize(this.PopulateMerchantCredentials(), cc, payfirmaMeta,
Convert.ToDouble(processPaymentRequest.OrderTotal), _payfirmaPaymentSettings.IsTest);
}
else
{
payfirmaResponse = payfirma.ProcessSale(this.PopulateMerchantCredentials(), cc, payfirmaMeta,
Convert.ToDouble(processPaymentRequest.OrderTotal), _payfirmaPaymentSettings.IsTest);
}
if (!String.IsNullOrEmpty(payfirmaResponse.Error))
{
result.AddError(payfirmaResponse.Error);
}
else if (!payfirmaResponse.Result)
{
result.AddError(payfirmaResponse.ResultMessage);
} else {
result.AvsResult = payfirmaResponse.AVS;
result.AuthorizationTransactionCode = payfirmaResponse.AuthCode;
result.AuthorizationTransactionId = payfirmaResponse.TransactionId;
result.AuthorizationTransactionResult = payfirmaResponse.ResultMessage;
if (_payfirmaPaymentSettings.TransactMode == TransactMode.Authorize)
{
result.NewPaymentStatus = PaymentStatus.Authorized;
}
else
{
result.NewPaymentStatus = PaymentStatus.Paid;
}
}
return result;
}
示例12: ProcessPayment
public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = new ProcessPaymentResult();
result.AllowStoringCreditCardNumber = true;
result.SubscriptionTransactionId = processPaymentRequest.CustomValues["yandexKassaMode"].ToString();
result.NewPaymentStatus = PaymentStatus.Pending;
return result;
}
示例13: ProcessPayment
/// <summary>
/// Process a payment
/// </summary>
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
/// <returns>Process payment result</returns>
public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
{
var googleOrderNumber = processPaymentRequest.CustomValues.ContainsKey("GoogleOrderNumber")
? processPaymentRequest.CustomValues["GoogleOrderNumber"] as string
: "";
var result = new ProcessPaymentResult();
result.NewPaymentStatus = PaymentStatus.Pending;
result.AuthorizationTransactionId = googleOrderNumber;
return result;
}
示例14: ProcessPayment
/// <summary>
/// Process a payment right after order is created
/// </summary>
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
/// <returns>Process payment result</returns>
public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = new ProcessPaymentResult();
var transx = _sagePayServerTransactionService.GetSagePayServerTransactionByVendorTxCode(processPaymentRequest.OrderGuid.ToString());
if (transx == null)
{
result.AddError(String.Format("SagePay Server transaction code {0} does not exist.", processPaymentRequest.OrderGuid));
return result;
}
if ((transx.Status == "OK") || (transx.Status == "AUTHENTICATED") || (transx.Status == "REGISTERED"))
{
switch (_sagePayServerPaymentSettings.TransactType)
{
case TransactTypeValues.Payment:
var releaseResult = _sagePayServerWorkflowService.ReleaseTransaction(processPaymentRequest.OrderGuid.ToString(), processPaymentRequest.OrderTotal);
if (releaseResult.Success)
{
result.NewPaymentStatus = PaymentStatus.Paid;
result.CaptureTransactionResult = releaseResult.Message;
}
else
{
result.AddError(releaseResult.Message);
}
break;
case TransactTypeValues.Deferred:
result.NewPaymentStatus = PaymentStatus.Authorized;
break;
default:
result.NewPaymentStatus = PaymentStatus.Pending;
break;
}
result.AuthorizationTransactionId = transx.Id.ToString(CultureInfo.InvariantCulture);
result.AuthorizationTransactionCode = transx.VpsTxId;
result.AuthorizationTransactionResult = transx.ToString();
}
else
{
result.AddError(transx.StatusDetail);
}
return result;
}
示例15: ProcessPayment
/// <summary>
/// Process a payment
/// </summary>
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
/// <returns>Process payment result</returns>
public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = new ProcessPaymentResult();
var customer = _customerService.GetCustomerById(processPaymentRequest.CustomerId);
//var orderTotal = Math.Round(processPaymentRequest.OrderTotal, 2);
StripeCreditCardInfo cc = new StripeCreditCardInfo();
cc.CVC = processPaymentRequest.CreditCardCvv2;
cc.FullName = customer.BillingAddress.FirstName + " " + customer.BillingAddress.LastName;
cc.Number = processPaymentRequest.CreditCardNumber;
cc.ExpirationMonth = processPaymentRequest.CreditCardExpireMonth;
cc.ExpirationYear = processPaymentRequest.CreditCardExpireYear;
cc.AddressLine1 = customer.BillingAddress.Address1;
cc.AddressLine2 = customer.BillingAddress.Address2;
if (customer.BillingAddress.Country.TwoLetterIsoCode.ToLower() == "us")
{
cc.StateOrProvince = customer.BillingAddress.StateProvince.Abbreviation;
}
else
{
cc.StateOrProvince = "ot";
}
cc.ZipCode = customer.BillingAddress.ZipPostalCode;
cc.Country = customer.BillingAddress.Country.TwoLetterIsoCode;
StripePayment payment = new StripePayment(_stripePaymentSettings.TransactionKey);
try
{
StripeCharge charge = payment.Charge((int)(processPaymentRequest.OrderTotal * 100),
_currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode.ToLower(),
cc, string.Format("charge for {0} - {1}",
cc.FullName, processPaymentRequest.PurchaseOrderNumber));
if (charge != null)
{
result.NewPaymentStatus = PaymentStatus.Paid;
_stripePaymentSettings.TransactMode = TransactMode.AuthorizeAndCapture;
result.AuthorizationTransactionId = charge.ID;
result.AuthorizationTransactionResult = StripeChargeStatus.SUCCESS;
//need this for refund
result.AuthorizationTransactionCode = _stripePaymentSettings.TransactionKey;
}
}
catch (StripeException stripeException)
{
result.AuthorizationTransactionResult = stripeException.StripeError.Message;
result.AuthorizationTransactionCode = stripeException.StripeError.Code;
result.AuthorizationTransactionId = "-1";
result.AddError(string.Format("Declined ({0}: {1} - {2})", result.AuthorizationTransactionCode,
result.AuthorizationTransactionResult, _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode));
}
return result;
}