当前位置: 首页>>代码示例>>C#>>正文


C# Payment.ProcessPaymentResult类代码示例

本文整理汇总了C#中NopSolutions.NopCommerce.BusinessLogic.Payment.ProcessPaymentResult的典型用法代码示例。如果您正苦于以下问题:C# ProcessPaymentResult类的具体用法?C# ProcessPaymentResult怎么用?C# ProcessPaymentResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ProcessPaymentResult类属于NopSolutions.NopCommerce.BusinessLogic.Payment命名空间,在下文中一共展示了ProcessPaymentResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
     }
 }
开发者ID:juliakolesen,项目名称:voobrazi.by,代码行数:24,代码来源:PaymentManager.cs

示例2: 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();
			
			WebClient webClient = new WebClient();
			NameValueCollection form = new NameValueCollection();
			form.Add("gwlogin", loginID);
			if (!string.IsNullOrEmpty(RestrictKey))
				form.Add("RestrictKey", RestrictKey);
			form.Add("trans_method", "CC");
			form.Add("CVVtype", "1");
            form.Add("Dsep", "|");
			form.Add("MAXMIND", "1");

			form.Add("amount", paymentInfo.OrderTotal.ToString("####.00", new CultureInfo("en-US", false).NumberFormat));
			form.Add("ccnum", paymentInfo.CreditCardNumber);
			form.Add("ccmo", paymentInfo.CreditCardExpireMonth.ToString("D2"));
			form.Add("ccyr", paymentInfo.CreditCardExpireYear.ToString());
			form.Add("CVV2", paymentInfo.CreditCardCVV2);

			form.Add("FNAME", paymentInfo.BillingAddress.FirstName);
			form.Add("LNAME", paymentInfo.BillingAddress.LastName);

			if (string.IsNullOrEmpty(paymentInfo.BillingAddress.Company))
				form.Add("company", paymentInfo.BillingAddress.Company);

			form.Add("BADDR1", paymentInfo.BillingAddress.Address1);
			form.Add("BCITY", paymentInfo.BillingAddress.City);
			if (paymentInfo.BillingAddress.StateProvince != null)
				form.Add("BSTATE", paymentInfo.BillingAddress.StateProvince.Name);
			form.Add("BZIP1", paymentInfo.BillingAddress.ZipPostalCode);
			if (paymentInfo.BillingAddress.Country != null)
				form.Add("BCOUNTRY", paymentInfo.BillingAddress.Country.TwoLetterISOCode);
			form.Add("invoice_num", OrderGuid.ToString());
			form.Add("customer_ip", HttpContext.Current.Request.UserHostAddress);
			form.Add("BCUST_EMAIL", paymentInfo.BillingAddress.Email);


			string reply = null;
			Byte[] responseData = webClient.UploadValues(GetCDGcommerceUrl(), form);
			reply = Encoding.ASCII.GetString(responseData);

			if (null != reply)
			{
				processPaymentResult.AuthorizationTransactionResult = reply;

				string[] responseFields = reply.Split('|');
				switch (responseFields[0])
				{
					case "\"APPROVED\"":
						processPaymentResult.AuthorizationTransactionCode = responseFields[1];
						processPaymentResult.AVSResult = "AVRResponse: " + responseFields[3] + " Max Score:" + responseFields[5];
						processPaymentResult.AuthorizationTransactionID = responseFields[2]; //responseFields[38];
						processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
						break;
					case "\"DECLINED\"":
						processPaymentResult.Error = responseFields[6];
						processPaymentResult.FullError = responseFields[7] + " " + responseFields[6];
						break;
				}
			}
			else
			{
				processPaymentResult.Error = "CDGcommerce unknown error";
				processPaymentResult.FullError = "CDGcommerce unknown error";
			}
		}
开发者ID:juliakolesen,项目名称:voobrazi.by,代码行数:75,代码来源:CDGcommercePaymentProcessor.cs

示例3: 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)
 {
     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");
     }
 }
开发者ID:netmatrix01,项目名称:Innocent,代码行数:26,代码来源:ManualPaymentProcessor.cs

示例4: 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 NopException("Recurring payments not supported");
 }
开发者ID:netmatrix01,项目名称:Innocent,代码行数:11,代码来源:PayInStorePaymentProcessor.cs

示例5: 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)
 {
     DoExpressCheckout(paymentInfo, orderGuid, processPaymentResult);
 }
开发者ID:robbytarigan,项目名称:ToyHouse,代码行数:11,代码来源:PayPalExpressPaymentProcessor.cs

示例6: Capture

        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="order">Order</param>
        /// <param name="processPaymentResult">Process payment result</param>
        public void Capture(Order order, ref ProcessPaymentResult processPaymentResult)
        {
            InitSettings();

            string authorizationID = processPaymentResult.AuthorizationTransactionId;
            DoCaptureReq req = new DoCaptureReq();
            req.DoCaptureRequest = new DoCaptureRequestType();
            req.DoCaptureRequest.Version = this.APIVersion;
            req.DoCaptureRequest.AuthorizationID = authorizationID;
            req.DoCaptureRequest.Amount = new BasicAmountType();
            req.DoCaptureRequest.Amount.Value = order.OrderTotal.ToString("N", new CultureInfo("en-us"));
            req.DoCaptureRequest.Amount.currencyID = PaypalHelper.GetPaypalCurrency(IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency);
            req.DoCaptureRequest.CompleteType = CompleteCodeType.Complete;
            DoCaptureResponseType response = service2.DoCapture(req);

            string error = string.Empty;
            bool Success = PaypalHelper.CheckSuccess(response, out error);
            if (Success)
            {
                processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
                processPaymentResult.CaptureTransactionId = response.DoCaptureResponseDetails.PaymentInfo.TransactionID;
                processPaymentResult.CaptureTransactionResult = response.Ack.ToString();
            }
            else
            {
                processPaymentResult.Error = error;
            }
        }
开发者ID:robbytarigan,项目名称:ToyHouse,代码行数:33,代码来源:PayPalExpressPaymentProcessor.cs

示例7: Capture

		/// <summary>
		/// Captures order (from admin panel)
		/// </summary>
		/// <param name="OrderID">Order identifier</param>
		/// <param name="Error">Error</param>
		/// <returns>Captured order</returns>
		public static Order Capture(int OrderID, ref string Error)
		{
			Order order = GetOrderByID(OrderID);
			if (order == null)
				return order;

			if (!CanCapture(order))
				throw new NopException("Can not do capture for order.");

			ProcessPaymentResult processPaymentResult = new ProcessPaymentResult();
			try
			{
				//old info from placing order
				processPaymentResult.AuthorizationTransactionID = order.AuthorizationTransactionID;
				processPaymentResult.AuthorizationTransactionCode = order.AuthorizationTransactionCode;
				processPaymentResult.AuthorizationTransactionResult = order.AuthorizationTransactionResult;
				processPaymentResult.CaptureTransactionID = order.CaptureTransactionID;
				processPaymentResult.CaptureTransactionResult = order.CaptureTransactionResult;
				processPaymentResult.PaymentStatus = order.PaymentStatus;

				PaymentManager.Capture(order, ref processPaymentResult);

				if (String.IsNullOrEmpty(processPaymentResult.Error))
				{
					InsertOrderNote(order.OrderID, string.Format("Order has been captured"), DateTime.Now);

					order = UpdateOrder(order.OrderID, order.OrderGUID, order.CustomerID, order.CustomerLanguageID,
						order.CustomerTaxDisplayType, order.OrderSubtotalInclTax, order.OrderSubtotalExclTax, order.OrderShippingInclTax,
						order.OrderShippingExclTax, order.PaymentMethodAdditionalFeeInclTax, order.PaymentMethodAdditionalFeeExclTax,
						order.OrderTax, order.OrderTotal, order.OrderDiscount,
						order.OrderSubtotalInclTaxInCustomerCurrency, order.OrderSubtotalExclTaxInCustomerCurrency,
						order.OrderShippingInclTaxInCustomerCurrency, order.OrderShippingExclTaxInCustomerCurrency,
						order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency,
						order.OrderTaxInCustomerCurrency, order.OrderTotalInCustomerCurrency, order.CustomerCurrencyCode, order.OrderWeight,
						order.AffiliateID, order.OrderStatus, order.AllowStoringCreditCardNumber,
						order.CardType, order.CardName, order.CardNumber, order.MaskedCreditCardNumber,
						order.CardCVV2, order.CardExpirationMonth, order.CardExpirationYear,
						order.PaymentMethodID, order.PaymentMethodName,
						processPaymentResult.AuthorizationTransactionID,
						processPaymentResult.AuthorizationTransactionCode,
						processPaymentResult.AuthorizationTransactionResult,
						processPaymentResult.CaptureTransactionID,
						processPaymentResult.CaptureTransactionResult,
						order.PurchaseOrderNumber,
						processPaymentResult.PaymentStatus,
						order.BillingFirstName, order.BillingLastName, order.BillingPhoneNumber,
						order.BillingEmail, order.BillingFaxNumber, order.BillingCompany, order.BillingAddress1,
						order.BillingAddress2, order.BillingCity,
						order.BillingStateProvince, order.BillingStateProvinceID, order.BillingZipPostalCode,
						order.BillingCountry, order.BillingCountryID, order.ShippingStatus,
						order.ShippingFirstName, order.ShippingLastName, order.ShippingPhoneNumber,
						order.ShippingEmail, order.ShippingFaxNumber, order.ShippingCompany,
						order.ShippingAddress1, order.ShippingAddress2, order.ShippingCity,
						order.ShippingStateProvince, order.ShippingStateProvinceID, order.ShippingZipPostalCode,
						order.ShippingCountry, order.ShippingCountryID,
						order.ShippingMethod, order.ShippingRateComputationMethodID, order.ShippedDate, order.Deleted,
						order.CreatedOn);
				}
				else
				{
					InsertOrderNote(order.OrderID, string.Format("Unable to capture order. Error: {0}", processPaymentResult.Error), DateTime.Now);

				}
				order = CheckOrderStatus(order.OrderID);
			}
			catch (Exception exc)
			{
				processPaymentResult.Error = exc.Message;
				processPaymentResult.FullError = exc.ToString();
			}

			if (!String.IsNullOrEmpty(processPaymentResult.Error))
			{
				Error = processPaymentResult.Error;
				LogManager.InsertLog(LogTypeEnum.OrderError, string.Format("Error capturing order. {0}", processPaymentResult.Error), processPaymentResult.FullError);
			}
			return order;
		}
开发者ID:juliakolesen,项目名称:voobrazi.by,代码行数:84,代码来源:OrderManager.cs

示例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());
                    }

//.........这里部分代码省略.........
开发者ID:robbytarigan,项目名称:ToyHouse,代码行数:101,代码来源:OrderService.cs

示例9: 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)
        {
            InitSettings();
            MerchantAuthenticationType authentication = PopulateMerchantAuthentication();
            if (!paymentInfo.IsRecurringPayment)
            {
                ARBSubscriptionType subscription = new ARBSubscriptionType();
                NopSolutions.NopCommerce.Payment.Methods.AuthorizeNet.net.authorize.api.CreditCardType creditCard = new NopSolutions.NopCommerce.Payment.Methods.AuthorizeNet.net.authorize.api.CreditCardType();

                subscription.name = orderGuid.ToString();

                creditCard.cardNumber = paymentInfo.CreditCardNumber;
                creditCard.expirationDate = paymentInfo.CreditCardExpireYear + "-" + paymentInfo.CreditCardExpireMonth; // required format for API is YYYY-MM
                creditCard.cardCode = paymentInfo.CreditCardCvv2;

                subscription.payment = new PaymentType();
                subscription.payment.Item = creditCard;

                subscription.billTo = new NameAndAddressType();
                subscription.billTo.firstName = paymentInfo.BillingAddress.FirstName;
                subscription.billTo.lastName = paymentInfo.BillingAddress.LastName;
                subscription.billTo.address = paymentInfo.BillingAddress.Address1 + " " + paymentInfo.BillingAddress.Address2;
                subscription.billTo.city = paymentInfo.BillingAddress.City;
                if (paymentInfo.BillingAddress.StateProvince != null)
                {
                    subscription.billTo.state = paymentInfo.BillingAddress.StateProvince.Abbreviation;
                }
                subscription.billTo.zip = paymentInfo.BillingAddress.ZipPostalCode;

                if (paymentInfo.ShippingAddress != null)
                {
                    subscription.shipTo = new NameAndAddressType();
                    subscription.shipTo.firstName = paymentInfo.ShippingAddress.FirstName;
                    subscription.shipTo.lastName = paymentInfo.ShippingAddress.LastName;
                    subscription.shipTo.address = paymentInfo.ShippingAddress.Address1 + " " + paymentInfo.ShippingAddress.Address2;
                    subscription.shipTo.city = paymentInfo.ShippingAddress.City;
                    if (paymentInfo.ShippingAddress.StateProvince != null)
                    {
                        subscription.shipTo.state = paymentInfo.ShippingAddress.StateProvince.Abbreviation;
                    }
                    subscription.shipTo.zip = paymentInfo.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 = string.Format("{0} {1}", IoC.Resolve<ISettingManager>().StoreName, "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(paymentInfo.RecurringTotalCycles);
                subscription.paymentSchedule.totalOccurrencesSpecified = true;

                subscription.amount = paymentInfo.OrderTotal;
                subscription.amountSpecified = true;

                // Interval can't be updated once a subscription is created.
                subscription.paymentSchedule.interval = new PaymentScheduleTypeInterval();
                switch (paymentInfo.RecurringCyclePeriod)
                {
                    case (int)RecurringProductCyclePeriodEnum.Days:
                        subscription.paymentSchedule.interval.length = Convert.ToInt16(paymentInfo.RecurringCycleLength);
                        subscription.paymentSchedule.interval.unit = ARBSubscriptionUnitEnum.days;
                        break;
                    case (int)RecurringProductCyclePeriodEnum.Weeks:
                        subscription.paymentSchedule.interval.length = Convert.ToInt16(paymentInfo.RecurringCycleLength * 7);
                        subscription.paymentSchedule.interval.unit = ARBSubscriptionUnitEnum.days;
                        break;
                    case (int)RecurringProductCyclePeriodEnum.Months:
                        subscription.paymentSchedule.interval.length = Convert.ToInt16(paymentInfo.RecurringCycleLength);
                        subscription.paymentSchedule.interval.unit = ARBSubscriptionUnitEnum.months;
                        break;
                    case (int)RecurringProductCyclePeriodEnum.Years:
                        subscription.paymentSchedule.interval.length = Convert.ToInt16(paymentInfo.RecurringCycleLength * 12);
                        subscription.paymentSchedule.interval.unit = ARBSubscriptionUnitEnum.months;
                        break;
                    default:
                        throw new NopException("Not supported cycle period");
                }

                ARBCreateSubscriptionResponseType response = webService.ARBCreateSubscription(authentication, subscription);

                if (response.resultCode == MessageTypeEnum.Ok)
                {
                    processPaymentResult.SubscriptionTransactionId = response.subscriptionId.ToString();
//.........这里部分代码省略.........
开发者ID:robbytarigan,项目名称:ToyHouse,代码行数:101,代码来源:AuthorizeNetPaymentProcessor.cs

示例10: 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";
            }
        }
开发者ID:robbytarigan,项目名称:ToyHouse,代码行数:94,代码来源:AuthorizeNetPaymentProcessor.cs

示例11: Capture

        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="order">Order</param>
        /// <param name="processPaymentResult">Process payment result</param>
        public void Capture(Order order, ref ProcessPaymentResult processPaymentResult)
        {
            InitSettings();

            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);
            form.Add("x_type", "PRIOR_AUTH_CAPTURE");

            form.Add("x_amount", order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture));
            string[] codes = processPaymentResult.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]);

            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];
                        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";
            }
        }
开发者ID:robbytarigan,项目名称:ToyHouse,代码行数:65,代码来源:AuthorizeNetPaymentProcessor.cs

示例12: 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;
                }
            }
        }
开发者ID:netmatrix01,项目名称:Innocent,代码行数:46,代码来源:XmlPaymentProcessor.cs

示例13: Capture

        /// <summary>
        /// Captures payment (from admin panel)
        /// </summary>
        /// <param name="order">Order</param>
        /// <param name="processPaymentResult">Process payment result</param>
        public void Capture(Order order, 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 = "";

            success = sxml.processAdvice(order.OrderTotal,order.OrderGuid.ToString(),processPaymentResult.AuthorizationTransactionCode);

            code = sxml["response_code"];

            if (!success)
            {
                processPaymentResult.Error = String.Format("Declined ({0})", code);
                processPaymentResult.FullError = sxml.Error;
            }
            else
            {
                processPaymentResult.CaptureTransactionId = sxml["transaction_id"];
                processPaymentResult.CaptureTransactionResult = String.Format("Approved ({0})", code);

                processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
            }
        }
开发者ID:netmatrix01,项目名称:Innocent,代码行数:28,代码来源:XmlPaymentProcessor.cs

示例14: Capture

 /// <summary>
 /// Captures payment (from admin panel)
 /// </summary>
 /// <param name="order">Order</param>
 /// <param name="processPaymentResult">Process payment result</param>
 public void Capture(Order order, ref ProcessPaymentResult processPaymentResult)
 {
     //TODO implement capture from admin panel using CaptureTransaction object
     throw new NopException("Capture method not supported");
 }
开发者ID:juliakolesen,项目名称:voobrazi.by,代码行数:10,代码来源:PayFlowProPaymentProcessor.cs

示例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();

            //little hack here
            CultureInfo userCulture = Thread.CurrentThread.CurrentCulture;
            NopContext.Current.SetCulture(new CultureInfo("en-US"));
            try
            {
                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;
                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 invoice = new Invoice();
                invoice.BillTo = to;
                invoice.ShipTo = to2;
                invoice.InvNum = OrderGuid.ToString();
                //For values which have more than two decimal places 
                //Currency Amt = new Currency(new decimal(25.1214));
                //Amt.NoOfDecimalDigits = 2;
                //If the NoOfDecimalDigits property is used then it is mandatory to set one of the following properties to true.
                //Amt.Round = true;
                //Amt.Truncate = true;
                //Inv.Amt = Amt;
                decimal orderTotal = Math.Round(paymentInfo.OrderTotal, 2);
                //UNDONE USD only
                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);
                    }
//.........这里部分代码省略.........
开发者ID:juliakolesen,项目名称:voobrazi.by,代码行数:101,代码来源:PayFlowProPaymentProcessor.cs


注:本文中的NopSolutions.NopCommerce.BusinessLogic.Payment.ProcessPaymentResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。