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


C# NVPCodec.Add方法代码示例

本文整理汇总了C#中NVPCodec.Add方法的典型用法代码示例。如果您正苦于以下问题:C# NVPCodec.Add方法的具体用法?C# NVPCodec.Add怎么用?C# NVPCodec.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NVPCodec的用法示例。


在下文中一共展示了NVPCodec.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ECSetExpressCheckout

        public string ECSetExpressCheckout(Cart cart)
        {
            Settings settings = new Settings();
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = getProfile();
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder.Add("VERSION", "84.0");
            encoder.Add("METHOD", "SetExpressCheckout");
            // Add request-specific fields to the request.
            encoder.Add("RETURNURL", getSiteURL() + "Payment/CompletePayPalCheckout");
            encoder.Add("CANCELURL", getSiteURL() + "Payment");
            encoder.Add("PAYMENTREQUEST_0_AMT", String.Format("{0:N2}", cart.getTotal()));
            encoder.Add("PAYMENTREQUEST_0_PAYMENTACTION", "Sale");
            encoder.Add("PAYMENTREQUEST_0_CURRENCYCODE", "USD");
            encoder.Add("BRANDNAME", settings.Get("SiteName") + " eCommerce Platform");
            encoder.Add("LOGIN", "Login");
            encoder.Add("HDRIMG", settings.Get("EmailLogo"));
            encoder.Add("CUSTOMERSERVICENUMBER", "888-894-4824");
            encoder.Add("PAYMENTREQUEST_0_SHIPPINGAMT", String.Format("{0:N2}", cart.shipping_price));
            encoder.Add("PAYMENTREQUEST_0_DESC", "Your " + settings.Get("SiteName") + " Order");
            encoder.Add("ALLOWNOTE", "0");
            encoder.Add("NOSHIPPING", "1");
            int count = 0;
            decimal total = 0;
            foreach (CartItem item in cart.CartItems) {
                encoder.Add("L_PAYMENTREQUEST_0_NUMBER" + count, item.partID.ToString());
                encoder.Add("L_PAYMENTREQUEST_0_NAME" + count, item.shortDesc);
                encoder.Add("L_PAYMENTREQUEST_0_AMT" + count, String.Format("{0:N2}", item.price));
                encoder.Add("L_PAYMENTREQUEST_0_QTY" + count, item.quantity.ToString());
                encoder.Add("L_PAYMENTREQUEST_0_ITEMCATEGORY" + count, "Physical");
                encoder.Add("L_PAYMENTREQUEST_0_ITEMURL" + count, settings.Get("SiteURL") + "part/" + item.partID);
                total += item.price * item.quantity;
                count++;
            }
            encoder.Add("PAYMENTREQUEST_0_TAXAMT", String.Format("{0:N2}", cart.tax));
            encoder.Add("PAYMENTREQUEST_0_ITEMAMT", String.Format("{0:N2}", total));

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            if (decoder["TOKEN"] != null) {
                return decoder["TOKEN"];
            } else {

                string errors = " CorrelationID: " + decoder["CORRELATIONID"] + " error code: " + decoder["L_ERRORCODE0"] + " Messages: " + decoder["L_SHORTMESSAGE0"] + ", " + decoder["L_SHORTMESSAGE2"] + ", " + decoder["L_LONGMESSAGE0"] + ", " + decoder["L_LONGMESSAGE1"];
                return decoder["ACK"] + errors;
            }
        }
开发者ID:meganmcchesney,项目名称:CURTeCommerce,代码行数:53,代码来源:Paypal.cs

示例2: PaymentInfo

        public ActionResult PaymentInfo()
        {
            var model = new PaymentSagePayServerModel();

            //First validate if this is the response of failed transaction (Status INVALID)
            var StatusDetail = Request.QueryString["StatusDetail"];

            if (StatusDetail != null)
            {
                model.Warnings.Add(StatusDetail);
                return View("Nop.Plugin.Payments.SagePayServer.Views.PaymentSagePayServer.PaymentInfo", model);
            }

            var webClient = new WebClient();

            var data = new NVPCodec();

            data.Add("VPSProtocol", SagePayHelper.GetProtocol());
            data.Add("TxType", _sagePayServerPaymentSettings.TransactType);
            data.Add("Vendor", _sagePayServerPaymentSettings.VendorName.ToLower());

            var orderGuid = Guid.NewGuid();

            data.Add("VendorTxCode", orderGuid.ToString());

            if (!String.IsNullOrWhiteSpace(_sagePayServerPaymentSettings.PartnerID))
                data.Add("ReferrerID", _sagePayServerPaymentSettings.PartnerID);

            var cart = _workContext.CurrentCustomer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart).ToList();
            
            decimal? shoppingCartTotalBase = _orderTotalCalculationService.GetShoppingCartTotal(cart);

            var OrderTotal = shoppingCartTotalBase.GetValueOrDefault();

            data.Add("Amount", OrderTotal.ToString("F2", CultureInfo.InvariantCulture));

            if (_workContext.WorkingCurrency != null)
                data.Add("Currency", _workContext.WorkingCurrency.CurrencyCode);
            else if (_workContext.CurrentCustomer.CurrencyId.HasValue && _workContext.CurrentCustomer.Currency != null)
                data.Add("Currency", _workContext.CurrentCustomer.Currency.CurrencyCode);
            else
                data.Add("Currency", _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode);                        

            data.Add("Description", "DescriptionText");

            // The Notification URL is the page to which Server calls back when a transaction completes

            var notificationUrl = _sagePayServerPaymentSettings.NotificationFullyQualifiedDomainName;

            data.Add("NotificationURL", notificationUrl + "Plugins/PaymentSagePayServer/NotificationPage");

            // Billing Details
            data.Add("BillingSurname", _workContext.CurrentCustomer.BillingAddress.LastName);
            data.Add("BillingFirstnames", _workContext.CurrentCustomer.BillingAddress.FirstName);
            data.Add("BillingAddress1", _workContext.CurrentCustomer.BillingAddress.Address1);

            if (!String.IsNullOrWhiteSpace(_workContext.CurrentCustomer.BillingAddress.Address2))
                data.Add("BillingAddress2", _workContext.CurrentCustomer.BillingAddress.Address2);

            data.Add("BillingCity", _workContext.CurrentCustomer.BillingAddress.City);
            data.Add("BillingPostCode", _workContext.CurrentCustomer.BillingAddress.ZipPostalCode);
            data.Add("BillingCountry", _workContext.CurrentCustomer.BillingAddress.Country.TwoLetterIsoCode); //TODO: Verify if it is ISO 3166-1 country code

            if (_workContext.CurrentCustomer.BillingAddress.StateProvince != null)
                data.Add("BillingState", _workContext.CurrentCustomer.BillingAddress.StateProvince.Abbreviation);

            if (!String.IsNullOrWhiteSpace(_workContext.CurrentCustomer.BillingAddress.PhoneNumber))
                data.Add("BillingPhone", _workContext.CurrentCustomer.BillingAddress.PhoneNumber);


            // Delivery Details
            if (_workContext.CurrentCustomer.ShippingAddress != null)
            {
                data.Add("DeliverySurname", _workContext.CurrentCustomer.ShippingAddress.LastName);
                data.Add("DeliveryFirstnames", _workContext.CurrentCustomer.ShippingAddress.FirstName);
                data.Add("DeliveryAddress1", _workContext.CurrentCustomer.ShippingAddress.Address1);

                if (!String.IsNullOrWhiteSpace(_workContext.CurrentCustomer.ShippingAddress.Address2))
                    data.Add("DeliveryAddress2", _workContext.CurrentCustomer.ShippingAddress.Address2);

                data.Add("DeliveryCity", _workContext.CurrentCustomer.ShippingAddress.City);
                data.Add("DeliveryPostCode", _workContext.CurrentCustomer.ShippingAddress.ZipPostalCode);

                if (_workContext.CurrentCustomer.ShippingAddress.Country != null)
                {
                    data.Add("DeliveryCountry", _workContext.CurrentCustomer.ShippingAddress.Country.TwoLetterIsoCode);
                }

                if (_workContext.CurrentCustomer.ShippingAddress.StateProvince != null)
                    data.Add("DeliveryState", _workContext.CurrentCustomer.ShippingAddress.StateProvince.Abbreviation);

                if (!String.IsNullOrWhiteSpace(_workContext.CurrentCustomer.ShippingAddress.PhoneNumber))
                    data.Add("DeliveryPhone", _workContext.CurrentCustomer.ShippingAddress.PhoneNumber);

            }
            else {
                //Thanks to 'nomisit' for pointing this out. http://www.nopcommerce.com/p/258/sagepay-server-integration-iframe-and-redirect-methods.aspx
                data.Add("DeliverySurname", "");
                data.Add("DeliveryFirstnames", "");
                data.Add("DeliveryAddress1", "");
//.........这里部分代码省略.........
开发者ID:philipengland,项目名称:albionextrusions.co.uk,代码行数:101,代码来源:PaymentSagePayServerController.cs

示例3: ECDoExpressCheckout

        public string ECDoExpressCheckout(string token, string payerID, string amount, Cart cart)
        {
            Settings settings = new Settings();
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = getProfile();
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder.Add("VERSION","84.0");
            encoder.Add("METHOD","DoExpressCheckoutPayment");

            // Add request-specific fields to the request.
            encoder.Add("TOKEN",token);
            encoder.Add("PAYERID",payerID);
            encoder.Add("RETURNURL",getSiteURL() + "Payment/PayPalCheckout");
            encoder.Add("CANCELURL",getSiteURL() + "Payment");
            encoder.Add("PAYMENTREQUEST_0_AMT",amount);
            encoder.Add("PAYMENTREQUEST_0_PAYMENTACTION","Sale");
            encoder.Add("PAYMENTREQUEST_0_CURRENCYCODE","USD");
            encoder.Add("BRANDNAME",settings.Get("SiteName"));
            encoder.Add("LOGIN","Login");
            encoder.Add("HDRIMG",settings.Get("EmailLogo"));
            encoder.Add("CUSTOMERSERVICENUMBER",settings.Get("PhoneNumber"));
            encoder.Add("PAYMENTREQUEST_0_SHIPPINGAMT",cart.shipping_price.ToString());
            encoder.Add("PAYMENTREQUEST_0_DESC","Your " + settings.Get("SiteName") + " Order");
            encoder.Add("ALLOWNOTE","0");
            encoder.Add("NOSHIPPING","1");
            int count = 0;
            decimal total = 0;
            foreach (CartItem item in cart.CartItems) {
                encoder.Add("L_PAYMENTREQUEST_0_NUMBER" + count, item.partID.ToString());
                encoder.Add("L_PAYMENTREQUEST_0_NAME" + count, item.shortDesc);
                encoder.Add("L_PAYMENTREQUEST_0_AMT" + count, String.Format("{0:N2}", item.price));
                encoder.Add("L_PAYMENTREQUEST_0_QTY" + count, item.quantity.ToString());
                encoder.Add("L_PAYMENTREQUEST_0_ITEMCATEGORY" + count, "Physical");
                encoder.Add("L_PAYMENTREQUEST_0_ITEMURL" + count, settings.Get("SiteURL") + "part/" + item.partID);
                total += item.price * item.quantity;
                count++;
            }
            encoder.Add("PAYMENTREQUEST_0_TAXAMT", String.Format("{0:N2}", cart.tax));
            encoder.Add("PAYMENTREQUEST_0_ITEMAMT", String.Format("{0:N2}", total));
            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder["ACK"];
        }
开发者ID:meganmcchesney,项目名称:CURTeCommerce,代码行数:49,代码来源:Paypal.cs


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