Esempio n. 1
0
        public static webModel.PaymentIn ToWebModel(this coreModel.PaymentIn payment)
        {
            var retVal = new webModel.PaymentIn();

            retVal.InjectFrom(payment);
            retVal.Currency = payment.Currency;


            retVal.ChildrenOperations = payment.GetFlatObjectsListWithInterface <coreModel.IOperation>().Except(new[] { payment }).Select(x => x.ToWebModel()).ToList();

            if (payment.DynamicProperties != null)
            {
                retVal.DynamicProperties = payment.DynamicProperties;
            }

            retVal.PaymentMethod             = new webModel.PaymentMethod();
            retVal.PaymentMethod.Code        = payment.GatewayCode;
            retVal.PaymentMethod.Description = payment.GatewayCode;
            retVal.PaymentMethod.Name        = payment.GatewayCode;

            if (payment.PaymentMethod != null)
            {
                retVal.PaymentMethod = payment.PaymentMethod.ToWebModel();
            }
            return(retVal);
        }
		public static coreModel.PaymentIn ToCoreModel(this webModel.PaymentIn payment)
		{
			var retVal = new coreModel.PaymentIn();
			retVal.InjectFrom(payment);

			if (payment.Properties != null)
				retVal.Properties = payment.Properties.Select(x => x.ToCoreModel()).ToList();

			retVal.Currency = payment.Currency;
			return retVal;
		}
        public static coreModel.PaymentIn ToCoreModel(this webModel.PaymentIn payment)
        {
            var retVal = new coreModel.PaymentIn();

            retVal.InjectFrom(payment);

            if (payment.Properties != null)
            {
                retVal.Properties = payment.Properties.Select(x => x.ToCoreModel()).ToList();
            }

            retVal.Currency = payment.Currency;
            return(retVal);
        }
        public static coreModel.PaymentIn ToCoreModel(this webModel.PaymentIn payment)
        {
            var retVal = new coreModel.PaymentIn();
            retVal.InjectFrom(payment);
            retVal.PaymentStatus = EnumUtility.SafeParse<PaymentStatus>(payment.Status, PaymentStatus.Custom);


            retVal.Currency = payment.Currency;


            if (payment.DynamicProperties != null)
                retVal.DynamicProperties = payment.DynamicProperties;


            return retVal;
        }
        public static PaymentIn ToCoreModel(this PaymentInEntity entity)
        {
            if (entity == null)
                throw new ArgumentNullException("entity");

            var retVal = new PaymentIn();
            retVal.InjectFrom(entity);
            retVal.Currency = (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), entity.Currency);
            retVal.PaymentStatus = EnumUtility.SafeParse<PaymentStatus>(entity.Status, PaymentStatus.Custom);

            if (entity.Addresses != null && entity.Addresses.Any())
            {
                retVal.BillingAddress = entity.Addresses.First().ToCoreModel();
            }
            return retVal;
        }
Esempio n. 6
0
        public static webModel.PaymentIn ToWebModel(this coreModel.PaymentIn payment)
        {
            var retVal = new webModel.PaymentIn();

            retVal.InjectFrom(payment);
            retVal.Currency = payment.Currency;


            retVal.ChildrenOperations = payment.GetFlatObjectsListWithInterface <coreModel.IOperation>().Select(x => x.ToWebModel()).ToList();

            if (payment.DynamicProperties != null)
            {
                retVal.DynamicProperties = payment.DynamicProperties;
            }

            return(retVal);
        }
		public static PaymentIn ToCoreModel(this coreModel.Payment payment)
		{
			if (payment == null)
				throw new ArgumentNullException("payment");

			var retVal = new PaymentIn();
			retVal.InjectFrom(payment);
			retVal.Currency = payment.Currency;
			retVal.GatewayCode = payment.PaymentGatewayCode;
			retVal.Sum = payment.Amount;

			if(payment.BillingAddress != null)
			{
				retVal.BillingAddress = payment.BillingAddress.ToCoreModel();
			}

			return retVal;
		}
Esempio n. 8
0
        public static coreModel.PaymentIn ToCoreModel(this webModel.PaymentIn payment)
        {
            var retVal = new coreModel.PaymentIn();

            retVal.InjectFrom(payment);
            retVal.PaymentStatus = EnumUtility.SafeParse <PaymentStatus>(payment.Status, PaymentStatus.Custom);


            retVal.Currency = payment.Currency;


            if (payment.DynamicProperties != null)
            {
                retVal.DynamicProperties = payment.DynamicProperties;
            }


            return(retVal);
        }
        public static webModel.PaymentIn ToWebModel(this coreModel.PaymentIn payment)
        {
            var retVal = new webModel.PaymentIn();

            retVal.InjectFrom(payment);
            retVal.Currency = payment.Currency;

            retVal.Organization = retVal.OrganizationId;
            retVal.Customer     = retVal.CustomerId;

            if (payment.Properties != null)
            {
                retVal.Properties = payment.Properties.Select(x => x.ToWebModel()).ToList();
            }

            retVal.ChildrenOperations = payment.ChildrenOperations.Select(x => x.ToWebModel()).ToList();

            return(retVal);
        }
        public IHttpActionResult GetNewPayment(string id)
        {
            coreModel.PaymentIn retVal = null;
            var order = _customerOrderService.GetById(id, coreModel.CustomerOrderResponseGroup.Full);

            if (order != null)
            {
                retVal = new coreModel.PaymentIn
                {
                    Id         = Guid.NewGuid().ToString(),
                    Currency   = order.Currency,
                    CustomerId = order.CustomerId
                };
                retVal.Number = _uniqueNumberGenerator.GenerateNumber("PI{0:yyMMdd}-{1:D5}");
                return(Ok(retVal.ToWebModel()));
            }

            return(NotFound());
        }
Esempio n. 11
0
		public static PaymentIn ToCoreModel(this PaymentInEntity entity)
		{
			if (entity == null)
				throw new ArgumentNullException("entity");

			var retVal = new PaymentIn();
			retVal.InjectFrom(entity);
			retVal.Currency = (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), entity.Currency);

			if (entity.Properties != null)
			{
				retVal.Properties = entity.Properties.Select(x => x.ToCoreModel()).ToList();
			}

			if (entity.Addresses != null && entity.Addresses.Any())
			{
				retVal.BillingAddress = entity.Addresses.First().ToCoreModel();
			}
			return retVal;
		}
        public static PaymentIn ToCoreModel(this PaymentInEntity entity, IEnumerable<PaymentMethod> paymentMethods)
        {
            if (entity == null)
                throw new ArgumentNullException("entity");

            var retVal = new PaymentIn();
            retVal.InjectFrom(entity);
            retVal.Currency = entity.Currency;
            retVal.PaymentStatus = EnumUtility.SafeParse<PaymentStatus>(entity.Status, PaymentStatus.Custom);

            if (entity.Addresses != null && entity.Addresses.Any())
            {
                retVal.BillingAddress = entity.Addresses.First().ToCoreModel();
            }

            if (paymentMethods != null)
            {
                retVal.PaymentMethod = paymentMethods.FirstOrDefault(x => String.Equals(x.Code, entity.GatewayCode, StringComparison.InvariantCultureIgnoreCase));
            }

            return retVal;
        }
		private PaymentDetailsType GetPaypalPaymentDetail(CurrencyCodeType currency, PaymentActionCodeType paymentAction, PaymentIn payment)
		{
			var paymentDetails = new PaymentDetailsType { PaymentAction = paymentAction };
			paymentDetails.OrderTotal = new BasicAmountType(currency, FormatMoney(payment.Sum));

			return paymentDetails;
		}
        public IHttpActionResult GetNewPayment(string id)
        {
            var order = _customerOrderService.GetById(id, coreModel.CustomerOrderResponseGroup.Full);
            if (order != null)
            {
                var retVal = new coreModel.PaymentIn
                {
                    Id = Guid.NewGuid().ToString(),
                    Currency = order.Currency,
                    CustomerId = order.CustomerId
                };
                var numberTemplate = _settingManager.GetValue("Order.PaymentInNewNumberTemplate", "PI{0:yyMMdd}-{1:D5}");
                retVal.Number = _uniqueNumberGenerator.GenerateNumber(numberTemplate);
                return Ok(retVal.ToWebModel());
            }

            return NotFound();
        }
		private PaymentDetailsType GetPaypalPaymentDetail(string currency, PaymentActionCodeType paymentAction, PaymentIn payment)
		{
			var paymentDetails = new PaymentDetailsType { PaymentAction = paymentAction };
			paymentDetails.OrderTotal = new BasicAmountType(GetPaypalCurrency(currency), FormatMoney(payment.Sum));
            paymentDetails.ButtonSource = "Virto_SP";

            return paymentDetails;
		}
        public IHttpActionResult GetNewPayment(string id)
        {
            coreModel.PaymentIn retVal = null;
            var order = _customerOrderService.GetById(id, coreModel.CustomerOrderResponseGroup.Full);
            if (order != null)
            {
                retVal = new coreModel.PaymentIn
                {
                    Id = Guid.NewGuid().ToString(),
                    Currency = order.Currency,
                    CustomerId = order.CustomerId
                };
                retVal.Number = _operationNumberGenerator.GenerateNumber(retVal);
                return Ok(retVal.ToWebModel());
            }

            return NotFound();
        }
		private DoCaptureReq GetDoCaptureRequest(PaymentIn payment)
		{
			var retVal = new DoCaptureReq();

			retVal.DoCaptureRequest = new DoCaptureRequestType();
			retVal.DoCaptureRequest.Amount = new BasicAmountType(GetPaypalCurrency(payment.Currency.ToString()), FormatMoney(payment.Sum));
			retVal.DoCaptureRequest.AuthorizationID = payment.OuterId;
			retVal.DoCaptureRequest.CompleteType = CompleteCodeType.COMPLETE;

			return retVal;
		}
		private PayRequest CreatePaypalRequest(CustomerOrder order, PaymentIn payment, string url)
		{
			var receivers = new List<Receiver>();
			receivers.Add(new Receiver { amount = payment.Sum, email = "*****@*****.**", invoiceId = payment.Id });

			PayRequest retVal = new PayRequest
			{
				requestEnvelope = new RequestEnvelope { errorLanguage = "en_US" },
				currencyCode = order.Currency.ToString(),
				receiverList = new ReceiverList(receivers),
				actionType = "PAY",
				cancelUrl = string.Format("{0}/{1}?cancel=true&orderId={2}", url, PaypalPaymentRedirectRelativePath, order.Id) + "&paykey=${paykey}",
				returnUrl = string.Format("{0}/{1}?cancel=false&orderId={2}", url, PaypalPaymentRedirectRelativePath, order.Id) + "&paykey=${paykey}"
			};

			return retVal;
		}
		public PostProcessPaymentEvaluationContext(PaymentIn payment)
		{
			this.Payment = payment;
		}
		private SetExpressCheckoutReq CreatePaypalRequest(CustomerOrder order, Store store, PaymentIn payment)
		{
			var retVal = new SetExpressCheckoutReq();

			var request = new SetExpressCheckoutRequestType();

			var ecDetails = new SetExpressCheckoutRequestDetailsType
			{
				CallbackTimeout = "3",
				ReturnURL = string.Format("{0}/{1}?cancel=false&orderId={2}", store.Url, PaypalPaymentRedirectRelativePath, order.Id),
				CancelURL = string.Format("{0}/{1}?cancel=true&orderId={2}", store.Url, PaypalPaymentRedirectRelativePath, order.Id)
			};

			if (PaypalPaymentModeStoreSetting.Equals("BankCard"))
			{
				ecDetails.SolutionType = SolutionTypeType.SOLE;
				ecDetails.LandingPage = LandingPageType.BILLING;
			}
			else
			{
				ecDetails.SolutionType = SolutionTypeType.MARK;
				ecDetails.LandingPage = LandingPageType.LOGIN;
			}

			var currency = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), order.Currency.ToString());

			var billingAddress = order.Addresses.FirstOrDefault(s => s.AddressType == VirtoCommerce.Domain.Order.Model.AddressType.Billing);

			if (billingAddress != null)
				ecDetails.BuyerEmail = billingAddress.Email;
			else
				billingAddress = order.Addresses.FirstOrDefault();

			if (billingAddress != null && !string.IsNullOrEmpty(billingAddress.Email))
				ecDetails.BuyerEmail = billingAddress.Email;

			ecDetails.PaymentDetails.Add(GetPaypalPaymentDetail(currency, PaymentActionCodeType.SALE, payment));

			request.SetExpressCheckoutRequestDetails = ecDetails;

			retVal.SetExpressCheckoutRequest = request;

			return retVal;
		}
		private RefundTransactionReq GetRefundTransactionRequest(PaymentIn payment)
		{
			var retVal = new RefundTransactionReq();

			retVal.RefundTransactionRequest = new RefundTransactionRequestType();
			retVal.RefundTransactionRequest.TransactionID = payment.OuterId;
			//retVal.RefundTransactionRequest.Amount

			return retVal;
		}
Esempio n. 22
0
        private static CustomerOrder GetTestOrder(string id)
        {
            var order = new CustomerOrder
            {
                Id = id,
                Currency = CurrencyCodes.USD,
                CustomerId = "Test Customer",
                EmployeeId = "employee",
                StoreId = "test store",
                CreatedDate = DateTime.Now,
                Addresses = new []
				{
					new Address {	
					AddressType = AddressType.Shipping, 
					Phone = "+68787687",
					PostalCode = "60602",
					CountryCode = "US",
					CountryName = "United states",
					Email = "*****@*****.**",
					FirstName = "first name",
					LastName = "last name",
					Line1 = "45 Fremont Street",
                    City = "Los Angeles",
                    RegionId = "CA",
					Organization = "org1"
					}
				}.ToList(),
                Discount = new Discount
                {
                    PromotionId = "testPromotion",
                    Currency = CurrencyCodes.USD,
                    DiscountAmount = 12,
                    Coupon = new Coupon
                    {
                        Code = "ssss"
                    }
                }
            };
            var item1 = new LineItem
            {
                BasePrice = 10,
                Price = 20,
                ProductId = "shoes",
                CatalogId = "catalog",
                Currency = CurrencyCodes.USD,
                CategoryId = "category",
                Name = "shoes",
                Quantity = 2,
                ShippingMethodCode = "EMS",
                Discount = new Discount
                {
                    PromotionId = "itemPromotion",
                    Currency = CurrencyCodes.USD,
                    DiscountAmount = 12,
                    Coupon = new Coupon
                    {
                        Code = "ssss"
                    }
                }
            };
            var item2 = new LineItem
            {
                BasePrice = 100,
                Price = 100,
                ProductId = "t-shirt",
                CatalogId = "catalog",
                CategoryId = "category",
                Currency = CurrencyCodes.USD,
                Name = "t-shirt",
                Quantity = 2,
                ShippingMethodCode = "EMS",
                Discount = new Discount
                {
                    PromotionId = "testPromotion",
                    Currency = CurrencyCodes.USD,
                    DiscountAmount = 12,
                    Coupon = new Coupon
                    {
                        Code = "ssss"
                    }
                }
            };
            order.Items = new List<LineItem>();
            order.Items.Add(item1);
            order.Items.Add(item2);

            var shipment = new Shipment
            {
                Currency = CurrencyCodes.USD,
                DeliveryAddress = new Address
                {
                    City = "london",
                    CountryName = "England",
                    Phone = "+68787687",
                    PostalCode = "2222",
                    CountryCode = "ENG",
                    Email = "*****@*****.**",
                    FirstName = "first name",
                    LastName = "last name",
                    Line1 = "line 1",
                    Organization = "org1"
                },
                Discount = new Discount
                {
                    PromotionId = "testPromotion",
                    Currency = CurrencyCodes.USD,
                    DiscountAmount = 12,
                    Coupon = new Coupon
                    {
                        Code = "ssss"
                    }
                }
            };
            order.Shipments = new List<Shipment>();
            order.Shipments.Add(shipment);

            var payment = new PaymentIn
            {
                GatewayCode = "PayPal",
                Currency = CurrencyCodes.USD,
                Sum = 10,
                CustomerId = "et"
            };
            order.InPayments = new List<PaymentIn> { payment };

            return order;
        }