private PaymentPrice GetPaymentPrice(PaymentLookup paymentLookup, Cart cart)
        {
            var paymentMethodId = ParseToInt(paymentLookup.MethodId);
            var paymentMethod   = GetPaymentMethodInternal(paymentMethodId);
            var currency        = GetCurrencyCode(cart.CurrencyCode);

            var price = new PaymentPrice()
            {
                Amount       = paymentMethod.GetFeeForCurrency(currency).Fee,
                CurrencyCode = cart.CurrencyCode,
                LineItemIds  = paymentLookup.LineItemIds,
                MethodId     = paymentLookup.MethodId
            };

            price.SetPropertyValue("FeePercent", paymentMethod.FeePercent);

            return(price);
        }
예제 #2
0
        public override object Clone()
        {
            var result = base.Clone() as ShoppingCart;

            result.HandlingTotal        = HandlingTotal?.Clone() as Money;
            result.HandlingTotalWithTax = HandlingTotalWithTax?.Clone() as Money;
            result.DiscountAmount       = DiscountAmount?.Clone() as Money;
            result.Total                = Total?.Clone() as Money;
            result.SubTotal             = SubTotal?.Clone() as Money;
            result.SubTotalWithTax      = SubTotalWithTax?.Clone() as Money;
            result.ShippingPrice        = ShippingPrice?.Clone() as Money;
            result.ShippingPriceWithTax = ShippingPriceWithTax?.Clone() as Money;
            result.ShippingTotal        = ShippingTotal?.Clone() as Money;
            result.ShippingTotalWithTax = ShippingTotalWithTax?.Clone() as Money;
            result.PaymentPrice         = PaymentPrice?.Clone() as Money;
            result.PaymentPriceWithTax  = PaymentPriceWithTax?.Clone() as Money;
            result.PaymentTotal         = PaymentTotal?.Clone() as Money;
            result.PaymentTotalWithTax  = PaymentTotalWithTax?.Clone() as Money;
            result.HandlingTotal        = HandlingTotal?.Clone() as Money;
            result.HandlingTotalWithTax = HandlingTotalWithTax?.Clone() as Money;
            result.DiscountTotal        = DiscountTotal?.Clone() as Money;
            result.DiscountTotalWithTax = DiscountTotalWithTax?.Clone() as Money;
            result.TaxTotal             = TaxTotal?.Clone() as Money;

            if (Discounts != null)
            {
                result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount));
            }
            if (TaxDetails != null)
            {
                result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail));
            }
            if (DynamicProperties != null)
            {
                result.DynamicProperties = new List <DynamicProperty>(DynamicProperties.Select(x => x.Clone() as DynamicProperty));
            }
            if (ValidationErrors != null)
            {
                result.ValidationErrors = new List <ValidationError>(ValidationErrors.Select(x => x.Clone() as ValidationError));
            }
            if (Addresses != null)
            {
                result.Addresses = new List <Address>(Addresses.Select(x => x.Clone() as Address));
            }
            if (Items != null)
            {
                result.Items = new List <LineItem>(Items.Select(x => x.Clone() as LineItem));
            }
            if (Payments != null)
            {
                result.Payments = new List <Payment>(Payments.Select(x => x.Clone() as Payment));
            }
            if (Shipments != null)
            {
                result.Shipments = new List <Shipment>(Shipments.Select(x => x.Clone() as Shipment));
            }
            if (Coupons != null)
            {
                result.Coupons = new List <Coupon>(Coupons.Select(x => x.Clone() as Coupon));
            }
            if (AvailablePaymentMethods != null)
            {
                result.AvailablePaymentMethods = new List <PaymentMethod>(AvailablePaymentMethods.Select(x => x.Clone() as PaymentMethod));
            }

            return(result);
        }
예제 #3
0
 public void MergeFrom(OnlineOrderResponse other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Id.Length != 0)
     {
         Id = other.Id;
     }
     if (other.Loading != false)
     {
         Loading = other.Loading;
     }
     if (other.OfflineFulfillment != false)
     {
         OfflineFulfillment = other.OfflineFulfillment;
     }
     if (other.TrainDescription.Length != 0)
     {
         TrainDescription = other.TrainDescription;
     }
     if (other.railway_ != null)
     {
         if (railway_ == null)
         {
             Railway = new global::G2Rail.Protobuf.Railway();
         }
         Railway.MergeFrom(other.Railway);
     }
     if (other.from_ != null)
     {
         if (from_ == null)
         {
             From = new global::G2Rail.Protobuf.Station();
         }
         From.MergeFrom(other.From);
     }
     if (other.to_ != null)
     {
         if (to_ == null)
         {
             To = new global::G2Rail.Protobuf.Station();
         }
         To.MergeFrom(other.To);
     }
     if (other.Departure.Length != 0)
     {
         Departure = other.Departure;
     }
     if (other.Arrival.Length != 0)
     {
         Arrival = other.Arrival;
     }
     if (other.ticketPrice_ != null)
     {
         if (ticketPrice_ == null)
         {
             TicketPrice = new global::G2Rail.Protobuf.Price();
         }
         TicketPrice.MergeFrom(other.TicketPrice);
     }
     if (other.paymentPrice_ != null)
     {
         if (paymentPrice_ == null)
         {
             PaymentPrice = new global::G2Rail.Protobuf.Price();
         }
         PaymentPrice.MergeFrom(other.PaymentPrice);
     }
     if (other.chargingPrice_ != null)
     {
         if (chargingPrice_ == null)
         {
             ChargingPrice = new global::G2Rail.Protobuf.Price();
         }
         ChargingPrice.MergeFrom(other.ChargingPrice);
     }
     if (other.rebateAmount_ != null)
     {
         if (rebateAmount_ == null)
         {
             RebateAmount = new global::G2Rail.Protobuf.Price();
         }
         RebateAmount.MergeFrom(other.RebateAmount);
     }
     trains_.Add(other.trains_);
     passengers_.Add(other.passengers_);
     tickets_.Add(other.tickets_);
     records_.Add(other.records_);
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
예제 #4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (Loading != false)
            {
                hash ^= Loading.GetHashCode();
            }
            if (OfflineFulfillment != false)
            {
                hash ^= OfflineFulfillment.GetHashCode();
            }
            if (TrainDescription.Length != 0)
            {
                hash ^= TrainDescription.GetHashCode();
            }
            if (railway_ != null)
            {
                hash ^= Railway.GetHashCode();
            }
            if (from_ != null)
            {
                hash ^= From.GetHashCode();
            }
            if (to_ != null)
            {
                hash ^= To.GetHashCode();
            }
            if (Departure.Length != 0)
            {
                hash ^= Departure.GetHashCode();
            }
            if (Arrival.Length != 0)
            {
                hash ^= Arrival.GetHashCode();
            }
            if (ticketPrice_ != null)
            {
                hash ^= TicketPrice.GetHashCode();
            }
            if (paymentPrice_ != null)
            {
                hash ^= PaymentPrice.GetHashCode();
            }
            if (chargingPrice_ != null)
            {
                hash ^= ChargingPrice.GetHashCode();
            }
            if (rebateAmount_ != null)
            {
                hash ^= RebateAmount.GetHashCode();
            }
            hash ^= trains_.GetHashCode();
            hash ^= passengers_.GetHashCode();
            hash ^= tickets_.GetHashCode();
            hash ^= records_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }