/// <summary>
        /// Send payment.GetApprovalUrl(); to user, to get aproval from him
        /// </summary>
        /// <returns></returns>
        public Payment CreatePayment()
        {
            RedirectUrls redirect_urls = new RedirectUrls();
            Transaction  transaction   = new Transaction();
            Amount       amount        = new Amount();
            Payer        payer         = new Payer();

            ApiProperties.PaymentIntent intent         = ApiProperties.PaymentIntent.sale;
            ApiProperties.PaymentMethod payment_method = ApiProperties.PaymentMethod.paypal;
            ApiProperties.Currency      curremcy       = ApiProperties.Currency.USD;
            string  description = "descriptiontest";
            decimal total       = 1.1M;

            redirect_urls.return_url = @"https://www.google.pl/search?q=return";
            redirect_urls.cancel_url = @"https://www.google.pl/search?q=cancel";
            amount.currency          = curremcy.GetEnumName();
            amount.total             = string.Format("{0:0.00}", total);
            transaction.amount       = amount;
            transaction.description  = description;
            payer.payment_method     = payment_method.GetEnumName();

            Payment payment = new Payment();

            payment.intent        = intent.GetEnumName();
            payment.redirect_urls = redirect_urls;
            payment.payer         = payer;
            payment.transactions  = new List <Transaction>()
            {
                transaction
            };


            return(payment.Create(this.Context));
        }
Example #2
0
        /// <summary>
        /// Can be called using: payment.GetApprovalUrl();
        /// </summary>
        /// <param name="amount"></param>
        /// <param name="currency"></param>
        /// <param name="description"></param>
        /// <param name="returnURL"></param>
        /// <param name="cancelURL"></param>
        /// <returns></returns>
        public Payment RequestPayment(
            decimal amount,
            ApiProperties.Currency currency,
            string description,
            string returnURL, //@"https://www.google.pl/search?q=return"
            string cancelURL  //@"https://www.google.pl/search?q=cancel"
            )
        {
            if (amount <= 0)
            {
                return(null);
            }

            RedirectUrls redirect_urls = new RedirectUrls();
            Transaction  transaction   = new Transaction();
            Amount       Amount        = new Amount();
            Payer        payer         = new Payer();

            ApiProperties.PaymentIntent intent         = ApiProperties.PaymentIntent.sale;
            ApiProperties.PaymentMethod payment_method = ApiProperties.PaymentMethod.paypal;


            redirect_urls.return_url = returnURL;
            redirect_urls.cancel_url = cancelURL;
            Amount.currency          = currency.GetEnumName();
            Amount.total             = string.Format("{0:0.00}", amount);
            transaction.amount       = Amount;
            transaction.description  = description;
            payer.payment_method     = payment_method.GetEnumName();

            Payment payment = new Payment();

            payment.intent        = intent.GetEnumName();
            payment.redirect_urls = redirect_urls;
            payment.payer         = payer;
            payment.transactions  = new List <Transaction>()
            {
                transaction
            };

            return(payment.Create(this.Context));
        }