Inheritance: System.Web.UI.Page
Esempio n. 1
0
 public void ExampleMethod()
 {
     IPaymentGateway <Foo> paypal = new PayPal <Foo>();
     var name            = paypal.Name;
     Foo paymentRequest  = paypal.CreatePaymentRequest(new PaymentRequest());
     var paymentResponse = paypal.ProcessPaymentResponse(new Foo());
 }
        public PayPal<Payment> Get(String paymentCode)
        {
            PayPal<Payment> paypal = new PayPal<Payment>();

            try
            {
                PaymentRepository paymentRepository = new PaymentRepository();
                paypal.Object = paymentRepository.Get(paymentCode);
                return paypal;
            }
            catch (PayPal.HttpException he)
            {
                //{"name":"INVALID_RESOURCE_ID","message":"The requested resource ID was not found","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID","debug_id":"e035690ac842e"}
                if (he.Response.Contains("INVALID_RESOURCE_ID"))
                {
                    paypal.Validations.Add("paymentCode", "Invalid ID");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return paypal;
        }
Esempio n. 3
0
        public void AddOrders()
        {
            List <Order> pendingOrders = OrderService.GetOrders(StatusID: (int)Beasts.Model.Status.Pending).ToList();

            foreach (Order order in pendingOrders)
            {
                try
                {
                    if (PayPal.CheckSale(order.PaypalSaleID))
                    {
                        AddOrderRequest addOrderRequest = Mapper.Map <AddOrderRequest>(order);

                        AddOrderResponse addOrderResponse = client.AddOrder(addOrderRequest);

                        if (addOrderResponse.Result == 1 && addOrderResponse.Order != null)
                        {
                            order.PrintAuraID = addOrderResponse.Order.OrderId;
                            order.Status      = Beasts.Model.Status.Processing;
                            OrderService.UpdateOrder(order);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ExceptionService.CreateException(ex);
                }
            }
        }
Esempio n. 4
0
		public PayPalManager (Context context, PayPal.Forms.Abstractions.PayPalConfiguration xfconfig)
		{
			Context = context;

			switch (xfconfig.Environment) {
			case PayPal.Forms.Abstractions.Enum.Environment.NoNetwork:
				CONFIG_ENVIRONMENT = PayPalConfiguration.EnvironmentNoNetwork;
				break;
			case PayPal.Forms.Abstractions.Enum.Environment.Production:
				CONFIG_ENVIRONMENT = PayPalConfiguration.EnvironmentProduction;
				break;
			case PayPal.Forms.Abstractions.Enum.Environment.Sandbox:
				CONFIG_ENVIRONMENT = PayPalConfiguration.EnvironmentSandbox;
				break;
			}

			CONFIG_CLIENT_ID = xfconfig.PayPalKey;

			config = new PayPalConfiguration ()
				.Environment (CONFIG_ENVIRONMENT)
				.ClientId (CONFIG_CLIENT_ID)
				.AcceptCreditCards (xfconfig.AcceptCreditCards)
			// The following are only used in PayPalFuturePaymentActivity.
				.MerchantName (xfconfig.MerchantName)
				.MerchantPrivacyPolicyUri (global::Android.Net.Uri.Parse (xfconfig.MerchantPrivacyPolicyUri))
				.MerchantUserAgreementUri (global::Android.Net.Uri.Parse (xfconfig.MerchantUserAgreementUri));

			Intent intent = new Intent (Context, typeof(PayPalService));
			intent.PutExtra (PayPalService.ExtraPaypalConfiguration, config);
			Context.StartService (intent);
		}
        public IHttpActionResult PostPaypal(PayPal paypal)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            try
            {
                PayPal t = new PayPal();
                t.CreateTime   = paypal.CreateTime;
                t.CurrencyCode = paypal.CurrencyCode;
                t.PayementId   = paypal.PayementId;
                t.PayerEmail   = paypal.PayerEmail;
                t.PayerName    = paypal.PayerName;
                t.PayerSurname = paypal.PayerSurname;
                t.Value        = paypal.Value;



                unitOfWork.PayPals.Add(t);
                unitOfWork.Complete();
                return(Ok(t.Id));
            }
            catch (Exception ex)
            {
                return(NotFound());
            }
        }
        public ActionResult Index(CheckoutShippingViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.quote = GetQuote();

                Mapper.CreateMap <CheckoutShippingViewModel, Address>();

                if (model.quote.Address == null)
                {
                    AddressService.CreateAddress(model.quote.QuoteID, Mapper.Map <Address>(model));
                }
                else
                {
                    Address UpdatedAddress = Mapper.Map <Address>(model);
                    UpdatedAddress.AddressID = model.quote.Address.AddressID;
                    AddressService.UpdateAddress(UpdatedAddress);
                }

                Quote quote = GetQuote();
                quote.ShippingCharge = quote.CalculateShipping();
                QuoteService.UpdateQuote(quote);

                string URL = PayPal.ConfirmSale(GetQuote());

                return(Redirect(URL));
            }

            return(Index());
        }
Esempio n. 7
0
        public PayPal <Payment> Get(String paymentCode)
        {
            PayPal <Payment> paypal = new PayPal <Payment>();

            try
            {
                PaymentRepository paymentRepository = new PaymentRepository();
                paypal.Object = paymentRepository.Get(paymentCode);
                return(paypal);
            }
            catch (PayPal.HttpException he)
            {
                //{"name":"INVALID_RESOURCE_ID","message":"The requested resource ID was not found","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID","debug_id":"e035690ac842e"}
                if (he.Response.Contains("INVALID_RESOURCE_ID"))
                {
                    paypal.Validations.Add("paymentCode", "Invalid ID");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(paypal);
        }
Esempio n. 8
0
        public Response <PayPal.Api.Payment> GetPayment(String codePayment)
        {
            Response <PayPal.Api.Payment> response = null;
            PaymentBusiness paymentBusiness        = null;

            try
            {
                paymentBusiness = new PaymentBusiness();
                PayPal <PayPal.Api.Payment> paypal = paymentBusiness.Get(codePayment);

                if (paypal.IsValid)
                {
                    response = new Response <PayPal.Api.Payment>(paypal.Object, ResponseStatus.Success, "Success");
                }
                else
                {
                    response             = new Response <PayPal.Api.Payment>(paypal.Object, ResponseStatus.ErrorValidation, "Success");
                    response.Validations = paypal.Validations;
                }
            }
            catch (Exception ex)
            {
                response = new Response <PayPal.Api.Payment>(null, ResponseStatus.Error, ex.Message);
            }

            return(response);
        }
Esempio n. 9
0
        public IHttpActionResult PutPayPal(int id, PayPal payPal)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != payPal.Id)
            {
                return(BadRequest());
            }

            db.Entry(payPal).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PayPalExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 10
0
        public async Task IncluiPagamentoPayPalAsync(PayPal pagamentoPayPal)
        {
            await ValidaPagamento(pagamentoPayPal);

            ValidationHelper.ThrowValidationExceptionIfNotValid(pagamentoPayPal);

            await pagamentoWriteOnlyRepository.IncluiPagamentoPayPalAsync(pagamentoPayPal);
        }
Esempio n. 11
0
        static void Main()
        {
            Console.WriteLine("hello world");

            PayPal.Pay(100);
            PayPal.Pay(50);
            PayPal.Pay(250);
        }
Esempio n. 12
0
        public ActionResult ValidateCommand(string product, string totalPrice)
        {
            bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["IsSandbox"]);
            var  paypal     = new PayPal(useSandbox);

            paypal.item_name = product;
            paypal.amount    = totalPrice;
            return(View(paypal));
        }
Esempio n. 13
0
        public void DeveRetornarSucessoQuandoAssinaturaNaoEstiverAtiva()
        {
            var pagamento = new PayPal("12345678", DateTime.Now, DateTime.Now.AddDays(6), 10, 10, "O Proprio", documento, endereco, email);

            assinatura.AdicionarPagamento(pagamento);
            estudante.AdicionarAssinatura(assinatura);

            Assert.IsTrue(estudante.Valid);
        }
Esempio n. 14
0
        static async Task Main(string[] args)
        {
            Console.Write("Enter clienId:");
            var clientId = Console.ReadLine();

            Console.Write("Enter SecretKey:");
            var secret = Console.ReadLine();


            var model = new PayPalCreateOrderModel
            {
                intent         = "SALE",
                purchase_units = new List <PurchaseUnit>
                {
                    new PurchaseUnit
                    {
                        reference_id = Guid.NewGuid().ToString(),
                        description  = "Test paypal",
                        amount       = new Amount
                        {
                            currency = "USD",
                            total    = $"10",
                            details  = new Details
                            {
                                subtotal = $"10",
                                shipping = "0",
                                tax      = $"0"
                            }
                        },
                        items = new List <Item>
                        {
                            new Item
                            {
                                currency = "USD",
                                name     = $"Test Item",
                                price    = $"10",
                                tax      = "0",
                                quantity = "1"
                            }
                        },
                    }
                },
                redirect_urls = new RedirectUrls
                {
                    cancel_url = "",
                    return_url = ""
                }
            };


            var paypal = new PayPal(clientId, secret, "Sandbox");
            await paypal.CreatePayment(model);

            Console.WriteLine("Hello World!");
            Console.ReadKey();
        }
Esempio n. 15
0
    public ActionResult Pay()
    {
        PayPalRedirect redirect = PayPal.ExpressCheckout(new PayPalOrder {
            Amount = 50
        });

        Session["token"] = redirect.Token;

        return(new RedirectResult(redirect.Url));
    }
Esempio n. 16
0
        public IHttpActionResult GetPayPal(int id)
        {
            PayPal payPal = db.PayPals.Find(id);

            if (payPal == null)
            {
                return(NotFound());
            }

            return(Ok(payPal));
        }
Esempio n. 17
0
        public IHttpActionResult PostPayPal(PayPal payPal)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PayPals.Add(payPal);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = payPal.Id }, payPal));
        }
        private void MapPayPalPayments()
        {
            try
            {
                if (PayPalPayments.Count != 0)
                {
                    foreach (var pp in PayPalPayments)
                    {
                        var nPayment = new Payment
                        {
                            PaymentMethod   = 1,
                            PaymentApproved = true,
                            ApprovalDate    = pp.payment_date
                        };

                        var nPay = new PayPal()
                        {
                            mc_fee           = pp.mc_fee,
                            mc_gross         = pp.mc_gross,
                            parent_txn_id    = pp.parent_txn_id,
                            payment_date     = pp.payment_date,
                            payment_status   = pp.payment_status,
                            PayPal_post_vars = pp.PayPal_post_vars,
                            pending_reason   = pp.pending_reason,
                            reason_code      = pp.reason_code,
                            SourceIP         = pp.SourceIP,
                            txn_id           = pp.txn_id
                        };

                        var sub = new Subscription
                        {
                            ApplicationId    = applicationId,
                            UserId           = UserId,
                            UserType         = UserType,
                            SubscriptionType = GetSubscriptionType((byte)pp.MonthsPurchased),
                            SubscriptionDate = pp.Date,
                            ExpirationDate   = pp.Date.AddMonths(pp.MonthsPurchased),
                            InstitutionId    = institutionId
                        };

                        nPayment.PayPal = nPay;
                        sub.Payment     = nPayment;

                        subscriptions.Add(sub);
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error mapping PayPal payments.", e);
            }
        }
Esempio n. 19
0
        public async Task <IActionResult> PrepareOrder()
        {
            if (!signInManager.IsSignedIn(User))
            {
                return(Redirect("/account/login"));
            }

            var model     = new PrepareProductViewModel();
            var countries = await shippingPriceCrud.GetAll();

            ViewData["Countries"] = new SelectList(countries.OrderBy(m => m.Country), "Id", "Country");

            var user = await userManager.GetUserAsync(User);

            var carts = await context.Carts.Where(m => m.UserId.Equals(user.Id))
                        .Include(m => m.Product).ThenInclude(m => m.Images).ToListAsync();

            List <Models.Product.Product> products = new List <Models.Product.Product>();

            foreach (var item in carts)
            {
                products.Add(await productCrud.GetById(m => m.Id == item.ProductId));
                model.TotalPrice += item.TotalPrice;
                model.Quantity.Add(item.Quantity);
            }


            if (products.Count() == 0)
            {
                return(RedirectToAction("Index", "Cart"));
            }

            model.Products    = products;
            model.FirstName   = user.FirstName;
            model.LastName    = user.LastName;
            model.Email       = user.Email;
            model.PhoneNumber = user.PhoneNumber;

            PaymentSetting paymentCredential = await context.PaymentManages.FirstOrDefaultAsync();

            PayPal paypal = new PayPal(httpContextAccessor, context, paymentCredential.IsLive);

            ViewData["OrderId"] = await paypal.CreateOrder(decimal.Round(model.TotalPrice, 2, MidpointRounding.AwayFromZero), "GBP");

            ViewData["ClientId"]    = paymentCredential.ClientId;
            ViewData["ClientToken"] = HttpContext.Request.Cookies["client_token"] ?? await paypal.GenerateClientToken();

            ViewData["Currency"] = "GBP";

            return(View(model));
        }
Esempio n. 20
0
        public IHttpActionResult DeletePayPal(int id)
        {
            PayPal payPal = db.PayPals.Find(id);

            if (payPal == null)
            {
                return(NotFound());
            }

            db.PayPals.Remove(payPal);
            db.SaveChanges();

            return(Ok(payPal));
        }
Esempio n. 21
0
        public async Task <string> TokenizePayPal()
        {
            payTcs = new TaskCompletionSource <string>();
            if (isReady)
            {
                mBraintreeFragment.AddListener(this);
                PayPal.RequestOneTimePayment(mBraintreeFragment, new PayPalRequest());
            }
            else
            {
                OnTokenizationError?.Invoke(this, "Platform is not ready to accept payments");
                payTcs.TrySetException(new System.Exception("Platform is not ready to accept payments"));
            }

            return(await payTcs.Task);
        }
Esempio n. 22
0
		public PayPalManager(PayPal.Forms.Abstractions.PayPalConfiguration xfconfig)
		{
			NSString key = null;
			NSString value = new NSString (xfconfig.PayPalKey);
			string env = string.Empty;
			switch (xfconfig.Environment) {
			case PayPal.Forms.Abstractions.Enum.Environment.NoNetwork:
				key = Constants.PayPalEnvironmentNoNetwork;
				env = Constants.PayPalEnvironmentNoNetwork.ToString ();
				break;
				case PayPal.Forms.Abstractions.Enum.Environment.Production:
				key = Constants.PayPalEnvironmentProduction;
				env = Constants.PayPalEnvironmentProduction.ToString ();
				break;
				case PayPal.Forms.Abstractions.Enum.Environment.Sandbox:
				key = Constants.PayPalEnvironmentSandbox;
				env = Constants.PayPalEnvironmentSandbox.ToString ();
				break;
			}

			PayPalMobile.InitializeWithClientIdsForEnvironments (NSDictionary.FromObjectsAndKeys (
				new NSObject[] {
					value,
					value,
					value
				}, new NSObject[] {
					key,
					Constants.PayPalEnvironmentProduction,
					Constants.PayPalEnvironmentSandbox
				}
			));

			Environment = env;

			_payPalConfig = new PayPalConfiguration ();
			AcceptCreditCards = xfconfig.AcceptCreditCards;

			// Set up payPalConfig
			_payPalConfig.MerchantName = xfconfig.MerchantName;
			_payPalConfig.MerchantPrivacyPolicyURL = new NSUrl (xfconfig.MerchantPrivacyPolicyUri);
			_payPalConfig.MerchantUserAgreementURL = new NSUrl (xfconfig.MerchantUserAgreementUri);
			_payPalConfig.LanguageOrLocale = NSLocale.PreferredLanguages [0];
			_payPalConfig.PayPalShippingAddressOption = PayPalShippingAddressOption.PayPal;

			Debug.WriteLine ("PayPal iOS SDK Version: " + PayPalMobile.LibraryVersion);
		}
Esempio n. 23
0
        public Response<PayPal.Api.Payment> CreatePayment(PayPal.Api.Payment payment)
        {
            Response<PayPal.Api.Payment> response = null;
            PaymentBusiness paymentBusiness = null;
            PayPal<PayPal.Api.Payment> paypal = null;
            try
            {
                paymentBusiness = new PaymentBusiness();
                paypal = paymentBusiness.Create(payment);
                response = new Response<PayPal.Api.Payment>(paypal.Object, ResponseStatus.Success, "Success");
            }
            catch (Exception ex)
            {
                response = new Response<PayPal.Api.Payment>(null, ResponseStatus.Error, ex.Message);
            }

            return response;
        }
        public PayPal <CreditCard> Create(CreditCard creditCard)
        {
            PayPal <CreditCard> paypal = new PayPal <CreditCard>();

            try
            {
                creditCard = new CreditCard()
                {
                    number          = "4032035304110067",
                    type            = "visa",
                    expire_month    = 11,
                    expire_year     = 2020,
                    cvv2            = "4960",
                    first_name      = "Rafael",
                    last_name       = "Aguiar",
                    billing_address = new Address()
                    {
                        phone        = "1231231",
                        line1        = "1 First Street",
                        city         = "Saratoga",
                        state        = "CA",
                        postal_code  = "95070",
                        country_code = "US"
                    }
                };

                paypal.Object = creditCard;

                return(paypal);
            }
            catch (PayPal.HttpException he)
            {
                if (he.Response.Contains("INVALID_RESOURCE_ID"))
                {
                    paypal.Validations.Add("paymentCode", "Invalid ID");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(paypal);
        }
        public PayPal<CreditCard> Create(CreditCard creditCard)
        {
            PayPal<CreditCard> paypal = new PayPal<CreditCard>();

            try
            {
                creditCard = new CreditCard()
                {
                    number = "4032035304110067",
                    type = "visa",
                    expire_month = 11,
                    expire_year = 2020,
                    cvv2 = "4960",
                    first_name = "Rafael",
                    last_name = "Aguiar",
                    billing_address = new Address()
                    {
                        phone = "1231231",
                        line1 = "1 First Street",
                        city = "Saratoga",
                        state = "CA",
                        postal_code = "95070",
                        country_code = "US"
                    }
                };

                paypal.Object = creditCard;

                return paypal;
            }
            catch (PayPal.HttpException he)
            {
                if (he.Response.Contains("INVALID_RESOURCE_ID"))
                {
                    paypal.Validations.Add("paymentCode", "Invalid ID");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return paypal;
        }
Esempio n. 26
0
        public Response<PayPal.Api.CreditCard> CreateCreditCard(PayPal.Api.CreditCard creditCard)
        {
            Response<CreditCard> response = null;
            CreditCardBusiness creditCardBusiness = null;
            PayPal<CreditCard> paypal = null;

            try
            {
                creditCardBusiness = new CreditCardBusiness();
                paypal = creditCardBusiness.Create(creditCard);
                response = new Response<CreditCard>(creditCard, ResponseStatus.Success, "Success");
            }
            catch (Exception ex)
            {
                response = new Response<CreditCard>(null, ResponseStatus.Error, ex.Message);
            }

            return response;
        }
Esempio n. 27
0
        public Response <PayPal.Api.CreditCard> CreateCreditCard(PayPal.Api.CreditCard creditCard)
        {
            Response <CreditCard> response           = null;
            CreditCardBusiness    creditCardBusiness = null;
            PayPal <CreditCard>   paypal             = null;

            try
            {
                creditCardBusiness = new CreditCardBusiness();
                paypal             = creditCardBusiness.Create(creditCard);
                response           = new Response <CreditCard>(creditCard, ResponseStatus.Success, "Success");
            }
            catch (Exception ex)
            {
                response = new Response <CreditCard>(null, ResponseStatus.Error, ex.Message);
            }

            return(response);
        }
Esempio n. 28
0
        public Response <PayPal.Api.Payment> CreatePayment(PayPal.Api.Payment payment)
        {
            Response <PayPal.Api.Payment> response      = null;
            PaymentBusiness             paymentBusiness = null;
            PayPal <PayPal.Api.Payment> paypal          = null;

            try
            {
                paymentBusiness = new PaymentBusiness();
                paypal          = paymentBusiness.Create(payment);
                response        = new Response <PayPal.Api.Payment>(paypal.Object, ResponseStatus.Success, "Success");
            }
            catch (Exception ex)
            {
                response = new Response <PayPal.Api.Payment>(null, ResponseStatus.Error, ex.Message);
            }

            return(response);
        }
Esempio n. 29
0
        public ActionResult Order()
        {
            if (Session["cart"] != null)
            {
                double         total = 0.0;
                List <Product> list  = Session["cart"] as List <Product>;
                foreach (var item in list)
                {
                    total += item.ourPrice;
                }

                Order order = new Order()
                {
                    Date  = DateTime.Now,
                    Total = total
                };

                orderManager.Create(order);

                var result = orderManager.FindAll();
                var id     = (from ids in result.Data orderby ids.Id descending select ids.Id).FirstOrDefault();


                foreach (var item in list)
                {
                    orderItemManager.Create(new OrderItem()
                    {
                        OrderId = id, ProductId = item.id
                    });
                }

                bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["IsSandbox"]);
                var  paypal     = new PayPal(useSandbox);

                //paypal.item_name = product;
                paypal.amount = total;
                return(View("ValidateCommand", paypal));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 30
0
        public override IPaymentGateway CreatePaymentGateway(PaymentMethod paymentMethod, Product product)
        {
            IPaymentGateway gateway = null;

            switch (paymentMethod)
            {
            case PaymentMethod.PayPal:
                gateway = new PayPal();
                break;

            case PaymentMethod.BillDesk:
                gateway = new BillDesk();
                break;

            default:
                gateway = base.CreatePaymentGateway(paymentMethod, product);
                break;
            }

            return(gateway);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="title"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        public ActionResult PostToPayPal(string id, string title, string amount)
        {
            PayPal paypal = new PayPal();

            paypal.cmd = "_xclick";

            //bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSandbox"]);
#if DEBUG
            bool useSandbox = true;
#else
            bool useSandbox = false;
#endif
            ebookVM             = new ebookViewModel(id, title, amount);
            ebookVM.previousURL = HttpContext.Request.UrlReferrer;      // save this for redirect if cancel, etc.

            if (useSandbox)
            {
                paypal.business   = ConfigurationManager.AppSettings["LocalBusinessAccountKey"];
                ViewBag.actionURL = ConfigurationManager.AppSettings["PPSandbox"];

                paypal.cancel_return = ConfigurationManager.AppSettings["LocalCancelURL"];
                paypal.@return       = ConfigurationManager.AppSettings["LocalReturnURL"];
                paypal.notify_url    = ConfigurationManager.AppSettings["LocalNotifyURL"];
            }
            else
            {
                paypal.business   = ConfigurationManager.AppSettings["BusinessAccountKey"];
                ViewBag.actionURL = ConfigurationManager.AppSettings["PPProduction"];

                paypal.cancel_return = ConfigurationManager.AppSettings["CancelURL"];
                paypal.@return       = ConfigurationManager.AppSettings["ReturnURL"];
                paypal.notify_url    = ConfigurationManager.AppSettings["NotifyURL"];
            }

            paypal.currency_code = ConfigurationManager.AppSettings["CurrencyCode"];
            paypal.item_name     = title;
            paypal.amount        = amount;

            return(View(paypal));
        }
        public async Task <PaymentMethodNonce> AuthorizePaypalPaymentAsync(bool requestBillingAgreement, string[] additionalParameters = null, PayPalRequest request = null)
        {
            var actionListener = new PaymentMethodNonceListener();

            try
            {
                AddListener(actionListener);

                PayPal.AuthorizeAccount(this, additionalParameters);

                if (requestBillingAgreement)
                {
                    PayPal.RequestBillingAgreement(this, request ?? new PayPalRequest());
                }

                return(await actionListener.Task());
            }
            finally
            {
                RemoveListener(actionListener);
            }
        }
Esempio n. 33
0
        public IPayment GetPayment(PaymentType type)
        {
            IPayment payment = null;

            switch (type)
            {
            case PaymentType.CreditCard:
                payment = new CreditCard();
                break;

            case PaymentType.Cash:
                payment = new Cash();
                break;

            case PaymentType.BankTransfer:
                payment = new BankTransfer();
                break;

            case PaymentType.Paypal:
                payment = new PayPal();
                break;
            }
            return(payment);
        }
        public static void  initLibrary(View view)
        {
            View v = view;

            if (v == null)
            {
                v = ApplicationActivity.MainView;
            }

            if (v == null)
            {
                ConsoleMessage c = new ConsoleMessage("ERROR in initLibrary: MainView is null", "ERROR", 0, ConsoleMessage.MessageLevel.ERROR);
                return;
            }

            // This is the main initialization call that takes in your Context, the Application ID, the server you would like to connect to, and your PayPalListener
            PayPal.fetchDeviceReferenceTokenWithAppID(v.getContext(), appID, server, new ResultDelegate());



            // -- These are required settings.
            PayPal.getInstance().setLanguage("en_US"); // Sets the language for the library.
            // --
        }
 private void SavePayPalInvoice(Guid reconnectToOurBuyer,
         PayPal.Api.Payments.Payment createdInvoice)
 {
     // we will retrieve this so that PayPal can apply,
     // i.e., "execute", the invoice that the customer
     // has approved.  For this example, we are using
     // Entity Framework 6.0.2 with Code First.
     TinyInvoice invoiceToSave              = new TinyInvoice();
     invoiceToSave.ReconnectToOurBuyer      = reconnectToOurBuyer;
     invoiceToSave.PayPalPayment_Identifier = createdInvoice.id;
     using (ArgumentsPlus.Controllers.ArgumentPlusContext
            argumentsPlusDb
            = new ArgumentPlusContext())
     {
         argumentsPlusDb.TinyInvoices.Add(invoiceToSave);
         argumentsPlusDb.SaveChanges();
     }
 }
Esempio n. 36
0
		public void BuyItem(
			PayPal.Forms.Abstractions.PayPalItem item,
			Deveel.Math.BigDecimal xftax,
			Action onCancelled,
			Action<string> onSuccess,
			Action<string> onError
		){

			OnCancelled = onCancelled;
			OnSuccess = onSuccess;
			OnError = onError;

			NSDecimalNumber amount = new NSDecimalNumber (DoFormat (item.Price.ToDouble ())).Add (new NSDecimalNumber (DoFormat (xftax.ToDouble ())));

			var paymentDetails = PayPalPaymentDetails.PaymentDetailsWithSubtotal (amount, new NSDecimalNumber(0), new NSDecimalNumber (xftax.ToString ()));

			var payment = PayPalPayment.PaymentWithAmount (amount, item.Currency, item.Name, PayPalPaymentIntent.Sale);
			payment.PaymentDetails = paymentDetails;
			payment.Items = new NSObject[]{
				PayPalItem.ItemWithName (
					item.Name,
					1,
					new  NSDecimalNumber (item.Price.ToString ()),
					item.Currency,
					item.SKU
				)
			};
			if (payment.Processable) {
				var paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, this);
				var top = GetTopViewController (UIApplication.SharedApplication.KeyWindow);
				top.PresentViewController (paymentViewController, true, null);
			}else {
				OnError?.Invoke ("This particular payment will always be processable. If, for example, the amount was negative or the shortDescription was empty, this payment wouldn't be processable, and you'd want to handle that here.");
				OnError = null;
				Debug.WriteLine("Payment not processalbe:"+payment.Items);
			}
		}
Esempio n. 37
0
        public void BuyItems(
            PayPal.Forms.Abstractions.PayPalItem[] items,
            Decimal xfshipping,
            Decimal xftax,
            Action onCancelled,
            Action<string> onSuccess,
            Action<string> onError,
            PayPal.Forms.Abstractions.ShippingAddress address
        )
        {

            OnCancelled = onCancelled;
            OnSuccess = onSuccess;
            OnError = onError;

            List<PayPalItem> nativeItems = new List<PayPalItem>();
            foreach (var product in items)
            {
                nativeItems.Add(PayPalItem.ItemWithName(
                    product.Name,
                    (nuint)product.Quantity,
                    new NSDecimalNumber(RoundNumber((double)product.Price)),
                    product.Currency,
                    product.SKU)
                );
            }

            var subtotal = PayPalItem.TotalPriceForItems(nativeItems.ToArray());

            var shipping = new NSDecimalNumber(RoundNumber((double)xfshipping));
            var tax = new NSDecimalNumber(RoundNumber((double)xftax));
            var paymentDetails = PayPalPaymentDetails.PaymentDetailsWithSubtotal(subtotal, shipping, tax);

            var total = subtotal.Add(shipping).Add(tax);

            var payment = PayPalPayment.PaymentWithAmount(total, nativeItems.FirstOrDefault().Currency, "Multiple items", PayPalPaymentIntent.Sale);
            payment.Items = nativeItems.ToArray();
            payment.PaymentDetails = paymentDetails;

            if (address != null)
            {
                payment.ShippingAddress = PayPalShippingAddress.ShippingAddressWithRecipientName(
                    address.RecipientName,
                    address.Line1,
                    address.Line2,
                    address.City,
                    address.State,
                    address.PostalCode,
                    address.CountryCode
                );
            }

            if (payment.Processable)
            {
                var paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, this);
                var top = GetTopViewController(UIApplication.SharedApplication.KeyWindow);
                top.PresentViewController(paymentViewController, true, null);
            }
            else {
                OnError?.Invoke("This particular payment will always be processable. If, for example, the amount was negative or the shortDescription was empty, this payment wouldn't be processable, and you'd want to handle that here.");
                Debug.WriteLine("Payment not processalbe:" + payment.Items);
            }

        }
Esempio n. 38
0
        public void BuyItem(
            PayPal.Forms.Abstractions.PayPalItem item,
            Decimal xftax,
            Action onCancelled,
            Action<string> onSuccess,
            Action<string> onError,
            PayPal.Forms.Abstractions.ShippingAddress address
        )
        {

            OnCancelled = onCancelled;
            OnSuccess = onSuccess;
            OnError = onError;


            var subTotal = new NSDecimalNumber(RoundNumber((double)item.Price));
            NSDecimalNumber amount = subTotal.Add(new NSDecimalNumber(RoundNumber((double)xftax)));

            var paymentDetails = PayPalPaymentDetails.PaymentDetailsWithSubtotal(subTotal, new NSDecimalNumber(0), new NSDecimalNumber(RoundNumber((double)xftax)));

            var payment = PayPalPayment.PaymentWithAmount(amount, item.Currency, item.Name, PayPalPaymentIntent.Sale);
            payment.PaymentDetails = paymentDetails;
            payment.Items = new NSObject[]{
                PayPalItem.ItemWithName (
                    item.Name,
                    1,
                    new  NSDecimalNumber (RoundNumber((double)item.Price)),
                    item.Currency,
                    item.SKU
                )
            };

            if (address != null)
            {
                payment.ShippingAddress = PayPalShippingAddress.ShippingAddressWithRecipientName(
                    address.RecipientName,
                    address.Line1,
                    address.Line2,
                    address.City,
                    address.State,
                    address.PostalCode,
                    address.CountryCode
                );
            }


            if (payment.Processable)
            {
                var paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, this);
                var top = GetTopViewController(UIApplication.SharedApplication.KeyWindow);
                top.PresentViewController(paymentViewController, true, null);
            }
            else {
                OnError?.Invoke("This particular payment will always be processable. If, for example, the amount was negative or the shortDescription was empty, this payment wouldn't be processable, and you'd want to handle that here.");
                OnError = null;
                Debug.WriteLine("Payment not processalbe:" + payment.Items);
            }
        }
Esempio n. 39
0
        public void RequestCardData(Action onCancelled, Action<CardIOCreditCardInfo> onSuccess, PayPal.Forms.Abstractions.Enum.CardIOLogo scannerLogo)
        {
            RetrieveCardCancelled = onCancelled;
            RetrieveCardSuccess = onSuccess;
            var scanViewController = new CardIOPaymentViewController(new CustomCardIOPaymentViewControllerDelegate(this));

            switch (scannerLogo)
            {
                case Abstractions.Enum.CardIOLogo.CardIO:
                    scanViewController.HideCardIOLogo = false;
                    scanViewController.UseCardIOLogo = true;
                    break;
                case Abstractions.Enum.CardIOLogo.None:
                    scanViewController.HideCardIOLogo = true;
                    scanViewController.UseCardIOLogo = false;
                    break;
            }
            var top = GetTopViewController(UIApplication.SharedApplication.KeyWindow);
            top.PresentViewController(scanViewController, true, null);
        }
Esempio n. 40
0
        protected void confirmPayment(object sender, EventArgs e)
        {
            PayPal card = getData();

            using (ArtShopEntities db = new ArtShopEntities())
            {
                PayPal        database = db.PayPals.Find(card.paypal_id);
                modal.Payment payments = db.Payments.Find(paymentId);
                if (database == null)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Invalid paypal account!!",
                                                          "paypal account not corrects"));
                    return;
                }
                if (database.paypal_id != card.paypal_id)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Unassessable!!",
                                                          "Account is not match"));
                    return;
                }
                if (database.name != card.name)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Unassessable!!",
                                                          "Name is not match"));
                    return;
                }
                if (database.password != card.password)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Unassessable!!",
                                                          "Passwords is not match"));
                    return;
                }
                modal.Payment pay = db.Payments.Find(paymentId);

                if ((double)database.amount < pay.total_pay)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          Notifications.ERROR_TYPE,
                                                          "Not enought amount!!",
                                                          "Your accocunt only remain " + database.amount));
                    return;
                }

                database.amount        -= (decimal)pay.total_pay;
                payments.payment_status = Guid.Parse("c595596d-8980-4138-bc20-a91056e1b1ce");
                payments.payment_method = Guid.Parse("9244ee14-b4b5-4f2c-833b-3b3c18d68764");
                payments.payment_meta   = database.paypal_id;
                payments.customer_paid  = payments.total_pay;
                payments.payment_date   = DateTime.Now;

                db.Payments.AddOrUpdate(payments);
                db.PayPals.AddOrUpdate(database);

                try
                {
                    db.SaveChanges();
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          2,
                                                          Notifications.SUCCESS_TYPE,
                                                          "Payment sucessfull!!",
                                                          "you have complete the payment with your paypal account: " + database.paypal_id + ""));
                    Functions.sendPaymentMail(payments);
                }
                catch (Exception ex)
                {
                    Functions.EnqueueNewNotifications(new Notifications(
                                                          2,
                                                          Notifications.ERROR_TYPE,
                                                          "Payment Failed!!",
                                                          "you have following exception : " + ex.Message + " !!"));
                }
            }
        }
Esempio n. 41
0
 /// <summary>
 /// Tests that use this method must be ignored when run in an automated environment because executing an order
 /// will require approval via the executed payment's approval_url.
 /// </summary>
 /// <returns></returns>
 private Order GetExecutedPaymentOrder(PayPal.Api.APIContext apiContext)
 {
     var pay = PaymentTest.CreatePaymentOrder(apiContext);
     var paymentExecution = PaymentExecutionTest.GetPaymentExecution();
     paymentExecution.payer_id = pay.id;
     paymentExecution.transactions[0].amount.details = null;
     var executedPayment = pay.Execute(apiContext, paymentExecution);
     var orderId = executedPayment.transactions[0].related_resources[0].order.id;
     return Order.Get(apiContext, orderId);
 }
Esempio n. 42
0
		public void BuyItem(
			PayPal.Forms.Abstractions.PayPalItem item,
			Deveel.Math.BigDecimal xftax,
			Action onCancelled,
			Action<string> onSuccess,
			Action<string> onError
		){

			OnCancelled = onCancelled;
			OnSuccess = onSuccess;
			OnError = onError;
			BigDecimal amount = new BigDecimal (item.Price.ToString ()).Add (new BigDecimal (xftax.ToString ()));

			PayPalPayment payment = new PayPalPayment (amount, item.Currency, item.Name, PayPalPayment.PaymentIntentSale);

			Intent intent = new Intent (Context, typeof(PaymentActivity));

			intent.PutExtra (PayPalService.ExtraPaypalConfiguration, config);

			intent.PutExtra (PaymentActivity.ExtraPayment, payment);

			(Context as Activity).StartActivityForResult (intent, REQUEST_CODE_PAYMENT);
		}
Esempio n. 43
0
		public void BuyItems(
			PayPal.Forms.Abstractions.PayPalItem[] items,
			Deveel.Math.BigDecimal xfshipping,
			Deveel.Math.BigDecimal xftax,
			Action onCancelled,
			Action<string> onSuccess,
			Action<string> onError
		) {

			OnCancelled = onCancelled;
			OnSuccess = onSuccess;
			OnError = onError;

			List<PayPalItem> nativeItems = new List<PayPalItem> ();
			foreach (var product in items) {
				nativeItems.Add (new PayPalItem (
					product.Name,
					new Java.Lang.Integer ((int)product.Quantity),
					new BigDecimal (product.Price.ToString ()),
					product.Currency,
					product.SKU)
				);
			}

			BigDecimal subtotal = PayPalItem.GetItemTotal (nativeItems.ToArray ());
			BigDecimal shipping = new BigDecimal (xfshipping.ToString ());
			BigDecimal tax = new BigDecimal (xftax.ToString ());
			PayPalPaymentDetails paymentDetails = new PayPalPaymentDetails (shipping, subtotal, tax);
			BigDecimal amount = subtotal.Add (shipping).Add (tax);

			PayPalPayment payment = new PayPalPayment (amount, nativeItems.FirstOrDefault().Currency, "Multiple items", PayPalPayment.PaymentIntentSale);
			payment = payment.Items (nativeItems.ToArray ()).PaymentDetails (paymentDetails);

			Intent intent = new Intent (Context, typeof(PaymentActivity));

			intent.PutExtra (PayPalService.ExtraPaypalConfiguration, config);

			intent.PutExtra (PaymentActivity.ExtraPayment, payment);

			(Context as Activity).StartActivityForResult (intent, REQUEST_CODE_PAYMENT);
		}
        protected void Page_Load(object sender, System.EventArgs e)
        {
            StringBuilder writer = new StringBuilder();

            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");
            Customer ThisCustomer = Context.GetCustomer();

            writer.Append("<div align=\"left\">");
            int ONX = CommonLogic.QueryStringUSInt("OrderNumber");

            if (!ThisCustomer.IsAdminUser) // safety check
            {
                writer.Append("<b><font color=red>" + AppLogic.GetString("admin.common.PermissionDeniedUC", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "</b></font>");
            }
            else
            {
                writer.Append(String.Format(AppLogic.GetString("admin.paypalreauthorder.ReAuthorizeOrder", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ONX.ToString()));

                using (var conn = DB.dbConn())
                {
                    conn.Open();
                    using (var rs = DB.GetRS("Select * from orders   with (NOLOCK)  where ordernumber=" + ONX.ToString(), conn))
                    {
                        if (rs.Read())
                        {
                            String PM = AppLogic.CleanPaymentMethod(DB.RSField(rs, "PaymentMethod"));
                            if (DB.RSFieldDateTime(rs, "CapturedOn") == System.DateTime.MinValue)
                            {
                                if (DB.RSField(rs, "TransactionState") == AppLogic.ro_TXStateAuthorized)
                                {
                                    String Status = String.Empty;
                                    String GW     = AppLogic.CleanPaymentGateway(DB.RSField(rs, "PaymentGateway"));
                                    if (PM == AppLogic.ro_PMPayPalExpress)
                                    {
                                        GW = Gateway.ro_GWPAYPAL;
                                    }
                                    PayPal PayPalGW = new PayPal();
                                    Status = PayPalGW.ReAuthorizeOrder(ONX);
                                    writer.Append(String.Format(AppLogic.GetString("admin.paypalreauthorder.ReAuthorizeResponse", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), Status));
                                    writer.Append("<script type=\"text/javascript\">\n");
                                    writer.Append("opener.window.location = opener.window.location.href;");
                                    writer.Append("</script>\n");
                                }
                                else
                                {
                                    writer.Append(String.Format(AppLogic.GetString("admin.paypalreauthorder.NotAuth", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), DB.RSField(rs, "TransactionState")));
                                }
                            }
                            else
                            {
                                writer.Append(String.Format(AppLogic.GetString("admin.paypalreauthorder.CapturedOn", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), Localization.ToNativeDateTimeString(DB.RSFieldDateTime(rs, "CapturedOn"))));
                            }
                        }
                        else
                        {
                            writer.Append("<b><font color=red>" + AppLogic.GetString("admin.common.OrderNotFoundUC", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "</b></font>");
                        }
                    }
                }
            }
            writer.Append("</div>");
            writer.Append("<p align=\"center\"><a href=\"javascript:self.close();\">" + AppLogic.GetString("admin.common.Close", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "</a></p>");
            ltContent.Text = writer.ToString();
        }