public ChargeResponse Charge(PostCharge c) { var url = Urls.Charge; var postData = ParameterBuilder.ApplyAllParameters(c, ""); if (c.Card != null) { postData += "&card[number]=" + c.Card.CardNumber + "&card[expiry_month]=" + c.Card.ExpiryMonth + "&card[expiry_year]=" + c.Card.ExpiryYear + "&card[cvc]=" + c.Card.CVC + "&card[name]=" + c.Card.Name; postData += "&card[address_line1]=" + c.Card.Address1 + "&card[address_line2]=" + c.Card.Address2 + "&card[address_city]=" + c.Card.City + "&card[address_postcode]=" + c.Card.Postcode; postData += "&card[address_state]=" + c.Card.State + "&card[address_country]=" + c.Card.Country; } else if (c.CustomerToken != null) { postData += "&customer_token=" + c.CustomerToken; } else if (c.CardToken != null) { postData += "&card_token=" + c.CardToken; } else { throw new PinException(HttpStatusCode.BadRequest, null, "You need to supply either the Card, the Customer Token or a Card Token for payment"); } var response = Requestor.PostString(url, postData); return(JsonConvert.DeserializeObject <ChargeResponse>(response)); }
public dynamic createPayment(int guestID, string type, string method, decimal amount, string status, int resID = -1) { if (type == "PostCharge") { PostCharge charge = new PostCharge(); charge.GuestId = guestID; charge.PaymentMethod = method; charge.Amount = amount; charge.Status = status; return(charge); } else if (type == "ReservationInvoice") { ReservationInvoice invoice = new ReservationInvoice(); invoice.ReservationId = resID; invoice.GuestId = guestID; invoice.IssueDate = DateTime.Now; invoice.PaymentMethod = method; invoice.Amount = amount; invoice.Status = status; return(invoice); } else { return(null); } }
public bool addItem(int guestID, string itemName, string itemDesc, int itemQnty, decimal itemPrice) { PostCharge postCharge = null; var tempCharge = _chargeGateway.findByGuestID(guestID).FirstOrDefault(); if (tempCharge == null) { PaymentFactory factory = PaymentFactory.getInstance(); postCharge = factory.createPayment(guestID: guestID, type: "PostCharge", amount: itemPrice * itemQnty, status: "Pending", method: ""); _chargeGateway.insert(postCharge); } else { postCharge = tempCharge; } var item = new ReceiptItem(); item.Name = itemName; item.Description = itemDesc; item.Quantity = itemQnty; item.Price = itemPrice; try { postCharge.ItemList.Add(item); _chargeGateway.update(postCharge); return(true); } catch (Exception e) { return(false); } }
public bool updatePayment(PostCharge payment) { if (payment != null) { return(_chargeGateway.update(payment)); } return(false); }
public bool addPayment(PostCharge payment) { if (payment != null) { return(_chargeGateway.insert(payment)); } return(false); }
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 bool delete(PostCharge PostCharge) { _context.PostCharge.Remove(PostCharge); return(_context.SaveChanges() > 0 ? true : false); }
public bool update(PostCharge PostCharge) { _context.Update(PostCharge); return(_context.SaveChanges() > 0 ? true : false); }
public bool insert(PostCharge PostCharge) { _context.Add(PostCharge); return(_context.SaveChanges() > 0 ? true : false); }