protected void GetPaid(string itemType, string aditem, string amnt, CreditCardDetailsType cc) { HttpContext CurrContext = HttpContext.Current; //amnt = "1.00"; try { DoDirectPaymentResponseType reply = DirectPayment.DoDirectPaymentAPIOperation(cc, amnt); Session["Reply"] = reply; Session["PaymentInfo"] = cc; if (reply.Ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { switch (itemType) { case "car": VehiclesBilling vb = Session["VehicleBilling"] as VehiclesBilling; vb.PayPalId = reply.TransactionID; vb.PayPalState = reply.Ack.ToString(); vb.CreateTime = Convert.ToDateTime(reply.Timestamp); if (VehiclesBilling.PaidInFull(vb)) { CustomerVehicleInfo.UpdateBillingId(Convert.ToInt32(Session["VehicleId"]), vb.Id); NotifyCustomer(Convert.ToInt32(Session["VehicleId"]), itemType, vb.Payment, "0", reply.TransactionID); NotifyAdmin(Request.QueryString["item"], vb.Payment, "0", reply.TransactionID); } break; case "ad": AdsBilling ad = new AdsBilling { CustomerId = Convert.ToInt32(Session["CustomerId"]), AdId = Convert.ToInt32(Request.QueryString["id"]), Payment = Convert.ToDouble(amnt), PayPalId = reply.TransactionID, PayPalState = reply.Ack.ToString(), CreateTime = Convert.ToDateTime(reply.Timestamp) }; if (AdsBilling.InsertNewBilling(ad)) { CustomerAd.PaidInFull(ad.AdId); NotifyCustomer(ad.AdId, itemType, ad.Payment, "0", reply.TransactionID); NotifyAdmin(Request.QueryString["item"], ad.Payment, "0", reply.TransactionID); } break; } } else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Error", " alert('Transaction failed, please check your credit card information and try again.');", true); //Server.Transfer("~/account/PaymentResponse.aspx"); } } catch (WebException ex) { CurrContext.Items.Add("Error", ex.Message); ErrorHandler.writeExceptionToLogFile(ex); } }
private void UpdateAdBillingAdmin(double amnt) { AdsBilling ad = new AdsBilling(); ad.CustomerId = usr.Id; ad.AdId = filesuploaded; ad.Payment = amnt; ad.PayPalId = "BizAd by admin"; ad.PayPalState = "SUCCESS"; ad.CreateTime = DateTime.Now; if (AdsBilling.InsertNewBilling(ad)) { CustomerAd.PaidInFull(ad.AdId); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", " alert('Business ad completed.');", true); } }