protected void btnpayment_Click(object sender, EventArgs e) { GoDine a = new GoDine(); MembershipUser user = Membership.GetUser(); bool paramOK = true; decimal net = 0; decimal ratio = (decimal) 0.97; int code; try { net = Convert.ToDecimal(tbpaymentCAD.Text); } catch { lblinfo.Text = "ERROR -> Amount to pay is not valid"; paramOK = false; return; } try { if (tbPIN.Text == "") { code = -1; } else { code = Convert.ToInt32(tbPIN.Text); } } catch { lblinfo.Text = "ERROR -> PIN is not valid"; paramOK = false; return; } if (paramOK){ tbpaymentCAD.Text = ""; tbPIN.Text = ""; long barcode = a.GiftCard_Create_with_code(code, 0); // IT IS FORCED a.GiftCard_AddInfo_EmailType(barcode, user.UserName); //user.UserName string concept = "User payment by credit card/paypal"; a.Insert_Money_2_GiftCard(net, net*ratio, barcode, concept, 0); lblinfo.Text = "Success"; //// SENDING EMAIL string subject = "AroundTown GiftCard"; string body = GoDineEmails.PrepareMailBodyWith("newgiftcard.htm", "%name%", user.Email, "%amount%", net.ToString("0.00"), "%code%", barcode.ToString("0")); GoDineEmails.SendMail(user.Email, subject, body); Response.Redirect("GiftCards.aspx"); } }
protected void btncreategc_Click(object sender, EventArgs e) { try { int code; if (tbcreategc.Text == "") { code = -1; } else { code = Convert.ToInt32(tbcreategc.Text); } GoDine a = new GoDine(); string strusername = ddcreategc.SelectedValue; long barcode = a.GiftCard_Create_with_code(code, 1); // IT IS FORCED a.GiftCard_AddInfo_EmailType(barcode, strusername); lblcreategc.Text = "OK -> Gift Card created for User " + strusername + (code == -1 ? " without protection" : " with pass code = " + code.ToString()); } catch { lblcreategc.Text = "ERROR -> A user name must be inserted and if there is code protection it must be a positive integer"; } }
protected void RedirectToPaypal(decimal AMOUNT) { String saleString = Request.QueryString["Sale"]; String companyString = Request.QueryString["Company"]; UTILITIES.GiftCardReady GCready = new UTILITIES.GiftCardReady(); GCready.FromName = fromName.Text; GCready.FromEmail = fromEmail.Text; GCready.ToName = toName.Text; GCready.ToEmail = toEmail.Text; if (message.Value.Contains("Please Enter Your Greeting text here")){ GCready.TEXT = ""; } else{GCready.TEXT = message.Value;} GCready.amount = AMOUNT; GCready.STRVAL = "$ " + AMOUNT.ToString("0.00"); GCready.TYPE = rbChoice.SelectedIndex; GCready.DIR_BACKBMP = backgroundImage.Value; GCready.DIR_TXTBMP = ""; displayName = cbDisplayNames.Checked; GCready.DisplayName = displayName; Random random = new Random(); GCready.paypalID = DateTime.Now.ToString("yyMMddHHmmss") + fromEmail.Text.Replace('@', '-') + random.Next(1000).ToString("000"); GCready.SalesID = "00000000-0000-0000-0000-000000000000"; String CompanyID = "00000000-0000-0000-0000-000000000000"; decimal salesDeal = 0; GoDine a = new GoDine(); if (saleString != null && UniqueIDisValid(saleString)) { GCready.SalesID = saleString; try { salesDeal = a.getDealRateForSellerID(new Guid(saleString)); } catch { } } if (companyString != null && UniqueIDisValid(companyString)) { try { //sales people don't make comission for giftcards that are for individual companies //if it's a valid company ID it'll overwrite the salesID, if it's not valid it won't save the CompanyID salesDeal = a.CompanyGiftCardDealRate(companyString); CompanyID = companyString; GCready.SalesID = "00000000-0000-0000-0000-000000000000"; } catch { } } long barcode = a.GiftCard_Create_with_code(-1, 0); // IT IS NOT FORCED string barcodeWithChecksum = UTILITIES.appendChecksum(barcode); System.Console.WriteLine(barcodeWithChecksum); a.GiftCard_AddInfo_EmailType(barcode, GCready.ToEmail, GCready.FromEmail, GCready.ToName, GCready.FromName, GCready.DIR_BACKBMP, GCready.DIR_TXTBMP, GCready.TEXT, GCready.STRVAL, GCready.amount, GCready.paypalID, GCready.DisplayName, GCready.SalesID, salesDeal, CompanyID); if (GCready.TYPE == 1) { a.GiftCard_AddInfo_PrintType(barcode); } else if (GCready.TYPE == 2) { a.GiftCard_AddInfo_ShippingType(barcode, "", ""); // if shipping, the address must be applied exactly after the info of the email type } GCready.barcode = barcode; Session["GCready"] = GCready; //string input_permanent = "?cmd=_xclick&[email protected]¤cy_code=CAD&country=CA&no_shipping=1&shipping=0.001&handling=0.00&image_url=" + WEBSITE_ADDRESS + "/img/paypal150px.png&return=" + WEBSITE_ADDRESS + "/TransactionStatus.aspx&cancel_return=" + WEBSITE_ADDRESS + "/TransactionStatus.aspx"; string input_permanent = "?cmd=_ext-enter&redirect_cmd=_xclick&[email protected]";//&shipping=0.00&handling=0.00 input_permanent += "¤cy_code=CAD&no_shipping=1&country=CA&image_url=" + HOST_URL + "/img/paypal150px.png"; input_permanent += "&callback_url=" + HOST_URL + "/About.aspx"; string input_permanent_sandbox = "?cmd=_ext-enter&redirect_cmd=_xclick&[email protected]";//&shipping=0.00&handling=0.00 input_permanent_sandbox += "¤cy_code=CAD&no_shipping=1&country=CA&image_url=" + HOST_URL + "/img/paypal150px.png"; input_permanent_sandbox += "&callback_url=" + HOST_URL + "/About.aspx"; string input_dependent = "&item_name=AroundTown Giftcard, " + AMOUNT.ToString("0.00") + "$ value"; input_dependent += "&amount=" + AMOUNT.ToString("0.00") + "&email=" + GCready.FromEmail + "&receiver_email=" + GCready.FromEmail; input_dependent += "&custom=" + GCready.paypalID + "&first_name=" + GCready.FromName; //https://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/howto_checkout-outside string resp_redirect; if (useSandbox) { resp_redirect = PAYPAL_ADDRESS_SANDBOX + input_permanent_sandbox + input_dependent + "&return=" + HOST_URL + "/PaymentSuccess.aspx&cancel_return=" + HOST_URL + "/PaymentPending.aspx"; } else { resp_redirect = PAYPAL_ADDRESS + input_permanent + input_dependent + "&return=" + HOST_URL + "/PaymentSuccess.aspx&cancel_return=" + HOST_URL + "/PaymentPending.aspx"; } log.Debug("Redirecting to paypal: " + resp_redirect); Response.Redirect(resp_redirect); }