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"); } }
///////////////////////////////////////////////////////////// PAYMENT SUCCESS public static void Payment_Success_Case_Global_MoneyAndSend(GiftCard giftCard, decimal fee) { log.Debug("Processing successful payment for GiftCard " + giftCard.GiftCardID); log.Debug("Value=" + giftCard.GCValue + ", fee=" + fee + ", barcode=" + giftCard.BarCode); DataClassesAlbertDataContext db = new DataClassesAlbertDataContext(); string companyName = ""; if (giftCard.CompanyID != "00000000-0000-0000-0000-000000000000" && giftCard.CompanyID != "") { try { companyName = (from c in db.Companies where c.UserID == new Guid(giftCard.CompanyID) select c).Single().Name; } catch { } } GoDine a = new GoDine(); a.Insert_Money_2_GiftCard(giftCard.GCValue, giftCard.GCValue - fee, giftCard.BarCode, "Payment by credit card/paypal: " + giftCard.EmailFrom, 0); //IT IS NOT FORCED sendSuccessEmail(giftCard, companyName); }
protected void btnpayment_Click(object sender, EventArgs e) { GoDine a = new GoDine(); long barcode = 0; int success; decimal net = 0; try { barcode = Convert.ToInt64(ddpaymentID.SelectedValue); barcode = UTILITIES.removeCheckSum(barcode); net = Convert.ToDecimal(tbpaymentCAD.Text); success = 1; } catch { success = 0; } if (success == 1) { string concept = tbpaymentconcept.Text; a.Insert_Money_2_GiftCard(net, net, barcode, concept, 1); lblpayment.Text = "OK -> The amount of " + net.ToString() + " has been added to the gift card with barcode " + barcode.ToString(); tbpaymentCAD.Text = ""; } else { lblpayment.Text = "ERROR -> A valid amount of money must be inserted for the gift card selected"; } }