public ActionResult Donate(Charge charge, string cardToken)
        {
            Card c = (Card)Session["cardInfo"];

            charge.Amount *= 100;
            this.charge    = new PostCharge()
            {
                Amount      = charge.Amount,
                CardToken   = cardToken,
                Currency    = "AUD",
                Description = charge.Description,
                Email       = charge.Email,
                IPAddress   = Request.ServerVariables["REMOTE_ADDR"]
            };
            ChargeResponse response = ps.Charge(this.charge);

            if (response.Error == null)
            {
                if (response.Charge.Success)
                {
                    receipt = new DonateReceipt()
                    {
                        Amount      = response.Charge.Amount.ToString(),
                        Card_Token  = response.Charge.Card_Token,
                        Created     = response.Charge.Created,
                        Currency    = response.Charge.Currency,
                        Description = response.Charge.Description,
                        Email       = response.Charge.Email,
                        IP_address  = response.Charge.IP_address,
                        Token       = response.Charge.Token
                    };
                    drs.AddReceipt(receipt);

                    Session.Remove("cardInfo");

                    return(RedirectToAction("Receipt", new { token = receipt.Token }));
                }
                else
                {
                    TempData["PurchaceFailed"] = response.Messages[0].Message;
                    return(RedirectToAction("Donate", new { ct = cardToken }));
                }
            }
            else
            {
                if (response.Messages != null)
                {
                    TempData["PurchaceFailed"] = response.Messages[0].Message;
                }
                else
                {
                    TempData["PurchaceFailed"] = response.Description;
                }
                return(RedirectToAction("Donate", new { ct = cardToken }));
            }
        }
 public ActionResult Receipt(string token)
 {
     if (token != null)
     {
         this.receipt = drs.GetDonateReceiptByToken(token);
     }
     if (receipt != null)
     {
         return(View(receipt));
     }
     else
     {
         return(RedirectToAction("Index", "Donate"));
     }
 }
 public void AddReceipt(DonateReceipt receipt)
 {
     context.DonateReceipt.Add(receipt);
     context.SaveChanges();
 }
 public DonateReceiptService()
 {
     receipt = new DonateReceipt();
 }