/// <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) { TransactMode transactionMode = GetCurrentTransactionMode(); if (paymentInfo.BillingAddress.StateProvince == null) { throw new NopException("Please enter a valid state in the billing address"); } if (transactionMode == TransactMode.Authorize) { AuthorizeOrSale(paymentInfo, customer, OrderGuid, processPaymentResult, true); if (!String.IsNullOrEmpty(processPaymentResult.Error)) { return; } } else { AuthorizeOrSale(paymentInfo, customer, OrderGuid, processPaymentResult, false); if (!String.IsNullOrEmpty(processPaymentResult.Error)) { return; } } }
private void BindData() { TransactMode transactionModeEnum = GetCurrentTransactionMode(); switch (transactionModeEnum) { case TransactMode.Authorize: rbAuthorize.Checked = true; break; case TransactMode.AuthorizeAndCapture: rbAuthorizeAndCapture.Checked = true; break; default: break; } cbUseSandbox.Checked = SettingManager.GetSettingValueBoolean("PaymentMethod.PayFlowPro.UseSandbox"); txtUser.Text = SettingManager.GetSettingValue("PaymentMethod.PayFlowPro.User"); txtVendor.Text = SettingManager.GetSettingValue("PaymentMethod.PayFlowPro.Vendor"); txtPartner.Text = SettingManager.GetSettingValue("PaymentMethod.PayFlowPro.Partner"); txtPassword.Text = SettingManager.GetSettingValue("PaymentMethod.PayFlowPro.Password"); txtAdditionalFee.Value = SettingManager.GetSettingValueDecimalNative("PaymentMethod.PayFlowPro.AdditionalFee"); }
private void BindData() { TransactMode transactionModeEnum = GetCurrentTransactionMode(); switch (transactionModeEnum) { case TransactMode.Authorize: rbAuthorize.Checked = true; break; case TransactMode.AuthorizeAndCapture: rbAuthorizeAndCapture.Checked = true; break; default: break; } cbUseSandbox.Checked = this.SettingManager.GetSettingValueBoolean("PaymentMethod.PaypalDirect.UseSandbox"); txtAPIAccountName.Text = this.SettingManager.GetSettingValue("PaymentMethod.PaypalDirect.APIAccountName"); txtAPIAccountPassword.Text = this.SettingManager.GetSettingValue("PaymentMethod.PaypalDirect.APIAccountPassword"); txtSignature.Text = this.SettingManager.GetSettingValue("PaymentMethod.PaypalDirect.Signature"); txtAdditionalFee.Value = this.SettingManager.GetSettingValueDecimalNative("PaymentMethod.PaypalDirect.AdditionalFee"); }
/// <summary> /// Sets paypal express checkout /// </summary> /// <param name="OrderTotal">Order total</param> /// <param name="ReturnURL">Return URL</param> /// <param name="CancelURL">Cancel URL</param> /// <returns>Express checkout URL</returns> public string SetExpressCheckout(decimal OrderTotal, string ReturnURL, string CancelURL) { InitSettings(); TransactMode transactionMode = GetCurrentTransactionMode(); SetExpressCheckoutReq req = new SetExpressCheckoutReq(); req.SetExpressCheckoutRequest = new SetExpressCheckoutRequestType(); req.SetExpressCheckoutRequest.Version = this.APIVersion; SetExpressCheckoutRequestDetailsType details = new SetExpressCheckoutRequestDetailsType(); req.SetExpressCheckoutRequest.SetExpressCheckoutRequestDetails = details; if (transactionMode == TransactMode.Authorize) { details.PaymentAction = PaymentActionCodeType.Authorization; } else { details.PaymentAction = PaymentActionCodeType.Sale; } details.PaymentActionSpecified = true; details.OrderTotal = new BasicAmountType(); details.OrderTotal.Value = OrderTotal.ToString("N", new CultureInfo("en-us")); details.OrderTotal.currencyID = PaypalHelper.GetPaypalCurrency(CurrencyManager.PrimaryStoreCurrency); details.ReturnURL = ReturnURL; details.CancelURL = CancelURL; SetExpressCheckoutResponseType response = service2.SetExpressCheckout(req); string error; if (PaypalHelper.CheckSuccess(response, out error)) { return(GetPaypalUrl(response.Token)); } throw new NopException(error); }
private SelectList TransactModeValues(TransactMode selected) { return(new SelectList(new List <object>() { new { ID = (int)TransactMode.Authorize, Name = _helper.GetResource("ModeAuth") }, new { ID = (int)TransactMode.AuthorizeAndCapture, Name = _helper.GetResource("ModeAuthAndCapture") } }, "ID", "Name", (int)selected)); }
private SelectList TransactModeValues(TransactMode selected) { return new SelectList(new List<object>() { new { ID = (int)TransactMode.Authorize, Name = _helper.GetResource("ModeAuth") }, new { ID = (int)TransactMode.AuthorizeAndCapture, Name = _helper.GetResource("ModeAuthAndCapture") } }, "ID", "Name", (int)selected); }
private SelectList TransactModeValues(TransactMode selected) { return new SelectList(new List<object> { new { ID = (int)TransactMode.Authorize, Name = T("Plugins.Payments.PayPalDirect.ModeAuth") }, new { ID = (int)TransactMode.AuthorizeAndCapture, Name = T("Plugins.Payments.PayPalDirect.ModeAuthAndCapture") } }, "ID", "Name", (int)selected); }
/// <summary> /// Gets current transaction mode /// </summary> /// <returns>Current transaction mode</returns> public static TransactMode GetCurrentTransactionMode() { TransactMode transactionModeEnum = TransactMode.Authorize; string transactionMode = IoC.Resolve <ISettingManager>().GetSettingValue("PaymentMethod.AuthorizeNET.TransactionMode"); if (!String.IsNullOrEmpty(transactionMode)) { transactionModeEnum = (TransactMode)Enum.Parse(typeof(TransactMode), transactionMode); } return(transactionModeEnum); }
/// <summary> /// Gets transaction mode configured by store owner /// </summary> /// <returns></returns> private TransactMode GetCurrentTransactionMode() { TransactMode transactionModeEnum = TransactMode.Authorize; string transactionMode = SettingManager.GetSettingValue("PaymentMethod.PayFlowPro.TransactionMode"); if (!String.IsNullOrEmpty(transactionMode)) { transactionModeEnum = (TransactMode)Enum.Parse(typeof(TransactMode), transactionMode); } return(transactionModeEnum); }
/// <summary> /// Gets current transaction mode /// </summary> /// <returns>Current transaction mode</returns> public static TransactMode GetCurrentTransactionMode() { TransactMode transactionModeEnum = TransactMode.Authorize; string transactionMode = SettingManager.GetSettingValue("PaymentMethod.eProcessingNetwork.TransactionMode"); if (!String.IsNullOrEmpty(transactionMode)) { transactionModeEnum = (TransactMode)Enum.Parse(typeof(TransactMode), transactionMode); } return(transactionModeEnum); }
/// <summary> /// Do paypal express checkout /// </summary> /// <param name="Token">Paypal express checkout token</param> /// <param name="PayerID">Paypal payer identifier</param> /// <param name="OrderTotal">Order total</param> /// <param name="processPaymentResult">Process payment result</param> public void DoExpressCheckout(string Token, string PayerID, decimal OrderTotal, 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; PaymentDetailsType paymentDetails = new PaymentDetailsType(); details.PaymentDetails = paymentDetails; if (transactionMode == TransactMode.Authorize) { details.PaymentAction = PaymentActionCodeType.Authorization; } else { details.PaymentAction = PaymentActionCodeType.Sale; } details.Token = Token; details.PayerID = PayerID; paymentDetails.OrderTotal = new BasicAmountType(); paymentDetails.OrderTotal.Value = OrderTotal.ToString("N", new CultureInfo("en-us")); paymentDetails.OrderTotal.currencyID = PaypalHelper.GetPaypalCurrency(CurrencyManager.PrimaryStoreCurrency); paymentDetails.ButtonSource = "nopCommerceCart"; DoExpressCheckoutPaymentResponseType response = service2.DoExpressCheckoutPayment(req); string error; if (!PaypalHelper.CheckSuccess(response, out error)) { throw new NopException(error); } processPaymentResult.AuthorizationTransactionID = response.DoExpressCheckoutPaymentResponseDetails.PaymentInfo.TransactionID; processPaymentResult.AuthorizationTransactionResult = response.Ack.ToString(); //processPaymentResult.AuthorizationDate = response.Timestamp; //processPaymentResult.AuthorizationDate = DateTime.Now; if (transactionMode == TransactMode.Authorize) { processPaymentResult.PaymentStatus = PaymentStatusEnum.Authorized; } else { processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid; } }
public TransactMode GetCurrentTransactionMode() { TransactMode transactionModeEnum = TransactMode.Authorize; string transactionMode = this.SettingManager.GetSettingValue("PaymentMethod.PaypalDirect.TransactionMode"); if (!String.IsNullOrEmpty(transactionMode)) { transactionModeEnum = (TransactMode)Enum.Parse(typeof(TransactMode), transactionMode); } return(transactionModeEnum); }
public void Save() { TransactMode transactionMode = TransactMode.Authorize; if (rbAuthorize.Checked) { transactionMode = TransactMode.Authorize; } if (rbAuthorizeAndCapture.Checked) { transactionMode = TransactMode.AuthorizeAndCapture; } SetTransactionMode(transactionMode); SettingManager.SetParam("PaymentMethod.USAePayIntegrated.SourceKey", txtSourceKey.Text); SettingManager.SetParam("PaymenthMethod.USAePayIntegrated.Pin", txtPin.Text); SettingManager.SetParamNative("PaymentMethod.USAePayIntegrated.AdditionalFee", txtAdditionalFee.Value); }
public void Save() { TransactMode transactionMode = TransactMode.Authorize; if (rbPending.Checked) { transactionMode = TransactMode.Pending; } if (rbAuthorize.Checked) { transactionMode = TransactMode.Authorize; } if (rbAuthorizeAndCapture.Checked) { transactionMode = TransactMode.AuthorizeAndCapture; } SetTransactionMode(transactionMode); }
public void Save() { TransactMode transactionMode = TransactMode.Authorize; if (rbAuthorize.Checked) { transactionMode = TransactMode.Authorize; } if (rbAuthorizeAndCapture.Checked) { transactionMode = TransactMode.AuthorizeAndCapture; } SetTransactionMode(transactionMode); SettingManager.SetParam("PaymentMethod.AuthorizeNET.UseSandbox", cbUseSandbox.Checked.ToString()); SettingManager.SetParam("PaymentMethod.AuthorizeNET.TransactionKey", txtTransactionKey.Text); SettingManager.SetParam("PaymentMethod.AuthorizeNET.LoginID", txtLoginID.Text); }
/// <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) { processPaymentResult.AllowStoringCreditCardNumber = true; TransactMode transactionMode = GetCurrentTransactionMode(); switch (transactionMode) { case TransactMode.Pending: processPaymentResult.PaymentStatus = PaymentStatusEnum.Pending; break; case TransactMode.Authorize: processPaymentResult.PaymentStatus = PaymentStatusEnum.Authorized; break; case TransactMode.AuthorizeAndCapture: processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid; break; default: throw new NopException("Not supported transact type"); } //restore credit cart info if (paymentInfo.IsRecurringPayment) { Order initialOrder = IoC.Resolve <IOrderService>().GetOrderById(paymentInfo.InitialOrderId); if (initialOrder != null) { paymentInfo.CreditCardType = processPaymentResult.AllowStoringCreditCardNumber ? SecurityHelper.Decrypt(initialOrder.CardType) : string.Empty; paymentInfo.CreditCardName = processPaymentResult.AllowStoringCreditCardNumber ? SecurityHelper.Decrypt(initialOrder.CardName) : string.Empty; paymentInfo.CreditCardNumber = processPaymentResult.AllowStoringCreditCardNumber ? SecurityHelper.Decrypt(initialOrder.CardNumber) : string.Empty; paymentInfo.CreditCardCvv2 = processPaymentResult.AllowStoringCreditCardNumber ? SecurityHelper.Decrypt(initialOrder.CardCvv2) : string.Empty; try { paymentInfo.CreditCardExpireMonth = Convert.ToInt32(processPaymentResult.AllowStoringCreditCardNumber ? SecurityHelper.Decrypt(initialOrder.CardExpirationMonth) : "0"); paymentInfo.CreditCardExpireYear = Convert.ToInt32(processPaymentResult.AllowStoringCreditCardNumber ? SecurityHelper.Decrypt(initialOrder.CardExpirationYear) : "0"); } catch { } } } }
public void Save() { TransactMode transactionMode = TransactMode.Authorize; if (rbAuthorize.Checked) { transactionMode = TransactMode.Authorize; } if (rbAuthorizeAndCapture.Checked) { transactionMode = TransactMode.AuthorizeAndCapture; } SetTransactionMode(transactionMode); this.SettingManager.SetParam("PaymentMethod.PayJunction.UseSandbox", cbUseSandbox.Checked.ToString()); this.SettingManager.SetParam("PaymentMethod.PayJunction.pjlogon", txtUsername.Text); this.SettingManager.SetParam("PaymentMethod.PayJunction.pjpassword", txtPassword.Text); this.SettingManager.SetParamNative("PaymentMethod.PayJunction.AdditionalFee", txtAdditionalFee.Value); }
public void Save() { TransactMode transactionMode = TransactMode.Authorize; if (rbAuthorize.Checked) { transactionMode = TransactMode.Authorize; } if (rbAuthorizeAndCapture.Checked) { transactionMode = TransactMode.AuthorizeAndCapture; } SetTransactionMode(transactionMode); SettingManager.SetParam("PaymentMethod.PaypalExpress.UseSandbox", cbUseSandbox.Checked.ToString()); SettingManager.SetParam("PaymentMethod.PaypalExpress.APIAccountName", txtAPIAccountName.Text); SettingManager.SetParam("PaymentMethod.PaypalExpress.APIAccountPassword", txtAPIAccountPassword.Text); SettingManager.SetParam("PaymentMethod.PaypalExpress.Signature", txtSignature.Text); }
public void Save() { TransactMode transactionMode = TransactMode.Authorize; if (rbPending.Checked) { transactionMode = TransactMode.Pending; } if (rbAuthorize.Checked) { transactionMode = TransactMode.Authorize; } if (rbAuthorizeAndCapture.Checked) { transactionMode = TransactMode.AuthorizeAndCapture; } SetTransactionMode(transactionMode); SettingManager.SetParamNative("PaymentMethod.Manual.AdditionalFee", txtAdditionalFee.Value); }
public void Save() { TransactMode transactionMode = TransactMode.Authorize; if (rbAuthorize.Checked) { transactionMode = TransactMode.Authorize; } if (rbAuthorizeAndCapture.Checked) { transactionMode = TransactMode.AuthorizeAndCapture; } SetTransactionMode(transactionMode); SettingManager.SetParam("PaymentMethod.eProcessingNetwork.UseSandbox", cbUseSandbox.Checked.ToString()); SettingManager.SetParam("PaymentMethod.eProcessingNetwork.TransactionKey", txtTransactionKey.Text); SettingManager.SetParam("PaymentMethod.eProcessingNetwork.LoginId", txtLoginId.Text); SettingManager.SetParamNative("PaymentMethod.eProcessingNetwork.AdditionalFee", txtAdditionalFee.Value); }
public void Save() { TransactMode transactionMode = TransactMode.Authorize; if (rbAuthorize.Checked) { transactionMode = TransactMode.Authorize; } if (rbAuthorizeAndCapture.Checked) { transactionMode = TransactMode.AuthorizeAndCapture; } SetTransactionMode(transactionMode); SettingManager.SetParam("PaymentMethod.PayFlowPro.UseSandbox", cbUseSandbox.Checked.ToString()); SettingManager.SetParam("PaymentMethod.PayFlowPro.User", txtUser.Text); SettingManager.SetParam("PaymentMethod.PayFlowPro.Vendor", txtVendor.Text); SettingManager.SetParam("PaymentMethod.PayFlowPro.Partner", txtPartner.Text); SettingManager.SetParam("PaymentMethod.PayFlowPro.Password", txtPassword.Text); }
public void Save() { TransactMode transactionMode = TransactMode.Authorize; if (rbAuthorize.Checked) { transactionMode = TransactMode.Authorize; } if (rbAuthorizeAndCapture.Checked) { transactionMode = TransactMode.AuthorizeAndCapture; } SetTransactionMode(transactionMode); this.SettingManager.SetParam("PaymentMethod.PaypalDirect.UseSandbox", cbUseSandbox.Checked.ToString()); this.SettingManager.SetParam("PaymentMethod.PaypalDirect.APIAccountName", txtAPIAccountName.Text); this.SettingManager.SetParam("PaymentMethod.PaypalDirect.APIAccountPassword", txtAPIAccountPassword.Text); this.SettingManager.SetParam("PaymentMethod.PaypalDirect.Signature", txtSignature.Text); this.SettingManager.SetParamNative("PaymentMethod.PaypalDirect.AdditionalFee", txtAdditionalFee.Value); }
/// <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) { TransactMode transactionMode = GetCurrentTransactionMode(); if (transactionMode == TransactMode.Authorize) { AuthorizeOrSale(paymentInfo, customer, orderGuid, processPaymentResult, true); if (!String.IsNullOrEmpty(processPaymentResult.Error)) { return; } } else { AuthorizeOrSale(paymentInfo, customer, orderGuid, processPaymentResult, false); if (!String.IsNullOrEmpty(processPaymentResult.Error)) { return; } } }
private void BindData() { TransactMode transactionModeEnum = GetCurrentTransactionMode(); switch (transactionModeEnum) { case TransactMode.Pending: rbPending.Checked = true; break; case TransactMode.Authorize: rbAuthorize.Checked = true; break; case TransactMode.AuthorizeAndCapture: rbAuthorizeAndCapture.Checked = true; break; default: break; } }
private void BindData() { TransactMode transactionModeEnum = GetCurrentTransactionMode(); switch (transactionModeEnum) { case TransactMode.Authorize: rbAuthorize.Checked = true; break; case TransactMode.AuthorizeAndCapture: rbAuthorizeAndCapture.Checked = true; break; default: break; } cbUseSandbox.Checked = SettingManager.GetSettingValueBoolean("PaymentMethod.AuthorizeNET.UseSandbox"); txtTransactionKey.Text = SettingManager.GetSettingValue("PaymentMethod.AuthorizeNET.TransactionKey"); txtLoginID.Text = SettingManager.GetSettingValue("PaymentMethod.AuthorizeNET.LoginID"); }
private void BindData() { TransactMode transactionModeEnum = GetCurrentTransactionMode(); switch (transactionModeEnum) { case TransactMode.Authorize: rbAuthorize.Checked = true; break; case TransactMode.AuthorizeAndCapture: rbAuthorizeAndCapture.Checked = true; break; default: break; } txtSourceKey.Text = SettingManager.GetSettingValue("PaymentMethod.USAePayIntegrated.SourceKey"); txtPin.Text = SettingManager.GetSettingValue("PaymenthMethod.USAePayIntegrated.Pin"); txtAdditionalFee.Value = SettingManager.GetSettingValueDecimalNative("PaymentMethod.USAePayIntegrated.AdditionalFee"); }
/// <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) { processPaymentResult.AllowStoringCreditCardNumber = true; TransactMode transactionMode = GetCurrentTransactionMode(); switch (transactionMode) { case TransactMode.Pending: processPaymentResult.PaymentStatus = PaymentStatusEnum.Pending; break; case TransactMode.Authorize: processPaymentResult.PaymentStatus = PaymentStatusEnum.Authorized; break; case TransactMode.AuthorizeAndCapture: processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid; break; default: throw new NopException("Not supported transact type"); } }
private void BindData() { TransactMode transactionModeEnum = GetCurrentTransactionMode(); switch (transactionModeEnum) { case TransactMode.Pending: rbPending.Checked = true; break; case TransactMode.Authorize: rbAuthorize.Checked = true; break; case TransactMode.AuthorizeAndCapture: rbAuthorizeAndCapture.Checked = true; break; default: break; } txtAdditionalFee.Value = SettingManager.GetSettingValueDecimalNative("PaymentMethod.Manual.AdditionalFee"); }
private void BindData() { TransactMode transactionModeEnum = GetCurrentTransactionMode(); switch (transactionModeEnum) { case TransactMode.Authorize: rbAuthorize.Checked = true; break; case TransactMode.AuthorizeAndCapture: rbAuthorizeAndCapture.Checked = true; break; default: break; } cbUseSandbox.Checked = SettingManager.GetSettingValueBoolean("PaymentMethod.eProcessingNetwork.UseSandbox"); txtTransactionKey.Text = SettingManager.GetSettingValue("PaymentMethod.eProcessingNetwork.TransactionKey"); txtLoginId.Text = SettingManager.GetSettingValue("PaymentMethod.eProcessingNetwork.LoginId"); txtAdditionalFee.Value = SettingManager.GetSettingValueDecimalNative("PaymentMethod.eProcessingNetwork.AdditionalFee"); }
/// <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"; } }
public static void SetTransactionMode(TransactMode transactionMode) { SettingManager.SetParam("PaymentMethod.AuthorizeNET.TransactionMode", transactionMode.ToString()); }
/// <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(); //little hack here CultureInfo userCulture = Thread.CurrentThread.CurrentCulture; NopContext.Current.SetCulture(new CultureInfo("en-US")); try { Invoice invoice = new Invoice(); BillTo to = new BillTo(); to.FirstName = paymentInfo.BillingAddress.FirstName; to.LastName = paymentInfo.BillingAddress.LastName; to.Street = paymentInfo.BillingAddress.Address1; to.City = paymentInfo.BillingAddress.City; to.Zip = paymentInfo.BillingAddress.ZipPostalCode; if (paymentInfo.BillingAddress.StateProvince != null) { to.State = paymentInfo.BillingAddress.StateProvince.Abbreviation; } invoice.BillTo = to; if (paymentInfo.ShippingAddress != null) { ShipTo to2 = new ShipTo(); to2.ShipToFirstName = paymentInfo.ShippingAddress.FirstName; to2.ShipToLastName = paymentInfo.ShippingAddress.LastName; to2.ShipToStreet = paymentInfo.ShippingAddress.Address1; to2.ShipToCity = paymentInfo.ShippingAddress.City; to2.ShipToZip = paymentInfo.ShippingAddress.ZipPostalCode; if (paymentInfo.ShippingAddress.StateProvince != null) { to2.ShipToState = paymentInfo.ShippingAddress.StateProvince.Abbreviation; } invoice.ShipTo = to2; } invoice.InvNum = orderGuid.ToString(); decimal orderTotal = Math.Round(paymentInfo.OrderTotal, 2); invoice.Amt = new PayPal.Payments.DataObjects.Currency(orderTotal, CurrencyManager.PrimaryStoreCurrency.CurrencyCode); string creditCardExp = string.Empty; if (paymentInfo.CreditCardExpireMonth < 10) { creditCardExp = "0" + paymentInfo.CreditCardExpireMonth.ToString(); } else { creditCardExp = paymentInfo.CreditCardExpireMonth.ToString(); } creditCardExp = creditCardExp + paymentInfo.CreditCardExpireYear.ToString().Substring(2, 2); CreditCard credCard = new CreditCard(paymentInfo.CreditCardNumber, creditCardExp); credCard.Cvv2 = paymentInfo.CreditCardCvv2; CardTender tender = new CardTender(credCard); // <vendor> = your merchant (login id) // <user> = <vendor> unless you created a separate <user> for Payflow Pro // partner = paypal UserInfo userInfo = new UserInfo(user, vendor, partner, password); string url = GetPaypalUrl(); PayflowConnectionData payflowConnectionData = new PayflowConnectionData(url, 443, null, 0, null, null); Response response = null; if (transactionMode == TransactMode.Authorize) { response = new AuthorizationTransaction(userInfo, payflowConnectionData, invoice, tender, PayflowUtility.RequestId).SubmitTransaction(); } else { response = new SaleTransaction(userInfo, payflowConnectionData, invoice, tender, PayflowUtility.RequestId).SubmitTransaction(); } if (response.TransactionResponse != null) { if (response.TransactionResponse.Result == 0) { processPaymentResult.AuthorizationTransactionId = response.TransactionResponse.Pnref; processPaymentResult.AuthorizationTransactionResult = response.TransactionResponse.RespMsg; if (transactionMode == TransactMode.Authorize) { processPaymentResult.PaymentStatus = PaymentStatusEnum.Authorized; } else { processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid; } } else { processPaymentResult.Error = string.Format("{0} - {1}", response.TransactionResponse.Result, response.TransactionResponse.RespMsg); processPaymentResult.FullError = string.Format("Response Code : {0}. Response Description : {1}", response.TransactionResponse.Result, response.TransactionResponse.RespMsg); } } else { processPaymentResult.Error = "Error during checkout"; processPaymentResult.FullError = "Error during checkout"; } } catch (Exception) { throw; } finally { NopContext.Current.SetCulture(userCulture); } }
public static void SetTransactionMode(TransactMode transactionMode) { SettingManager.SetParam("PaymentMethod.USAePayIntegrated.TransactionMode", transactionMode.ToString()); }
public void SetTransactionMode(TransactMode transactionMode) { this.SettingManager.SetParam("PaymentMethod.Manual.TransactionMode", transactionMode.ToString()); }
public static void SetTransactionMode(TransactMode transactionMode) { SettingManager.SetParam("PaymentMethod.PaypalExpress.TransactionMode", transactionMode.ToString()); }