Example #1
0
        public static string GetTokenFromApprovalUrl(List <Links> links)
        {
            var resource = new PayPalRelationalObject {
                links = links
            };

            return(resource.GetTokenFromApprovalUrl());
        }
        public void LinksApprovalUrlPayNowTest()
        {
            var resource = new PayPalRelationalObject {
                links = GetLinksList()
            };
            var approvalUrl = resource.GetApprovalUrl(true);

            Assert.AreEqual("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-0JP008296V451950C&useraction=commit", approvalUrl);
        }
        public void LinksApprovalUrlTokenTest()
        {
            var resource = new PayPalRelationalObject {
                links = GetLinksList()
            };
            var token = resource.GetTokenFromApprovalUrl();

            Assert.AreEqual("EC-0JP008296V451950C", token);
        }
        public void LinksNoApprovalUrlTest()
        {
            var resource = new PayPalRelationalObject
            {
                links = new List <Links>
                {
                    GetLinks(false)
                }
            };
            var approvalUrl = resource.GetApprovalUrl();

            Assert.IsTrue(string.IsNullOrEmpty(approvalUrl));
        }
        public void LinksNoApprovalUrlEmptyTokenTest()
        {
            var resource = new PayPalRelationalObject
            {
                links = new List <Links>
                {
                    GetLinks(false)
                }
            };
            var token = resource.GetTokenFromApprovalUrl();

            Assert.IsTrue(string.IsNullOrEmpty(token));
        }
Example #6
0
        private static string GetPayPalRedirectUrl(PayPalRelationalObject payment)
        {
            var links = payment.links.GetEnumerator();

            while (links.MoveNext())
            {
                var lnk = links.Current;
                if (lnk != null && lnk.rel.ToLower().Trim().Equals("approval_url"))
                {
                    return(lnk.href);
                }
            }
            return(null);
        }