本文整理汇总了C#中NopSolutions.NopCommerce.BusinessLogic.Payment.PaymentInfo类的典型用法代码示例。如果您正苦于以下问题:C# PaymentInfo类的具体用法?C# PaymentInfo怎么用?C# PaymentInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PaymentInfo类属于NopSolutions.NopCommerce.BusinessLogic.Payment命名空间,在下文中一共展示了PaymentInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPaymentInfo
public PaymentInfo GetPaymentInfo()
{
PaymentInfo paymentInfo = new PaymentInfo();
paymentInfo.CreditCardName = this.creditCardName.Text;
paymentInfo.CreditCardNumber = this.creditCardNumber.Text;
paymentInfo.CreditCardExpireYear = int.Parse((this.creditCardExpireYear.SelectedValue == null) ? "0" : this.creditCardExpireYear.SelectedValue);
paymentInfo.CreditCardExpireMonth = int.Parse((this.creditCardExpireMonth.SelectedValue == null) ? "0" : this.creditCardExpireMonth.SelectedValue);
paymentInfo.CreditCardCvv2 = this.creditCardCVV2.Text;
return paymentInfo;
}
示例2: GetPaymentInfo
public PaymentInfo GetPaymentInfo()
{
PaymentInfo paymentInfo = new PaymentInfo();
paymentInfo.CreditCardType = string.Empty;
paymentInfo.CreditCardName = string.Empty;
paymentInfo.CreditCardNumber = string.Empty;
paymentInfo.CreditCardExpireYear = 0;
paymentInfo.CreditCardExpireMonth = 0;
paymentInfo.CreditCardCvv2 = string.Empty;
return paymentInfo;
}
示例3: GetPaymentInfo
public PaymentInfo GetPaymentInfo()
{
PaymentInfo paymentInfo = new PaymentInfo();
int creditCardTypeId = int.Parse(this.ddlCreditCardType.SelectedItem.Value);
CreditCardType creditCardType = CreditCardTypeManager.GetCreditCardTypeById(creditCardTypeId);
if (creditCardType == null)
throw new NopException("Couldn't load credit card type");
paymentInfo.CreditCardType = creditCardType.SystemKeyword;
paymentInfo.CreditCardName = this.creditCardName.Text;
paymentInfo.CreditCardNumber = this.creditCardNumber.Text;
paymentInfo.CreditCardExpireYear = int.Parse((this.creditCardExpireYear.SelectedValue == null) ? "0" : this.creditCardExpireYear.SelectedValue);
paymentInfo.CreditCardExpireMonth = int.Parse((this.creditCardExpireMonth.SelectedValue == null) ? "0" : this.creditCardExpireMonth.SelectedValue);
paymentInfo.CreditCardCvv2 = this.creditCardCVV2.Text;
return paymentInfo;
}
示例4: ProcessPayment
/// <summary>
/// Process payment
/// </summary>
/// <param name="paymentInfo">Payment info required for an order processing</param>
/// <param name="customer">Customer</param>
/// <param name="OrderGuid">Unique order identifier</param>
/// <param name="processPaymentResult">Process payment result</param>
public static void ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid OrderGuid, ref ProcessPaymentResult processPaymentResult)
{
if (paymentInfo.OrderTotal == decimal.Zero)
{
processPaymentResult.Error = string.Empty;
processPaymentResult.FullError = string.Empty;
processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
}
else
{
PaymentMethod paymentMethod = PaymentMethodManager.GetPaymentMethodByID(paymentInfo.PaymentMethodID);
if (paymentMethod == null)
throw new NopException("Payment method couldn't be loaded");
IPaymentMethod iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;
iPaymentMethod.ProcessPayment(paymentInfo, customer, OrderGuid, ref processPaymentResult);
}
}
示例5: btnNextStep_Click
protected void btnNextStep_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
try
{
PayPalExpressPaymentProcessor payPalExpress = new PayPalExpressPaymentProcessor();
string token = CommonHelper.QueryString("token");
PaypalPayer payer = payPalExpress.GetExpressCheckout(token);
if (string.IsNullOrEmpty(payer.PayerID))
throw new NopException("Payer ID is not set");
PaymentInfo paymentInfo = new PaymentInfo();
PaymentMethod paypalExpressPaymentMethod = PaymentMethodManager.GetPaymentMethodBySystemKeyword("PayPalExpress");
paymentInfo.PaymentMethodId = paypalExpressPaymentMethod.PaymentMethodId;
paymentInfo.BillingAddress = NopContext.Current.User.BillingAddress;
paymentInfo.ShippingAddress = NopContext.Current.User.ShippingAddress;
paymentInfo.PaypalPayerId = payer.PayerID;
paymentInfo.PaypalToken = token;
paymentInfo.CustomerLanguage = NopContext.Current.WorkingLanguage;
paymentInfo.CustomerCurrency = NopContext.Current.WorkingCurrency;
int orderId = 0;
string result = OrderManager.PlaceOrder(paymentInfo, NopContext.Current.User, out orderId);
Order order = OrderManager.GetOrderById(orderId);
if (!String.IsNullOrEmpty(result))
{
lConfirmOrderError.Text = Server.HtmlEncode(result);
btnNextStep.Visible = false;
return;
}
else
PaymentManager.PostProcessPayment(order);
Response.Redirect("~/checkoutcompleted.aspx");
}
catch (Exception exc)
{
LogManager.InsertLog(LogTypeEnum.OrderError, exc.Message, exc);
lConfirmOrderError.Text = Server.HtmlEncode(exc.ToString());
btnNextStep.Visible = false;
}
}
}
示例6: ProcessPayment
/// <summary>
/// Process payment
/// </summary>
/// <param name="paymentInfo">Payment info required for an order processing</param>
/// <param name="customer">Customer</param>
/// <param name="orderGuid">Unique order identifier</param>
/// <param name="processPaymentResult">Process payment result</param>
public void ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid orderGuid, ref ProcessPaymentResult processPaymentResult)
{
XmlTransaction sxml = new XmlTransaction(XmlPaymentSettings.TestMode ? XmlTransaction.MODE_TEST : XmlTransaction.MODE_LIVE, SecurePaySettings.MerchantId, SecurePaySettings.MerchantPassword, ID);
bool success = false;
string code = "";
if(XmlPaymentSettings.AuthorizeOnly)
{
success = sxml.processPreauth(paymentInfo.OrderTotal, orderGuid.ToString(), paymentInfo.CreditCardNumber, paymentInfo.CreditCardExpireMonth.ToString("D2"), paymentInfo.CreditCardExpireYear.ToString().Substring(2, 2), paymentInfo.CreditCardCvv2.ToString());
}
else
{
success = sxml.processCredit(paymentInfo.OrderTotal, orderGuid.ToString(), paymentInfo.CreditCardNumber, paymentInfo.CreditCardExpireMonth.ToString("D2"), paymentInfo.CreditCardExpireYear.ToString().Substring(2, 2), paymentInfo.CreditCardCvv2.ToString());
}
code = sxml["response_code"];
if (!success)
{
processPaymentResult.Error = String.Format("Declined ({0})", code);
processPaymentResult.FullError = sxml.Error;
}
else
{
if(XmlPaymentSettings.AuthorizeOnly)
{
processPaymentResult.AuthorizationTransactionCode = (XmlPaymentSettings.AuthorizeOnly ? sxml["preauth_id"] : "");
processPaymentResult.AuthorizationTransactionId = sxml["transaction_id"];
processPaymentResult.AuthorizationTransactionResult = String.Format("Approved ({0})", code);
processPaymentResult.PaymentStatus = PaymentStatusEnum.Authorized;
}
else
{
processPaymentResult.CaptureTransactionId = sxml["transaction_id"];
processPaymentResult.CaptureTransactionResult = String.Format("Approved ({0})", code);
processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
}
}
}
示例7: PlaceOrder
/// <summary>
/// Places an order
/// </summary>
/// <param name="paymentInfo">Payment info</param>
/// <param name="customer">Customer</param>
/// <param name="OrderID">Order identifier</param>
/// <returns>The error status, or String.Empty if no errors</returns>
public static string PlaceOrder(PaymentInfo paymentInfo, Customer customer, out int OrderID)
{
Guid OrderGuid = Guid.NewGuid();
return PlaceOrder(paymentInfo, customer, OrderGuid, out OrderID);
}
示例8: PlaceOrder
/// <summary>
/// Places an order
/// </summary>
/// <param name="paymentInfo">Payment info</param>
/// <param name="customer">Customer</param>
/// <param name="orderGuid">Order GUID to use</param>
/// <param name="orderId">Order identifier</param>
/// <returns>The error status, or String.Empty if no errors</returns>
public string PlaceOrder(PaymentInfo paymentInfo, Customer customer,
Guid orderGuid, out int orderId)
{
orderId = 0;
var processPaymentResult = new ProcessPaymentResult();
var customerService = IoC.Resolve<ICustomerService>();
var shoppingCartService = IoC.Resolve<IShoppingCartService>();
var taxService = IoC.Resolve<ITaxService>();
var currencyService = IoC.Resolve<ICurrencyService>();
var shippingService= IoC.Resolve<IShippingService>();
var paymentService = IoC.Resolve<IPaymentService>();
var productService = IoC.Resolve<IProductService>();
var discountService = IoC.Resolve<IDiscountService>();
var localizationManager = IoC.Resolve<ILocalizationManager>();
var messageService = IoC.Resolve<IMessageService>();
var customerActivityService = IoC.Resolve<ICustomerActivityService>();
var smsService = IoC.Resolve<ISMSService>();
var logService = IoC.Resolve<ILogService>();
try
{
if (customer == null)
throw new ArgumentNullException("customer");
if (customer.IsGuest && !customerService.AnonymousCheckoutAllowed)
throw new NopException("Anonymous checkout is not allowed");
// This is a check to customer email address which is important to be valid.
if (!CommonHelper.IsValidEmail(customer.Email)) {
throw new NopException("Email is not valid");
}
if (paymentInfo == null)
throw new ArgumentNullException("paymentInfo");
Order initialOrder = null;
if (paymentInfo.IsRecurringPayment)
{
initialOrder = GetOrderById(paymentInfo.InitialOrderId);
if (initialOrder == null)
throw new NopException("Initial order could not be loaded");
}
if (!paymentInfo.IsRecurringPayment)
{
if (paymentInfo.BillingAddress == null)
throw new NopException("Billing address not provided");
// Billing address email is never asked in the first place, so system must not check its validity
//if (!CommonHelper.IsValidEmail(paymentInfo.BillingAddress.Email))
//{
// throw new NopException("Email is not valid");
//}
}
if (paymentInfo.IsRecurringPayment)
{
paymentInfo.PaymentMethodId = initialOrder.PaymentMethodId;
}
paymentInfo.CreditCardType = CommonHelper.EnsureNotNull(paymentInfo.CreditCardType);
paymentInfo.CreditCardName = CommonHelper.EnsureNotNull(paymentInfo.CreditCardName);
paymentInfo.CreditCardName = CommonHelper.EnsureMaximumLength(paymentInfo.CreditCardName, 100);
paymentInfo.CreditCardName = paymentInfo.CreditCardName.Trim();
paymentInfo.CreditCardNumber = CommonHelper.EnsureNotNull(paymentInfo.CreditCardNumber);
paymentInfo.CreditCardNumber = paymentInfo.CreditCardNumber.Trim();
paymentInfo.CreditCardCvv2 = CommonHelper.EnsureNotNull(paymentInfo.CreditCardCvv2);
paymentInfo.CreditCardCvv2 = paymentInfo.CreditCardCvv2.Trim();
paymentInfo.PaypalToken = CommonHelper.EnsureNotNull(paymentInfo.PaypalToken);
paymentInfo.PaypalPayerId = CommonHelper.EnsureNotNull(paymentInfo.PaypalPayerId);
paymentInfo.GoogleOrderNumber = CommonHelper.EnsureNotNull(paymentInfo.GoogleOrderNumber);
paymentInfo.PurchaseOrderNumber = CommonHelper.EnsureNotNull(paymentInfo.PurchaseOrderNumber);
ShoppingCart cart = null;
if (!paymentInfo.IsRecurringPayment)
{
cart = shoppingCartService.GetCustomerShoppingCart(customer.CustomerId, ShoppingCartTypeEnum.ShoppingCart);
//validate cart
var warnings = shoppingCartService.GetShoppingCartWarnings(cart, customer.CheckoutAttributes, true);
if (warnings.Count > 0)
{
StringBuilder warningsSb = new StringBuilder();
foreach (string warning in warnings)
{
warningsSb.Append(warning);
warningsSb.Append(";");
}
throw new NopException(warningsSb.ToString());
}
//.........这里部分代码省略.........
示例9: ProcessNextRecurringPayment
/// <summary>
/// Process next recurring psayment
/// </summary>
/// <param name="recurringPaymentId">Recurring payment identifier</param>
public void ProcessNextRecurringPayment(int recurringPaymentId)
{
try
{
var rp = GetRecurringPaymentById(recurringPaymentId);
if (rp == null)
throw new NopException("Recurring payment could not be loaded");
if (!rp.IsActive)
throw new NopException("Recurring payment is not active");
var initialOrder = rp.InitialOrder;
if (initialOrder == null)
throw new NopException("Initial order could not be loaded");
var customer = initialOrder.Customer;
if (customer == null)
throw new NopException("Customer could not be loaded");
var nextPaymentDate = rp.NextPaymentDate;
if (!nextPaymentDate.HasValue)
throw new NopException("Next payment date could not be calculated");
//payment info
var paymentInfo = new PaymentInfo();
paymentInfo.IsRecurringPayment = true;
paymentInfo.InitialOrderId = initialOrder.OrderId;
paymentInfo.RecurringCycleLength = rp.CycleLength;
paymentInfo.RecurringCyclePeriod = rp.CyclePeriod;
paymentInfo.RecurringTotalCycles = rp.TotalCycles;
//place new order
int newOrderId = 0;
string result = this.PlaceOrder(paymentInfo, customer,
Guid.NewGuid(), out newOrderId);
if (!String.IsNullOrEmpty(result))
{
throw new NopException(result);
}
else
{
var rph = new RecurringPaymentHistory()
{
RecurringPaymentId = rp.RecurringPaymentId,
OrderId = newOrderId,
CreatedOn = DateTime.UtcNow
};
InsertRecurringPaymentHistory(rph);
}
}
catch (Exception exc)
{
IoC.Resolve<ILogService>().InsertLog(LogTypeEnum.OrderError, string.Format("Error while processing recurring order. {0}", exc.Message), exc);
throw;
}
}
示例10: btnNextStep_Click
protected void btnNextStep_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
try
{
var paymentInfo = this.PaymentInfo;
if (paymentInfo == null)
{
var args1 = new CheckoutStepEventArgs() { OrderConfirmed = false };
OnCheckoutStepChanged(args1);
if (!this.OnePageCheckout)
{
Response.Redirect("~/checkoutpaymentinfo.aspx");
}
else
{
return;
}
}
paymentInfo.BillingAddress = NopContext.Current.User.BillingAddress;
paymentInfo.ShippingAddress = NopContext.Current.User.ShippingAddress;
paymentInfo.CustomerLanguage = NopContext.Current.WorkingLanguage;
paymentInfo.CustomerCurrency = NopContext.Current.WorkingCurrency;
int orderId = 0;
string result = OrderManager.PlaceOrder(paymentInfo, NopContext.Current.User, out orderId);
this.PaymentInfo = null;
var order = OrderManager.GetOrderById(orderId);
if (!String.IsNullOrEmpty(result))
{
lConfirmOrderError.Text = Server.HtmlEncode(result);
return;
}
else
{
PaymentManager.PostProcessPayment(order);
}
var args2 = new CheckoutStepEventArgs() { OrderConfirmed = true };
OnCheckoutStepChanged(args2);
if (!this.OnePageCheckout)
Response.Redirect("~/checkoutcompleted.aspx");
}
catch (Exception exc)
{
LogManager.InsertLog(LogTypeEnum.OrderError, exc.Message, exc);
lConfirmOrderError.Text = Server.HtmlEncode(exc.ToString());
}
}
}
示例11: ProcessPayment
/// <summary>
/// Process payment
/// </summary>
/// <param name="paymentInfo">Payment info required for an order processing</param>
/// <param name="customer">Customer</param>
/// <param name="orderGuid">Unique order identifier</param>
/// <param name="processPaymentResult">Process payment result</param>
public void ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid orderGuid, ref ProcessPaymentResult processPaymentResult)
{
InitSettings();
TransactMode transactionMode = GetCurrentTransactionMode();
WebClient webClient = new WebClient();
NameValueCollection form = new NameValueCollection();
form.Add("x_login", loginID);
form.Add("x_tran_key", transactionKey);
if (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", APIVersion);
form.Add("x_relay_response", "FALSE");
form.Add("x_method", "CC");
form.Add("x_currency_code", IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency.CurrencyCode);
if (transactionMode == TransactMode.Authorize)
form.Add("x_type", "AUTH_ONLY");
else if (transactionMode == TransactMode.AuthorizeAndCapture)
form.Add("x_type", "AUTH_CAPTURE");
else
throw new NopException("Not supported transaction mode");
form.Add("x_amount", paymentInfo.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture));
form.Add("x_card_num", paymentInfo.CreditCardNumber);
form.Add("x_exp_date", paymentInfo.CreditCardExpireMonth.ToString("D2") + paymentInfo.CreditCardExpireYear.ToString());
form.Add("x_card_code", paymentInfo.CreditCardCvv2);
form.Add("x_first_name", paymentInfo.BillingAddress.FirstName);
form.Add("x_last_name", paymentInfo.BillingAddress.LastName);
if (string.IsNullOrEmpty(paymentInfo.BillingAddress.Company))
form.Add("x_company", paymentInfo.BillingAddress.Company);
form.Add("x_address", paymentInfo.BillingAddress.Address1);
form.Add("x_city", paymentInfo.BillingAddress.City);
if (paymentInfo.BillingAddress.StateProvince != null)
form.Add("x_state", paymentInfo.BillingAddress.StateProvince.Abbreviation);
form.Add("x_zip", paymentInfo.BillingAddress.ZipPostalCode);
if (paymentInfo.BillingAddress.Country != null)
form.Add("x_country", paymentInfo.BillingAddress.Country.TwoLetterIsoCode);
//20 chars maximum
form.Add("x_invoice_num", orderGuid.ToString().Substring(0,20));
form.Add("x_customer_ip",NopContext.Current.UserHostAddress);
string reply = null;
Byte[] responseData = webClient.UploadValues(GetAuthorizeNETUrl(), form);
reply = Encoding.ASCII.GetString(responseData);
if (!String.IsNullOrEmpty(reply))
{
string[] responseFields = reply.Split('|');
switch (responseFields[0])
{
case "1":
processPaymentResult.AuthorizationTransactionCode = string.Format("{0},{1}", responseFields[6], responseFields[4]);
processPaymentResult.AuthorizationTransactionResult = string.Format("Approved ({0}: {1})", responseFields[2], responseFields[3]);
processPaymentResult.AVSResult = responseFields[5];
//responseFields[38];
if (transactionMode == TransactMode.Authorize)
{
processPaymentResult.PaymentStatus = PaymentStatusEnum.Authorized;
}
else
{
processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
}
break;
case "2":
processPaymentResult.Error = string.Format("Declined ({0}: {1})", responseFields[2], responseFields[3]);
processPaymentResult.FullError = string.Format("Declined ({0}: {1})", responseFields[2], responseFields[3]);
break;
case "3":
processPaymentResult.Error = string.Format("Error: {0}", reply);
processPaymentResult.FullError = string.Format("Error: {0}", reply);
break;
}
}
else
{
processPaymentResult.Error = "Authorize.NET unknown error";
processPaymentResult.FullError = "Authorize.NET unknown error";
}
}
示例12: DoExpressCheckout
/// <summary>
/// Do paypal express checkout
/// </summary>
/// <param name="paymentInfo">Payment info required for an order processing</param>
/// <param name="orderGuid">Unique order identifier</param>
/// <param name="processPaymentResult">Process payment result</param>
public void DoExpressCheckout(PaymentInfo paymentInfo,
Guid orderGuid, ProcessPaymentResult processPaymentResult)
{
InitSettings();
TransactMode transactionMode = GetCurrentTransactionMode();
DoExpressCheckoutPaymentReq req = new DoExpressCheckoutPaymentReq();
DoExpressCheckoutPaymentRequestType request = new DoExpressCheckoutPaymentRequestType();
req.DoExpressCheckoutPaymentRequest = request;
request.Version = this.APIVersion;
DoExpressCheckoutPaymentRequestDetailsType details = new DoExpressCheckoutPaymentRequestDetailsType();
request.DoExpressCheckoutPaymentRequestDetails = details;
if (transactionMode == TransactMode.Authorize)
details.PaymentAction = PaymentActionCodeType.Authorization;
else
details.PaymentAction = PaymentActionCodeType.Sale;
details.PaymentActionSpecified = true;
details.Token = paymentInfo.PaypalToken;
details.PayerID = paymentInfo.PaypalPayerId;
details.PaymentDetails = new PaymentDetailsType[1];
PaymentDetailsType paymentDetails1 = new PaymentDetailsType();
details.PaymentDetails[0] = paymentDetails1;
paymentDetails1.OrderTotal = new BasicAmountType();
paymentDetails1.OrderTotal.Value = paymentInfo.OrderTotal.ToString("N", new CultureInfo("en-us"));
paymentDetails1.OrderTotal.currencyID = PaypalHelper.GetPaypalCurrency(IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency);
paymentDetails1.Custom = orderGuid.ToString();
paymentDetails1.ButtonSource = "nopCommerceCart";
DoExpressCheckoutPaymentResponseType response = service2.DoExpressCheckoutPayment(req);
string error;
if (!PaypalHelper.CheckSuccess(response, out error))
throw new NopException(error);
if (response.DoExpressCheckoutPaymentResponseDetails.PaymentInfo != null &&
response.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0] != null)
{
processPaymentResult.AuthorizationTransactionId = response.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].TransactionID;
processPaymentResult.AuthorizationTransactionResult = response.Ack.ToString();
if (transactionMode == TransactMode.Authorize)
processPaymentResult.PaymentStatus = PaymentStatusEnum.Authorized;
else
processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
}
else
{
throw new NopException("response.DoExpressCheckoutPaymentResponseDetails.PaymentInfo is null");
}
}
示例13: ProcessPayment
/// <summary>
/// Process payment
/// </summary>
/// <param name="paymentInfo">Payment info required for an order processing</param>
/// <param name="customer">Customer</param>
/// <param name="orderGuid">Unique order identifier</param>
/// <param name="processPaymentResult">Process payment result</param>
public void ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid orderGuid, ref ProcessPaymentResult processPaymentResult)
{
InitSettings();
GatewayConnector eWAYgateway = new GatewayConnector();
GatewayRequest eWAYRequest = new GatewayRequest();
if (useSandBox)
eWAYRequest.EwayCustomerID = ewayTestCustomerID;
else
eWAYRequest.EwayCustomerID = ewayLiveCustomerID;
eWAYRequest.CardNumber = paymentInfo.CreditCardNumber;
eWAYRequest.CardExpiryMonth = paymentInfo.CreditCardExpireMonth.ToString("D2");
eWAYRequest.CardExpiryYear = paymentInfo.CreditCardExpireYear.ToString();
eWAYRequest.CardHolderName = paymentInfo.CreditCardName;
//Integer
eWAYRequest.InvoiceAmount = Convert.ToInt32(paymentInfo.OrderTotal * 100);
eWAYRequest.PurchaserFirstName = paymentInfo.BillingAddress.FirstName;
eWAYRequest.PurchaserLastName = paymentInfo.BillingAddress.LastName;
eWAYRequest.PurchaserEmailAddress = paymentInfo.BillingAddress.Email;
eWAYRequest.PurchaserAddress = paymentInfo.BillingAddress.Address1;
eWAYRequest.PurchaserPostalCode = paymentInfo.BillingAddress.ZipPostalCode;
eWAYRequest.InvoiceReference = orderGuid.ToString();
eWAYRequest.InvoiceDescription = SettingManager.GetSettingValue("Common.StoreName") + ". Order #" + orderGuid.ToString();
eWAYRequest.TransactionNumber = orderGuid.ToString();
eWAYRequest.CVN = paymentInfo.CreditCardCvv2;
eWAYRequest.EwayOption1 = string.Empty;
eWAYRequest.EwayOption2 = string.Empty;
eWAYRequest.EwayOption3 = string.Empty;
// Do the payment, send XML doc containing information gathered
eWAYgateway.Uri = GeteWayUrl();
GatewayResponse eWAYResponse = eWAYgateway.ProcessRequest(eWAYRequest);
if (eWAYResponse != null)
{
// Payment succeeded get values returned
if (eWAYResponse.Status && (eWAYResponse.Error.StartsWith(APPROVED_RESPONSE) || eWAYResponse.Error.StartsWith(HONOUR_RESPONSE)))
{
processPaymentResult.AuthorizationTransactionCode = eWAYResponse.AuthorisationCode;
processPaymentResult.AuthorizationTransactionResult = eWAYResponse.InvoiceReference;
processPaymentResult.AuthorizationTransactionId = eWAYResponse.TransactionNumber;
processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
//processPaymentResult.AuthorizationDate = DateTime.UtcNow;
}
else
{
processPaymentResult.Error = "An invalid response was recieved from the payment gateway." + eWAYResponse.Error;
processPaymentResult.FullError = "An invalid response was recieved from the payment gateway." + eWAYRequest.ToXml().ToString() + ". " + eWAYResponse.Error;
}
}
else
{
// invalid response recieved from server.
processPaymentResult.Error = "An invalid response was recieved from the payment gateway.";
processPaymentResult.FullError = "An invalid response was recieved from the payment gateway." + eWAYRequest.ToXml().ToString();
}
}
示例14: ProcessRecurringPayment
/// <summary>
/// Process recurring payment
/// </summary>
/// <param name="paymentInfo">Payment info required for an order processing</param>
/// <param name="customer">Customer</param>
/// <param name="orderGuid">Unique order identifier</param>
/// <param name="processPaymentResult">Process payment result</param>
public void ProcessRecurringPayment(PaymentInfo paymentInfo, Customer customer, Guid orderGuid, ref ProcessPaymentResult processPaymentResult)
{
throw new NotImplementedException();
}
示例15: ProcessPayment
/// <summary>
/// Process payment
/// </summary>
/// <param name="paymentInfo">Payment info required for an order processing</param>
/// <param name="customer">Customer</param>
/// <param name="orderGuid">Unique order identifier</param>
/// <param name="processPaymentResult">Process payment result</param>
public void ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid orderGuid, ref ProcessPaymentResult processPaymentResult)
{
InitSettings();
TransactMode transactionMode = GetCurrentTransactionMode();
string transactionModeStr = string.Empty;
if (transactionMode == TransactMode.Authorize)
transactionModeStr = "AUTHORIZATION";
else if (transactionMode == TransactMode.AuthorizeAndCapture)
transactionModeStr = "AUTHORIZATION_CAPTURE";
else
throw new NopException("Not supported transaction mode");
// This is the standard information that is needed to connect to PayJunction
string server = GetUrl();
int port = 443;
SslStream stream = null;
// Encode Data Values
string encodedPJLogin = Encode("dc_logon", pjlogon);
string encodedPJPassword = Encode("dc_password", pjpassword);
string encodedFirstname = Encode("dc_first_name", paymentInfo.BillingAddress.FirstName);
string encodedLastname = Encode("dc_last_name", paymentInfo.BillingAddress.LastName);
string encodedCCNumber = Encode("dc_number", paymentInfo.CreditCardNumber);
string encodedExpMonth = Encode("dc_expiration_month", paymentInfo.CreditCardExpireMonth.ToString("D2"));
string encodedExpYear = Encode("dc_expiration_year", paymentInfo.CreditCardExpireYear.ToString().Substring(2, 2));
string encodedCVVCode = Encode("dc_verification_number", paymentInfo.CreditCardCvv2);
string encodedAddress = Encode("dc_address", paymentInfo.BillingAddress.Address1);
string encodedCity = Encode("dc_city", paymentInfo.BillingAddress.City);
string encodedZipCode = Encode("dc_zipcode", paymentInfo.BillingAddress.ZipPostalCode);
string encodedTransType = Encode("dc_transaction_type", transactionModeStr);
string encodedAmount = Encode("dc_transaction_amount", paymentInfo.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture));
string encodedVersion = Encode("dc_version", "1.2");
// Concatenate Encoded Transaction String
string transactioninfo = "POST /quick_link?" + encodedPJLogin + "&" + encodedPJPassword + "&" + encodedFirstname + "&" + encodedLastname + "&" + encodedCCNumber + "&" + encodedExpMonth + "&" + encodedExpYear + "&" + encodedCCNumber + "&" + encodedAddress + "&" + encodedCity + "&" + encodedZipCode + "&" + encodedTransType + "&" + encodedAmount + "&" + encodedVersion + " \r\n\r\n";
try
{
// Instantiate a TcpClient with the server and port
TcpClient client = new TcpClient(server, port);
// Convert the data to send into a byte array
Byte[] data = System.Text.Encoding.ASCII.GetBytes(transactioninfo);
// Specify the callback function that will act as the validation delegate.
RemoteCertificateValidationCallback callback = new
// This lets you inspect the certificate to see if it meets your validation requirements.
RemoteCertificateValidationCallback(OnCertificateValidation);
// Instantiate an SslStream with the NetworkStream returned from the TcpClient.
stream = new SslStream(client.GetStream(), false, callback);
// As a client, you can authenticate the server and validate the results using the SslStream.
// This is the host name of the server you are connecting to, which may or may not be the name used to connect to the server when TcpClient is instantiated.
stream.AuthenticateAsClient(server);
// Send the message to the server.
stream.Write(data, 0, data.Length);
// Buffer to hold data returned from the server.
data = new Byte[2048];
// Read the response from the server up to the size of the buffer.
int bytes = stream.Read(data, 0, data.Length);
Console.WriteLine(bytes);
// Convert the received bytes into a string
string responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
// Create an Array "keyValue" that contains the response
string[] keyValue = responseData.Split(Convert.ToChar(28));
Dictionary<string, string> keyValueDic = new Dictionary<string, string>();
foreach (string key in keyValue)
{
string str1 = key.Split(new char[] { '=' })[0];
string str2 = key.Split(new char[] { '=' })[1];
keyValueDic.Add(str1, str2);
}
string dc_response_code = string.Empty;
if (keyValueDic.ContainsKey("dc_response_code"))
{
dc_response_code = keyValueDic["dc_response_code"];
}
string dc_response_message = string.Empty;
if (keyValueDic.ContainsKey("dc_response_message"))
{
dc_response_message = keyValueDic["dc_response_message"];
}
if (dc_response_code == "00" || dc_response_code == "85")
{
string dc_transaction_id = string.Empty;
if (keyValueDic.ContainsKey("dc_transaction_id"))
{
dc_transaction_id = keyValueDic["dc_transaction_id"];
}
if (transactionMode == TransactMode.Authorize)
{
processPaymentResult.PaymentStatus = PaymentStatusEnum.Authorized;
processPaymentResult.AuthorizationTransactionId = dc_transaction_id;
//.........这里部分代码省略.........