public JsonResult PaypalContribution(string nonce, string id, ContributionViewModel contribution)
        {

            var amount = (decimal)contribution.Amount;

            TransactionRequest request = new TransactionRequest()
            {
                Amount = amount,
                PaymentMethodNonce = nonce,
                OrderId = "Mapped to PayPal Invoice Number",
                Options = new TransactionOptionsRequest()
                {
                    SubmitForSettlement = true,
                    PayPal = new TransactionOptionsPayPalRequest()
                    {
                        CustomField = "PayPal custom field",
                        Description = "Description for PayPal email receipt"
                    }
                }
            };

            Result<Transaction> result = gateway.Transaction.Sale(request);

            if (result.IsSuccess())
            {
                var userId = User.Identity.GetUserId();
                var user = db.Users.Find(userId);

                var newContribution = new Contribution()
                {
                    Campaign = db.Campaigns.Find(id),
                    Amount = contribution.Amount,
                    Contributor = user,
                };

                var campaign = db.Campaigns.Find(id);
                campaign.Contributions.Add(newContribution);
                db.SaveChanges();

                return Json(result.Message);
            };
            var errors = new List<string>();

            foreach (var item in result.Errors.DeepAll())
            {
                errors.Add(item.Message);
            }
            return Json(errors);
        }
        public JsonResult CreditCardContribution(string nonce, string id, ContributionViewModel contribution)
        {
            var amount = (decimal)contribution.Amount;

            var request = new TransactionRequest
            {
                Amount = amount,
                PaymentMethodNonce = nonce,
                Options = new TransactionOptionsRequest
                {
                    SubmitForSettlement = true
                }
            };

            Result<Transaction> result = gateway.Transaction.Sale(request);

            if (result.IsSuccess())
            {
                var userId = User.Identity.GetUserId();
                var user = db.Users.Find(userId);

                var newContribution = new Contribution()
                {
                    Campaign = db.Campaigns.Find(id),
                    Amount = contribution.Amount,
                    Contributor = user,
                };

                var campaign = db.Campaigns.Find(id);
                campaign.Contributions.Add(newContribution);
                db.SaveChanges();

                return Json(result.Message);
            };

            var errors = new List<string>();

            foreach (var item in result.Errors.DeepAll())
            {
                errors.Add(item.Message);
            }

            return Json(errors);
        }