-
Notifications
You must be signed in to change notification settings - Fork 0
/
getgift.aspx.cs
155 lines (139 loc) · 6.6 KB
/
getgift.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
namespace BlueIkons
{
public partial class getgift : Telerik.Web.UI.RadAjaxPage
{
fbuser fbuser = new fbuser();
Site siteTemp = new Site();
string strapprurl = ConfigurationManager.AppSettings.Get("App_URL").ToString();
bool Live_Trial = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("Live_Demo").ToString());
protected void Page_Load(object sender, EventArgs e)
{
fbuser = siteTemp.getfbuser();
if (!IsPostBack)
{
//populate charities info
DataSet dstemp = BlueIkons_DB.SPs.ViewFbidpendinggifts(fbuser.UID).GetDataSet();
if (dstemp.Tables[0].Rows.Count > 0)
{
int giftkey = Convert.ToInt32(dstemp.Tables[0].Rows[0]["Gift_Key"]);
dstemp = BlueIkons_DB.SPs.ViewCharity(giftkey).GetDataSet();
lblcharityname.Text = dstemp.Tables[0].Rows[0]["Charity_Name"].ToString();
lblcharitydescription.Text = dstemp.Tables[0].Rows[0]["Charity_Description"].ToString();
hdcharityemail.Value = dstemp.Tables[0].Rows[0]["Charity_Email"].ToString();
gift giftinfo = siteTemp.GetGiftInfo(giftkey);
lblamount.Text = string.Format("{0:C}", giftinfo.amount);
lblhumanid.Text = giftkey.ToString();
lblgiftid.Text = giftinfo.Gift_Key.ToString();
lblgiftamount.Text = string.Format("{0:C}", giftinfo.amount);
lblinfo.Text = giftkey.ToString();
//check if gift is still good
if (siteTemp.Gifthasbeenreceived(giftkey))
{
Response.Redirect("givegift.aspx?fbid=" + fbuser.UID.ToString() + "&alert=1");
}
PayPal pp = new PayPal();
Transactions txinfo = siteTemp.Gettx(giftinfo.txkey);
if (!pp.PreapprovalActive(txinfo.pakey, Live_Trial,giftinfo.txkey))
{
//Is not active
Response.Redirect("givegift.aspx?fbid=" + fbuser.UID.ToString() + "&alert=2");
}
}
}
if (Request.Form["__EVENTTARGET"] == "btnpf")
{
btnpf();
}
if (Request.Form["__EVENTTARGET"] == "btncollect")
{
btnpf();
}
}
protected void btnSendtoPayPal_Click(object sender, EventArgs e)
{
pnltotal.Visible = false;
pnlcollect.Visible = true;
}
protected void btnPayForward_Click(object sender, EventArgs e)
{
pnltotal.Visible = false;
pnlpayforward.Visible = true;
}
protected void btnpf()
{
//Pay it forward
DataSet dstemp = BlueIkons_DB.SPs.ViewFbidpendinggifts(fbuser.UID).GetDataSet();
int giftkey = Convert.ToInt32(dstemp.Tables[0].Rows[0]["Gift_Key"]);
gift giftinfo = siteTemp.GetGiftInfo(giftkey);
PayPal pa = new PayPal();
if (pa.ParallelPayment(Live_Trial, giftinfo, hdcharityemail.Value))
{
//Payment went through
pnlpayforward.Visible = false;
pnltxcompleted.Visible = true;
pnltotal.Visible = false;
if (giftinfo.fbpost)
{
//post on facebook
DataSet dstemp2 = BlueIkons_DB.SPs.ViewFBUser(giftinfo.sender_fbid).GetDataSet();
string accesstoken = dstemp2.Tables[0].Rows[0]["Access_Token"].ToString();
string receivername = giftinfo.receiver_name;
string strmessage = "Paid it Forward";
string strdescription = "You too can send a gift by clicking on the image. BlueIkons. Faster than a GiftCard...and more Fun!";
string strpicurl = ConfigurationManager.AppSettings.Get("BlueIkons_Pics").ToString() + giftinfo.blueikon.ToString() + ".png";
siteTemp.Facebook_PostLink_OnWall(giftinfo.receiver_fbid.ToString(), strapprurl, strmessage, strpicurl, "BlueIkons, Faster than a Gift Card and more Fun!", accesstoken, "", strdescription);
}
}
else
{
lblerror.Visible = true;
}
}
protected void btnPayForward2_Click(object sender, EventArgs e)
{
btnpf();
}
protected void btncollect()
{
//Complete tx and send money to receiver's paypal
DataSet dstemp = BlueIkons_DB.SPs.ViewFbidpendinggifts(fbuser.UID).GetDataSet();
int giftkey = Convert.ToInt32(dstemp.Tables[0].Rows[0]["Gift_Key"]);
gift giftinfo = siteTemp.GetGiftInfo(giftkey);
PayPal pa = new PayPal();
if (pa.ParallelPayment(Live_Trial, giftinfo, txtppemail.Text))
{
//Payment went through
pnlcollect.Visible = false;
pnltxcompleted.Visible = true;
pnltotal.Visible = false;
if (giftinfo.fbpost)
{
//post on facebook
DataSet dstemp2 = BlueIkons_DB.SPs.ViewFBUser(giftinfo.sender_fbid).GetDataSet();
string accesstoken = dstemp2.Tables[0].Rows[0]["Access_Token"].ToString();
string receivername = giftinfo.receiver_name;
string strmessage = giftinfo.witty_message; //receivername + " received a gift on BlueIkons";
string strdescription = "You too can send a gift by clicking on the image. BlueIkons. Faster than a GiftCard...and more Fun!";
string strpicurl = ConfigurationManager.AppSettings.Get("BlueIkons_Pics").ToString() + giftinfo.blueikon.ToString() + ".png";
siteTemp.Facebook_PostLink_OnWall(giftinfo.receiver_fbid.ToString(), strapprurl, strmessage, strpicurl, "BlueIkons, Faster than a Gift Card and more Fun!", accesstoken, "", strdescription);
}
}
else
{
lblerror.Visible = true;
}
}
protected void btnCollect_Click(object sender, EventArgs e)
{
btncollect();
}
}
}