Click here to Skip to main content
15,914,225 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi finally i have only one problem.
while redirecting from Paypal to my site after paymeny.
When i implement these code to my project it showing some error on the key word:-
Key Word: "PDTHolder pdt = PDTHolder.Parse(strResponse);"
Error :"The type or namespace name PHTHolder couldnt be found(are u missing a directive or an assembly reffernces)"

The complete code is.....



protected void Page_Load(object sender, EventArgs e)
{
            if (!Page.IsPostBack)
            {
                string authToken, txToken, query, strResponse;
                authToken = WebConfigurationManager.AppSettings["PDTToken"];
 
                //read in txn token from querystring
                txToken = Request.QueryString.Get("tx");
 

                query = string.Format("cmd=_notify-synch&tx={0}&at={1}",
                                      txToken, authToken);
 
                // Create the request back
                string url = WebConfigurationManager.AppSettings["PayPalSubmitUrl"];
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
 
                // Set values for the request back
                req.Method = "POST";
                req.ContentType = "application/x-www-form-urlencoded";
                req.ContentLength = query.Length;
 
                // Write the request back IPN strings
                StreamWriter stOut = new StreamWriter(req.GetRequestStream(),
                                         System.Text.Encoding.ASCII);
                stOut.Write(query);
                stOut.Close();
 
                // Do the request to PayPal and get the response
                StreamReader stIn = new      StreamReader(req.GetResponse().GetResponseStream());
                strResponse = stIn.ReadToEnd();
                stIn.Close();
 
                // sanity check
                lblMsg.Text = strResponse;
 
                // If response was SUCCESS, parse response string and output details
                if (strResponse.StartsWith("SUCCESS"))
                {
                    PDTHolder pdt = PDTHolder.Parse(strResponse);
                    lblMsg.Text =
                        string.Format("Thank you {0} {1} [{2}] for your payment of {3} {4}!",
                        pdt.PayerFirstName, pdt.PayerLastName,
                        pdt.PayerEmail, pdt.GrossTotal, pdt.Currency);
                }
                else
                {
                    lblMsg.Text = "Oooops, something went wrong...";
                }
            }
        }



pls pls help me......
Posted
Updated 11-May-11 1:06am
v2
Comments
Mohammed Asif.K 11-May-11 7:06am    
first time stop facebook browsing and coding..thats time clear ur problems

Please chekch this link..
http://www.codeproject.com/KB/aspnet/paypal_c_aspnet.aspx
or
Implimnet this items
I had also to change my global.asax to not use code behind. Look:

void Profile_MigrateAnonymous(object sender,
ProfileMigrateEventArgs e)
{
ProfileCommon anonymousProfile =
Profile.GetProfile(e.AnonymousID);
if (anonymousProfile != null &&
anonymousProfile.CurrentBasketInfo != null)
{
Profile.CurrentBasketInfo =
anonymousProfile.CurrentBasketInfo;
}
}
 
Share this answer
 
v2
Comments
abdul wahab.o 11-May-11 7:21am    
What is this..........??????????
I don't get anything
any way thanks for your responds.
copy and paste this class in ur app_code class template.

using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Web;
5
6 namespace LepiPele.PayPal.PDT
7 {
8 public class PDTHolder
9 {
10 public double GrossTotal { get; set; }
11 public int InvoiceNumber { get; set; }
12 public string PaymentStatus { get; set; }
13 public string PayerFirstName { get; set; }
14 public double PaymentFee { get; set; }
15 public string BusinessEmail { get; set; }
16 public string PayerEmail { get; set; }
17 public string TxToken { get; set; }
18 public string PayerLastName { get; set; }
19 public string ReceiverEmail { get; set; }
20 public string ItemName { get; set; }
21 public string Currency { get; set; }
22 public string TransactionId { get; set; }
23 public string SubscriberId { get; set; }
24 public string Custom { get; set; }
25
26 public static PDTHolder Parse(string postData)
27 {
28 String sKey, sValue;
29 PDTHolder ph = new PDTHolder();
30
31 try
32 {
33 //split response into string array using whitespace delimeter
34 String[] StringArray = postData.Split('\n');
35
36 // NOTE:
37 /*
38 * loop is set to start at 1 rather than 0 because first
39 string in array will be single word SUCCESS or FAIL
40 Only used to verify post data
41 */
42
43 // use split to split array we already have using "=" as delimiter
44 int i;
45 for (i = 1; i < StringArray.Length - 1; i++)
46 {
47 String[] StringArray1 = StringArray[i].Split('=');
48
49 sKey = StringArray1[0];
50 sValue = HttpUtility.UrlDecode(StringArray1[1]);
51
52 // set string vars to hold variable names using a switch
53 switch (sKey)
54 {
55 case "mc_gross":
56 ph.GrossTotal = Convert.ToDouble(sValue);
57 break;
58
59 case "invoice":
60 ph.InvoiceNumber = Convert.ToInt32(sValue);
61 break;
62
63 case "payment_status":
64 ph.PaymentStatus = Convert.ToString(sValue);
65 break;
66
67 case "first_name":
68 ph.PayerFirstName = Convert.ToString(sValue);
69 break;
70
71 case "mc_fee":
72 ph.PaymentFee = Convert.ToDouble(sValue);
73 break;
74
75 case "business":
76 ph.BusinessEmail = Convert.ToString(sValue);
77 break;
78
79 case "payer_email":
80 ph.PayerEmail = Convert.ToString(sValue);
81 break;
82
83 case "Tx Token":
84 ph.TxToken = Convert.ToString(sValue);
85 break;
86
87 case "last_name":
88 ph.PayerLastName = Convert.ToString(sValue);
89 break;
90
91 case "receiver_email":
92 ph.ReceiverEmail = Convert.ToString(sValue);
93 break;
94
95 case "item_name":
96 ph.ItemName = Convert.ToString(sValue);
97 break;
98
99 case "mc_currency":
100 ph.Currency = Convert.ToString(sValue);
101 break;
102
103 case "txn_id":
104 ph.TransactionId = Convert.ToString(sValue);
105 break;
106
107 case "custom":
108 ph.Custom = Convert.ToString(sValue);
109 break;
110
111 case "subscr_id":
112 ph.SubscriberId = Convert.ToString(sValue);
113 break;
114 }
115 }
116
117 return ph;
118 }
119 catch (Exception ex)
120 {
121 throw ex;
122 }
123 }
124 }
125 }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900