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


C# IInvoice.ShippingLineItems方法代码示例

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


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

示例1: PerformTask

        /// <summary>
        /// Performs the task of applying taxes to the invoice.
        /// </summary>
        /// <param name="value">
        /// The <see cref="IInvoice"/>
        /// </param>
        /// <returns>
        /// The <see cref="Attempt"/>.
        /// </returns>
        public override Attempt<IInvoice> PerformTask(IInvoice value)
        {
            // if taxes are not to be applied, skip this step
            if (this.SalePreparation.ApplyTaxesToInvoice)
            {
                try
                {
                    // clear any current tax lines
                    var removers = value.Items.Where(x => x.LineItemType == LineItemType.Tax);
                    foreach (var remove in removers)
                    {
                        value.Items.Remove(remove);
                    }

                    IAddress taxAddress = null;
                    var shippingItems = value.ShippingLineItems().ToArray();
                    if (shippingItems.Any())
                    {
                        var shipment = shippingItems.First().ExtendedData.GetShipment<OrderLineItem>();
                        taxAddress = shipment.GetDestinationAddress();
                    }

                    taxAddress = taxAddress ?? value.GetBillingAddress();

                    this.SetTaxableSetting(value);
                    var taxes = value.CalculateTaxes(this.SalePreparation.MerchelloContext, taxAddress);
                    this.SetTaxableSetting(value, true);                    

                    var taxLineItem = taxes.AsLineItemOf<InvoiceLineItem>();

                    var currencyCode =
                        this.SalePreparation.MerchelloContext.Services.StoreSettingService.GetByKey(
                            Core.Constants.StoreSettingKeys.CurrencyCodeKey).Value;

                    taxLineItem.ExtendedData.SetValue(Core.Constants.ExtendedDataKeys.CurrencyCode, currencyCode);

                    value.Items.Add(taxLineItem);

                    return Attempt<IInvoice>.Succeed(value);
                }
                catch (Exception ex)
                {
                    return Attempt<IInvoice>.Fail(ex);
                }
            }

            return Attempt<IInvoice>.Succeed(value);
        }
开发者ID:Teknyc,项目名称:Merchello,代码行数:57,代码来源:ApplyTaxesToInvoiceTax.cs

示例2: PriorAuthorizeCapturePayment

        public IPaymentResult PriorAuthorizeCapturePayment(IInvoice invoice, IPayment payment, decimal amount)
        {
            var api = new QuickPayApi(_settings.ApiKey);
              var paymentId = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.QuickpayPaymentId);
              //var amountMinor = int.Parse(payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.QuickpayPaymentAmount));
              var amountMinor = IsZeroDecimalCurrency(invoice.CurrencyCode()) ? amount.ToString("F0") : (amount * 100).ToString("F0");

              try {
            var captureResult = api.CapturePayment(paymentId, amountMinor);

            if (captureResult.Accepted && captureResult.Operations.Any(x => x.Type == "capture" && x.Amount.ToString("F0") == amountMinor)) {
              LogHelper.Info<QuickPayPaymentProcessor>(string.Format("QuickPay Capture PaymentId {0} Success:\r\n{1}", paymentId, captureResult));
              return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, invoice.ShippingLineItems().Any());
            } else {
              LogHelper.Info<QuickPayPaymentProcessor>(string.Format("QuickPay Capture PaymentId {0} Error:\r\n{1}", paymentId, captureResult));
              return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("{0}", "QuickPay unknown error"))), invoice, false);
            }
              } catch (Exception x) {
            LogHelper.Error<QuickPayPaymentProcessor>(string.Format("QuickPay Capture PaymentId {0} Error:\r\n{1}", paymentId, x.Message), x);
            return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("{0}", "QuickPay unknown error"))), invoice, false);
              }
        }
开发者ID:joelbhansen,项目名称:MerchelloQuickPayProvider,代码行数:22,代码来源:QuickPayPaymentProcessor.cs

示例3: Build

        /// <summary>
        /// Builds the <see cref="PaymentDetailsItemType"/>.
        /// </summary>
        /// <param name="invoice">
        /// The invoice.
        /// </param>
        /// <param name="actionCode">
        /// The <see cref="PaymentActionCodeType"/>.
        /// </param>
        /// <returns>
        /// The <see cref="PaymentDetailsType"/>.
        /// </returns>
        public PaymentDetailsType Build(IInvoice invoice, PaymentActionCodeType actionCode)
        {
            // Get the decimal configuration for the current currency
            var currencyCodeType = PayPalApiHelper.GetPayPalCurrencyCode(invoice.CurrencyCode);
            var basicAmountFactory = new PayPalBasicAmountTypeFactory(currencyCodeType);

            // Get the tax total
            var itemTotal = basicAmountFactory.Build(invoice.TotalItemPrice());
            var shippingTotal = basicAmountFactory.Build(invoice.TotalShipping());
            var taxTotal = basicAmountFactory.Build(invoice.TotalTax());
            var invoiceTotal = basicAmountFactory.Build(invoice.Total);

            var items = BuildPaymentDetailsItemTypes(invoice.ProductLineItems(), basicAmountFactory);

            var paymentDetails = new PaymentDetailsType
            {
                PaymentDetailsItem = items.ToList(),
                ItemTotal = itemTotal,
                TaxTotal = taxTotal,
                ShippingTotal = shippingTotal,
                OrderTotal = invoiceTotal,
                PaymentAction = actionCode,
                InvoiceID = invoice.PrefixedInvoiceNumber()
            };

            // ShipToAddress
            if (invoice.ShippingLineItems().Any())
            {
                var addressTypeFactory = new PayPalAddressTypeFactory();
                paymentDetails.ShipToAddress = addressTypeFactory.Build(invoice.GetShippingAddresses().FirstOrDefault());
            }

            return paymentDetails;
        }
开发者ID:ryanology,项目名称:Merchello,代码行数:46,代码来源:PayPalPaymentDetailsTypeFactory.cs

示例4: SetSagePayApiData

        //TODO: refactor away to a Service that wraps the SagePay kit horribleness
        private void SetSagePayApiData(IFormPayment request, IInvoice invoice, IPayment payment)
        {
            // Get Merchello data
            var billingAddress = invoice.GetBillingAddress();
            var shippingAddress = billingAddress;

            // Shipment - only use a shipping address if there is shipment info in the invoice
            var shipmentLineItem = invoice.ShippingLineItems().FirstOrDefault();
            if (shipmentLineItem != null)
            {
                var shipment = shipmentLineItem.ExtendedData.GetShipment<InvoiceLineItem>();
                shippingAddress = shipment.GetDestinationAddress();
            }
            
            // SagePay details
            request.VpsProtocol = Settings.ProtocolVersion;
            request.TransactionType = Settings.TransactionType;
            request.Vendor = Settings.VendorName;
            request.VendorTxCode = SagePayFormIntegration.GetNewVendorTxCode();
            request.Amount = payment.Amount;
            request.Currency = invoice.CurrencyCode();
            request.Description = "Goods from " + Settings.VendorName;
            
            // TODO:  Is there a basket summary I can access?  Or convert the Basket to a sagepay format

            // Set ReturnUrl and CancelUrl of SagePay request to SagePayApiController.
            Func<string, string> adjustUrl = (url) =>
            {
                if (!url.StartsWith("http")) url = GetWebsiteUrl() + (url[0] == '/' ? "" : "/") + url;
                url = url.Replace("{invoiceKey}", invoice.Key.ToString(), StringComparison.InvariantCultureIgnoreCase);
                url = url.Replace("{paymentKey}", payment.Key.ToString(), StringComparison.InvariantCultureIgnoreCase);
                return url;
            };

            request.SuccessUrl = adjustUrl("/umbraco/MerchelloSagePay/SagePayApi/SuccessPayment?InvoiceKey={invoiceKey}&PaymentKey={paymentKey}");
            request.FailureUrl = adjustUrl("/umbraco/MerchelloSagePay/SagePayApi/AbortPayment?InvoiceKey={invoiceKey}&PaymentKey={paymentKey}");

            // Billing details
            request.BillingSurname = billingAddress.TrySplitLastName();
            request.BillingFirstnames = billingAddress.TrySplitFirstName();
            request.BillingAddress1 = billingAddress.Address1;
            request.BillingAddress2 = billingAddress.Address2;
            request.BillingPostCode = billingAddress.PostalCode;
            request.BillingCity = billingAddress.Locality;
            request.BillingCountry = invoice.BillToCountryCode;
            request.CustomerEmail = billingAddress.Email;

            // Shipping details
            request.DeliverySurname = shippingAddress.TrySplitLastName();
            request.DeliveryFirstnames = shippingAddress.TrySplitFirstName();
            request.DeliveryAddress1 = shippingAddress.Address1;
            request.DeliveryCity = shippingAddress.Locality;
            request.DeliveryCountry = shippingAddress.CountryCode;
            request.DeliveryPostCode = shippingAddress.PostalCode;

            //Optional
            //request.CustomerName = cart.Billing.FirstNames + " " + cart.Billing.Surname;
            
            //request.VendorEmail = Settings.VendorEmail;
            //request.SendEmail = Settings.SendEmail;

            //request.EmailMessage = Settings.EmailMessage;
            //request.BillingAddress2 = billingAddress.Address2;
            //request.BillingPostCode = billingAddress.PostalCode;
            //request.BillingState = billingAddress.Region;
            //request.BillingPhone = billingAddress.Phone;
            //request.DeliveryAddress2 = shippingAddress.Address2;
            //request.DeliveryPostCode = shippingAddress.PostalCode;
            //request.DeliveryState = shippingAddress.Region;
            //request.DeliveryPhone = shippingAddress.Phone;

        }
开发者ID:chrisdaaaaay,项目名称:Merchello.Plugins.SagePay,代码行数:73,代码来源:SagePayFormPaymentProcessor.cs

示例5: GetRefundPaymentResult

        private IPaymentResult GetRefundPaymentResult(IInvoice invoice, IPayment payment, HttpWebResponse response)
        {
            string apiResponse = null;
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                apiResponse = reader.ReadToEnd();
            }
            JObject responseJson = JObject.Parse(apiResponse);

            switch (response.StatusCode)
            {
                case HttpStatusCode.OK: // 200
                    return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice,
                        invoice.ShippingLineItems().Any());
                case HttpStatusCode.PaymentRequired: // 402
                    return
                        new PaymentResult(
                            Attempt<IPayment>.Fail(payment,
                                new Exception(string.Format("Error {0}", responseJson["message"]))), invoice, false);
                default:
                    return
                        new PaymentResult(
                            Attempt<IPayment>.Fail(payment,
                                new Exception(string.Format("Error {0}", "Stripe unknown error"))), invoice, false);
            }
        }
开发者ID:drpeck,项目名称:Merchello,代码行数:26,代码来源:StripePaymentProcessor.cs

示例6: GetCapturePaymentResult

        // TODO: is this identical to GetProcessPaymentResult()? If so, consolidate...
        private static IPaymentResult GetCapturePaymentResult(IInvoice invoice, IPayment payment,
            HttpWebResponse response)
        {
            string apiResponse = null;
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                apiResponse = reader.ReadToEnd();
            }
            JObject responseJson = JObject.Parse(apiResponse);

            switch (response.StatusCode)
            {
                case HttpStatusCode.OK: // 200
                    payment.ExtendedData.SetValue(Constants.ExtendedDataKeys.StripeChargeId, (string) responseJson["id"]);
                    payment.Authorized = true;
                    if ((bool) responseJson["captured"]) payment.Collected = true;
                    return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice,
                        invoice.ShippingLineItems().Any());
                case HttpStatusCode.PaymentRequired: // 402
                    return
                        new PaymentResult(
                            Attempt<IPayment>.Fail(payment,
                                new Exception(string.Format("{0}", responseJson["error"]["message"]))), invoice, false);
                default:
                    return
                        new PaymentResult(
                            Attempt<IPayment>.Fail(payment,
                                new Exception(string.Format("{0}", "Stripe unknown error"))), invoice, false);
            }
        }
开发者ID:drpeck,项目名称:Merchello,代码行数:31,代码来源:StripePaymentProcessor.cs

示例7: SetSagePayApiData

        //TODO: refactor away to a Service that wraps the SagePay kit horribleness
        private void SetSagePayApiData(IDirectPayment request, IInvoice invoice, IPayment payment, CreditCard creditCard)
        {
            // Get Merchello data
            //TODO - what if there is no shipping info?  e.g. Classes only - Get from billing?
            var shipmentLineItem = invoice.ShippingLineItems().FirstOrDefault();
            var shipment = shipmentLineItem.ExtendedData.GetShipment<InvoiceLineItem>();
            var shippingAddress = shipment.GetDestinationAddress();
            var billingAddress = invoice.GetBillingAddress(); 
            

            // Merchello info for callback
            //request.InvoiceKey = invoice.Key;
            //request.PayerId = invoice.Pa
            //request.PaymentKey = payment.Key
            
            // SagePay details
            request.VpsProtocol = Settings.ProtocolVersion;
            request.TransactionType = Settings.TransactionType;
            request.Vendor = Settings.VendorName;
            request.VendorTxCode = SagePayAPIIntegration.GetNewVendorTxCode();
            request.Amount = payment.Amount;
            request.Currency = invoice.CurrencyCode();
            request.Description = "Goods from " + Settings.VendorName;
            
            // TODO:  Is there a basket summary I can access?  Or convert the Basket to a sagepay format

            // Billing details
            request.BillingSurname = billingAddress.TrySplitLastName();
            request.BillingFirstnames = billingAddress.TrySplitFirstName();
            request.BillingAddress1 = billingAddress.Address1;
            request.BillingAddress2 = billingAddress.Address2;
            request.BillingPostCode = billingAddress.PostalCode;
            request.BillingCity = billingAddress.Locality;
            request.BillingCountry = invoice.BillToCountryCode;

            // Shipping details
            request.DeliverySurname = shippingAddress.TrySplitLastName();
            request.DeliveryFirstnames = shippingAddress.TrySplitFirstName();
            request.DeliveryAddress1 = shippingAddress.Address1;
            request.DeliveryCity = shippingAddress.Locality;
            request.DeliveryCountry = shippingAddress.CountryCode;
            request.DeliveryPostCode = shippingAddress.PostalCode;

            request.CardType = (CardType)Enum.Parse(typeof(CardType), creditCard.CreditCardType);
            request.CardHolder = creditCard.CardholderName;
            request.CardNumber = creditCard.CardNumber;
            request.ExpiryDate = creditCard.ExpireMonth + creditCard.ExpireYear;
            request.Cv2 = creditCard.CardCode;

            request.Apply3dSecure = 0;

            if (request.CardType == CardType.PAYPAL)
            {
                Func<string, string> adjustUrl = (url) =>
                {
                    if (!url.StartsWith("http")) url = GetWebsiteUrl() + (url[0] == '/' ? "" : "/") + url;
                    url = url.Replace("{invoiceKey}", invoice.Key.ToString(), StringComparison.InvariantCultureIgnoreCase);
                    url = url.Replace("{paymentKey}", payment.Key.ToString(), StringComparison.InvariantCultureIgnoreCase);
                    return url;
                };

                request.PayPalCallbackUrl = adjustUrl("/umbraco/MerchelloSagePay/SagePayApi/PaypalCallback?InvoiceKey={invoiceKey}&PaymentKey={paymentKey}");
            }

            //Optional
            //request.CustomerName = cart.Billing.FirstNames + " " + cart.Billing.Surname;
            //request.CustomerEmail = customer.Email;
            //request.VendorEmail = Settings.VendorEmail;
            //request.SendEmail = Settings.SendEmail;

            //request.EmailMessage = Settings.EmailMessage;
            //request.BillingAddress2 = billingAddress.Address2;
            //request.BillingPostCode = billingAddress.PostalCode;
            //request.BillingState = billingAddress.Region;
            //request.BillingPhone = billingAddress.Phone;
            //request.DeliveryAddress2 = shippingAddress.Address2;
            //request.DeliveryPostCode = shippingAddress.PostalCode;
            //request.DeliveryState = shippingAddress.Region;
            //request.DeliveryPhone = shippingAddress.Phone;

        }
开发者ID:chrisdaaaaay,项目名称:Merchello.Plugins.SagePay,代码行数:82,代码来源:SagePayDirectPaymentProcessor.cs

示例8: ProcessPayment

        /// <summary>
        ///     Processes the Authorize and AuthorizeAndCapture transactions
        /// </summary>
        /// <param name="invoice">The <see cref="IInvoice" /> to be paid</param>
        /// <param name="payment">The <see cref="IPayment" /> record</param>
        /// <param name="transactionMode">Authorize or AuthorizeAndCapture</param>
        /// <param name="amount">The money amount to be processed</param>
        /// <returns>The <see cref="IPaymentResult" /></returns>
        public IPaymentResult ProcessPayment(IInvoice invoice, IPayment payment, TransactionMode transactionMode, decimal amount)
        {
            if (!IsValidCurrencyCode(invoice.CurrencyCode()))
            return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("Invalid currency. Invoice Currency: '{0}'", invoice.CurrencyCode()))), invoice, false);

              if (transactionMode == TransactionMode.Authorize) {

            //var paymentId = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.QuickpayPaymentId);
            var currency = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.PaymentCurrency);
            var amountAuthorizedMinorString = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.PaymentAmount);
            var amountAuthorized = decimal.Parse(amountAuthorizedMinorString) / (IsZeroDecimalCurrency(currency) ? 100 : 1);

            if (invoice.CurrencyCode() != currency) {
              return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("Currency mismatch. Invoice Currency: {0}, Payment Currency: {1}", invoice.CurrencyCode(), currency))), invoice, false);
            }

            if (invoice.Total > amountAuthorized) {
              return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("Amount mismatch. Invoice Amount: {0}, Payment Amount: {1}", invoice.Total.ToString("F2"), amountAuthorized.ToString("F2")))), invoice, false);
            }

            payment.Authorized = true;

            return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, invoice.ShippingLineItems().Any());
              }

              return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("{0}", "QuickPay Payment AuthorizeAndCapture Not Implemented Yet"))), invoice, false);
        }
开发者ID:joelbhansen,项目名称:MerchelloQuickPayProvider,代码行数:35,代码来源:QuickPayPaymentProcessor.cs

示例9: VoidPayment

        public IPaymentResult VoidPayment(IInvoice invoice, IPayment payment)
        {
            var api = new QuickPayApi(_settings.ApiKey);

              var paymentId = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.QuickpayPaymentId);

              try {
            var cancelResult = api.CancelPayment(paymentId);

            if (cancelResult.Accepted && cancelResult.Operations.Any(x => x.Type == "cancel")) {
              LogHelper.Info<QuickPayPaymentProcessor>(string.Format("QuickPay Cancel PaymentId {0} Success:\r\n{1}", paymentId, cancelResult));
              return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, invoice.ShippingLineItems().Any());
            } else {
              LogHelper.Info<QuickPayPaymentProcessor>(string.Format("QuickPay Cancel PaymentId {0} Error:\r\n{1}", paymentId, cancelResult));
              return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("{0}", "QuickPay Cancel Unknown Error"))), invoice, false);
            }
              } catch (Exception x) {
            LogHelper.Error<QuickPayPaymentProcessor>(string.Format("QuickPay Cancel PaymentId {0} Error:\r\n{1}", paymentId, x.Message), x);
            return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("{0}", "QuickPay Cancel Unknown Error"))), invoice, false);
              }
        }
开发者ID:joelbhansen,项目名称:MerchelloQuickPayProvider,代码行数:21,代码来源:QuickPayPaymentProcessor.cs


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