Пример #1
0
    public string GetCustomerID(IPNHolder ipn)
    {
        var Custom = ipn._custom.Split(',');
        //var custom = GetProjectID() + "," + GetCustomerID() + "," + GetPaymentID();
        int ProjectId = int.Parse(Custom[0]);
        int CustomerId = int.Parse(Custom[1]);
        int PaymentId = int.Parse(Custom[2]);

        return CustomerId.ToString(CultureInfo.InvariantCulture);
    }
Пример #2
0
 protected string GetProfessionalID(IPNHolder pdt)
 {
     ProfessionalPDTDataSetTableAdapters.ProfessionalTransactionForIPNTableAdapter ProfessionalTransactionForIpnAdapter =
         new ProfessionalPDTDataSetTableAdapters.ProfessionalTransactionForIPNTableAdapter();
     ProfessionalPDTDataSet.ProfessionalTransactionForIPNDataTable ProfessionalTransactionForIpnTable =
         new ProfessionalPDTDataSet.ProfessionalTransactionForIPNDataTable();
     ProfessionalTransactionForIpnAdapter.FillProfessionalIDForIPN(ProfessionalTransactionForIpnTable,
                                                           Convert.ToInt32(pdt._custom));
     return ProfessionalTransactionForIpnTable.Rows[0]["ProfessionalID"].ToString();
 }
Пример #3
0
 protected string GetCustomerID(IPNHolder pdt)
 {
     CustomerPDTDataSetTableAdapters.CustomerTransactionForIPNTableAdapter  CustomerTransactionForIpnAdapter =
         new CustomerPDTDataSetTableAdapters.CustomerTransactionForIPNTableAdapter();
     CustomerPDTDataSet.CustomerTransactionForIPNDataTable CustomerTransactionForIpnTable =
         new CustomerPDTDataSet.CustomerTransactionForIPNDataTable();
     CustomerTransactionForIpnAdapter.FillCustomerIDForIPN(CustomerTransactionForIpnTable,
                                                           Convert.ToInt32(pdt._custom));
     return CustomerTransactionForIpnTable.Rows[0]["CustomerID"].ToString();
 }
Пример #4
0
    //From ProcessIpn to GetNextSuccessfulIPNID
    private void ProcessIpn(IPNHolder ipn, string advertiserID)
    {
        //   1  //check that receiver_email is your Primary PayPal email
        //   2  //check the payment_status is Completed
        //   3  //check that payment_amount/payment_currency are correct
        //   4  //check that txn_id has not been previously processed
        //   5  //process payment

        //   4  //check that txn_id has not been previously processed IPN
        using (var context = new SidejobEntities())
        {
            try
            {
                var result = from c in context.CustomerSuccesfulIPNs
                             where c.TransactionId == ipn._txnID
                             select c.TransactionId;

                var resultQuery = result.FirstOrDefault();
                if (resultQuery == null)
                {
                    //TransactionID doesn't Exist In IPN
                    //Custom for the Ad
                    //Passing multiple variables into custom.

                    var Custom = ipn._custom.Split(',');
                    //var custom = GetProjectID() + "," + GetCustomerID() + "," + GetPaymentID();
                    int ProjectId = int.Parse(Custom[0]);
                    int CustomerId = int.Parse(Custom[1]);
                    int PaymentId = int.Parse(Custom[2]);

                    float paymentGross = float.Parse(ipn._paymentGross);
                    float paymentFees = float.Parse(ipn._paymentFee);
                    float paymentDue = paymentGross - paymentFees;

                    //3//check that payment_amount are correct
                    var result2 = from c in context.CustomerPaymentDues
                                  where c.CustomerID == CustomerId && c.ProjectID == ProjectId && Math.Abs(c.PaymentDue - paymentGross) < 0.00001
                                  select c.ProjectID;
                    var resultQuery2 = result2.FirstOrDefault();
                    if (resultQuery2 != 0)
                    {
                        //   4 b //check that txn_id has not been previously processed ipn
                        var result3 = from c in context.CustomerSuccessfulPDTs
                                      where c.TransactionId == ipn._txnID && c.PaymentStatus == "Completed"
                                      select c.PDTID;
                        var resultQuery3 = result3.FirstOrDefault();
                        if (resultQuery3 == 0)
                        {
                            double paymentGross1 = double.Parse(ipn._paymentGross);
                            double paymentFees1 = double.Parse(ipn._paymentFee);

                            //Insert into customeripn
                            var customeripn = new CustomerSuccesfulIPN
                            {
                                IPNID = GetNextSuccessfulIPNID(),
                                GrossTotal = paymentGross1,
                                Invoice = ipn._invoice,
                                PayerStatus = ipn._paymentStatus,
                                FirstName = ipn._firstName,
                                LastName = ipn._lastName,
                                PaymentFee = paymentFees1,
                                BusinessEmail = ipn._business,
                                ReceiverEmail = ipn._receiverEmail,
                                ItemName = ipn._itemName,
                                CurrencyCode = ipn._countryCode,
                                TransactionId = ipn._txnID,
                                Custom = ipn._custom,
                                CustomerID = CustomerId,
                                ProjectID = ProjectId,
                                TxType = ipn._txnType,
                                PendingReason = ipn._pendingReason,
                                SubscriberId = "",
                                PaymentDate = DateTime.Now.Date,
                                Address = ipn._address,
                                City = ipn._city,
                                State = ipn._state,
                                Zip = ipn._zip,
                                Country = ipn._country,
                                CountryCode = ipn._countryCode,
                                AddressStatus = ipn._addressStatus,
                                PaymentStatus = ipn._payerStatus,
                                PayerID = ipn._payerID,
                                PaymentType = ipn._paymentType,
                                NotifyVersion = ipn._notifyVersion,
                                PayerPhone = ipn._payerPhone,
                                Tax = ipn._tax,
                                PayerBusinessName = ipn._payerBusinessName
                            };

                            context.CustomerSuccesfulIPNs.AddObject(customeripn);
                            context.SaveChanges();

                            CustomerPaymentDue currentpaymentdue = (from c in context.CustomerPaymentDues
                                                                    where c.PaymentDueID == PaymentId
                                                                    select c).FirstOrDefault();
                            //Archived Payment Due

                            var archivedpaymentdue = new ArchivedCustomerPayment
                            {
                                CustomerID = currentpaymentdue.CustomerID,
                                PaymentDueID = currentpaymentdue.PaymentDueID,
                                ProjectID = currentpaymentdue.ProjectID,
                                ProjectAmount = currentpaymentdue.ProjectAmount,
                                Date = currentpaymentdue.Date,
                                StatusID = currentpaymentdue.StatusID,
                                CurrencyCode = currentpaymentdue.CurrencyCode,
                                PaymentDue = currentpaymentdue.PaymentDue,
                                PhaseStatus = currentpaymentdue.PhaseStatus,
                                PaymentProcess = currentpaymentdue.PaymentProcess
                            };
                            context.AddToArchivedCustomerPayments(archivedpaymentdue);
                            //Update PaymentDue
                            context.CustomerPaymentDues.DeleteObject(currentpaymentdue);
                            context.SaveChanges();

                            //invoke timeup for customerpayment
                            //Approve Ad
                            //ApproveAd(AdID);

                            //Insert into HistoryTransaction
                            //Delete from PaymentDue
                            //EmailBuyer
                            EmailBuyer(Resources.Resource.PaypalSuccessfulHeader, "Success",
                                       ipn._payerEmail, ipn);
                            //EmailAdmin
                            EmailAdmin(("Successful Payment"), ipn);
                        }

                    }
                }

            }
            catch (Exception e)
            {

            }
        }
    }
Пример #5
0
 private void EmailBuyer(string subject, string reason, string PayerEmail, IPNHolder ipn)
 {
     MailMessage mailObj = new MailMessage();
     mailObj.From = new MailAddress("*****@*****.**");
     mailObj.Subject = subject;
     switch (reason)
     {
         case "Failed":
             mailObj.Body = Resources.Resource.PaypalFailedMessage;
             break;
         case "Denied":
             mailObj.Body = Resources.Resource.PaypalDeniedMessage;
             break;
         case "Success":
             mailObj.Body = ipn._firstName + " " +
                             ipn._lastName + "<br/>"
                             + Resources.Resource.PaymentOf + " "
                             + ipn._currency + " " + ipn._paymentGross
                             + Resources.Resource.SucessfullyCompleted + "<br/>"
                             + Resources.Resource.ConfirmationNumber + " " + ipn._txnID + "<br/>"
                             + Resources.Resource.Sincerely + "<br/>"
                             + Resources.Resource.YourSideJobTeam + "<br/>";
             break;
     }
     mailObj.To.Add(new MailAddress(PayerEmail));
     mailObj.IsBodyHtml = true;
     SmtpClient SmtpMail = new SmtpClient();
     System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("*****@*****.**", "haithem759163");
     SmtpMail.Host = "mail.programmingfundamental.com";
     SmtpMail.UseDefaultCredentials = false;
     SmtpMail.Credentials = basicAuthenticationInfo;
     try
     {
         SmtpMail.Send(mailObj);
     }
     catch (Exception)
     {
         Response.Redirect(Request.Url.ToString());
         throw;
     }
 }
Пример #6
0
 private void EmailAdmin(string subject, IPNHolder pdt)
 {
     string strTo = "*****@*****.**";
     MailMessage MailMsg = new MailMessage(new MailAddress("*****@*****.**"), new MailAddress(strTo));
     MailMsg.BodyEncoding = Encoding.Default;
     MailMsg.Subject = subject.ToString();
     MailMsg.Body = "<br />"
      + "_paymentGross " + pdt._paymentGross + "<br />"
      + "Invoice: " + pdt._invoice + "<br />"
      + "Payment Status: " + pdt._paymentStatus + "<br />"
      + "First Name: " + pdt._firstName + "<br />"
      + "Last Name: " + pdt._lastName + "<br />"
      + "Payment Fee: " + pdt._paymentFee + "<br />"
      + "Business " + pdt._business + "<br />"
      + "Receiver Email: " + pdt._receiverEmail + "<br />"
      + "Item Name: " + pdt._itemName + "<br />"
      + "Currency: " + pdt._currency + "<br />"
      + "TransactionID: " + pdt._txnID + "<br />"
      + "Custom: " + pdt._custom + "<br />"
      + "No Subscriber" + "No Subscriber" + "<br />"
      + "Custom: " + pdt._custom + "<br />"
      + "Transaction Type:" + pdt._txnType + "<br />"
      + "Pending Reason: " + pdt._pendingReason + "<br />"
      + "Date" + System.DateTime.UtcNow + "<br/>"
      + "City: " + pdt._city + "<br />"
      + "State: " + pdt._state + "<br />"
      + "City: " + pdt._city + "<br />"
      + "Zip: " + pdt._zip + "<br />"
      + "Country: " + pdt._country + "<br />"
      + "_addressStatus: " + pdt._addressStatus + "<br />"
      + "_payerStatus: " + pdt._payerStatus + "<br />"
      + "_payerID " + pdt._payerID + "<br />"
      + "_paymentType: " + pdt._paymentType + "<br />"
      + "_notifyVersion: " + pdt._notifyVersion + "<br />"
      + "_payerPhone: " + pdt._payerPhone + "<br />"
      + "_tax: " + pdt._tax + "<br />"
      + "_payerBusinessName: " + pdt._payerBusinessName + "<br />"
      + "--Role--: Customer <br />"
      + "CustomerID" + GetCustomerID(pdt) + "<br />";
     MailMsg.Priority = MailPriority.High;
     MailMsg.IsBodyHtml = true;
     SmtpClient SmtpMail = new SmtpClient();
     System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("*****@*****.**", "haithem759163");
     SmtpMail.Host = "mail.haithem-araissia.com";
     SmtpMail.UseDefaultCredentials = false;
     SmtpMail.Credentials = basicAuthenticationInfo;
     SmtpMail.Send(MailMsg);
 }
Пример #7
0
    //invoke timeup for customerpayment
    //Approve Ad
    //ApproveAd(AdID);
    //protected void ApproveAd(int AdID)
    //{
    //    var context = new AdDatabase();
    //    var approvedAd = (from ad in context.AdGenerals
    //                      where ad.AdID == AdID
    //                      select ad).FirstOrDefault();
    //    approvedAd.IsActive = true;
    //    context.SaveChanges();
    //}
    protected void UpdatePaymentStatus(IPNHolder ipn, string advertiserID)
    {
        try
        {
            using (var context = new SidejobEntities())
            {

                var result = from c in context.CustomerSuccesfulIPNs
                             where c.TransactionId == ipn._txnID
                             select c.TransactionId;

                var resultQuery = result.FirstOrDefault();
                if (resultQuery == null)
                {
                    //TransactionID doesn't Exist In IPN
                    //Custom for the Ad
                    //Passing multiple variables into custom.

                    //int adID2 = int.Parse(adtemp[0]);
                    //  int PaymentDue = int.Parse(adtemp[2]);
                    //Guid advertiserID2 = Guid.Parse(adtemp[1]);
                    //float paymentGross = float.Parse(ipn._paymentGross);
                    //float paymentFees = float.Parse(ipn._paymentFee);
                    //float paymentDue = paymentGross - paymentFees;
                    var Custom = ipn._custom.Split(',');
                    //var custom = GetProjectID() + "," + GetCustomerID() + "," + GetPaymentID();
                    int PaymentId = int.Parse(Custom[2]);
                    CustomerPaymentDue currentpaymentdue = (from c in context.CustomerPaymentDues
                                                            where c.PaymentDueID == PaymentId
                                                            select c).FirstOrDefault();
                    currentpaymentdue.Status = ipn._paymentStatus;
                    currentpaymentdue.PaymentProcess = true;
                    context.SaveChanges();

                }
            }
        }
        catch (Exception)
        {
            EmailAdmin("PayPal: Error Error order...please check your paypal account", ipn);
        }
    }
Пример #8
0
    //public double GrossTotal { get; set; }
    //public int InvoiceNumber { get; set; }
    //public string PaymentStatus { get; set; }
    //public string PayerFirstName { get; set; }
    //public double PaymentFee { get; set; }
    //public string BusinessEmail { get; set; }
    //public string PayerEmail { get; set; }
    //public string TxToken { get; set; }
    //public string PayerLastName { get; set; }
    //public string ReceiverEmail { get; set; }
    //public string ItemName { get; set; }
    //public string Currency { get; set; }
    //public string TransactionId { get; set; }
    //public string SubscriberId { get; set; }
    //public string Custom { get; set; }
    public static IPNHolder Parse(string postData)
    {
        String sKey = null;
        String sValue = null;
        IPNHolder ph = new IPNHolder();

        //try
        //{
        //    //split response into string array using whitespace delimeter
        //    String[] StringArray = postData.Split('\n');

        //    // NOTE:
        //    /*
        //    * loop is set to start at 1 rather than 0 because first
        //    string in array will be single word SUCCESS or FAIL
        //    Only used to verify post data
        //    */

        //    // use split to split array we already have using "=" as delimiter
        //    int i;
        //    for (i = 1; i < StringArray.Length - 1; i++)
        //    {
        //        String[] StringArray1 = StringArray[i].Split('=');

        //        sKey = StringArray1[0];
        //        sValue = HttpUtility.UrlDecode(StringArray1[1]);

        //        // set string vars to hold variable names using a switch
        //        switch (sKey)
        //        {
        //            case "mc_gross":
        //                ph.GrossTotal = Convert.ToDouble(sValue);
        //                break;

        //            case "invoice":
        //                ph.InvoiceNumber = Convert.ToInt32(sValue);
        //                break;

        //            case "payment_status":
        //                ph.PaymentStatus = Convert.ToString(sValue);
        //                break;

        //            case "first_name":
        //                ph.PayerFirstName = Convert.ToString(sValue);
        //                break;

        //            case "mc_fee":
        //                ph.PaymentFee = Convert.ToDouble(sValue);
        //                break;

        //            case "business":
        //                ph.BusinessEmail = Convert.ToString(sValue);
        //                break;

        //            case "payer_email":
        //                ph.PayerEmail = Convert.ToString(sValue);
        //                break;

        //            case "Tx Token":
        //                ph.TxToken = Convert.ToString(sValue);
        //                break;

        //            case "last_name":
        //                ph.PayerLastName = Convert.ToString(sValue);
        //                break;

        //            case "receiver_email":
        //                ph.ReceiverEmail = Convert.ToString(sValue);
        //                break;

        //            case "item_name":
        //                ph.ItemName = Convert.ToString(sValue);
        //                break;

        //            case "mc_currency":
        //                ph.Currency = Convert.ToString(sValue);
        //                break;

        //            case "txn_id":
        //                ph.TransactionId = Convert.ToString(sValue);
        //                break;

        //            case "custom":
        //                ph.Custom = Convert.ToString(sValue);
        //                break;

        //            case "subscr_id":
        //                ph.SubscriberId = Convert.ToString(sValue);
        //                break;
        //        }
        //    }

        //    return ph;
        //}
        //catch (Exception ex)
        //{
        //    throw ex;
        //}

        //ph.PayerCity = "";
        //ph.PayerCountry = "";
        //ph.PayerCountryCode = "";
        //ph.PayerState = "";
        //ph.PayerAddressStatus = "";
        //ph.PayerAddress = "";
        //ph.PayerZipCode = "";
        //ph.PayerFirstName = "";
        //ph.PayerLastName = "";
        //ph.PayerBusinessName = "";
        //ph.PayerEmail = "";
        //ph.PayerID = "";
        //ph.PayerStatus = "";
        //ph.PayerPhone = "";
        //ph.Business = "";
        //ph.ItemName = "";
        //ph.ItemNumber = "";
        //ph.Quantity = "";
        //ph.ReceiverEmail = "";
        //ph.ReceiverID = "";
        //ph.Custom = "";
        //ph.Memo = "";
        //ph.Invoice = "";
        //ph.Tax = "";
        //ph.QuantityCartItems = "";
        //ph.PaymentDate = "";
        //ph.PaymentStatus = "";
        //ph.PaymentType = "";
        //ph.PendingReason = "";
        //ph.TXN_ID = "";
        //ph.TXN_Type = "";
        //ph.PaymentFee = "";
        //ph.PaymentGross = "";
        //ph.NotifyVersion = "";
        //ph.VerifySign = "";

        ph.RequestLength = HttpContext.Current.Request.Params.ToString();

        ph.PayerCity = HttpContext.Current.Request.Params["address_city"];
        ph.PayerCountry = HttpContext.Current.Request.Params["address_country"];
        ph.PayerCountryCode = HttpContext.Current.Request.Params["address_country_code"];
        ph.PayerState = HttpContext.Current.Request.Params["address_state"];
        ph.PayerAddressStatus = HttpContext.Current.Request.Params["address_status"];
        ph.PayerAddress = HttpContext.Current.Request.Params["address_street"];
        ph.PayerZipCode = HttpContext.Current.Request.Params["address_zip"];
        ph.PayerFirstName = HttpContext.Current.Request.Params["first_name"];
        ph.PayerLastName = HttpContext.Current.Request.Params["last_name"];
        ph.PayerBusinessName = HttpContext.Current.Request.Params["payer_business_name"];
        ph.PayerEmail = HttpContext.Current.Request.Params["payer_email"];
        ph.PayerID = HttpContext.Current.Request.Params["payer_id"];
        ph.PayerStatus = HttpContext.Current.Request.Params["payer_status"];
        ph.PayerPhone = HttpContext.Current.Request.Params["contact_phone"];
        ph.Business = HttpContext.Current.Request.Params["business"];
        ph.ItemName = HttpContext.Current.Request.Params["item_name"];
        ph.ItemNumber = HttpContext.Current.Request.Params["item_number"];
        ph.Quantity = HttpContext.Current.Request.Params["quantity"];
        ph.ReceiverEmail = HttpContext.Current.Request.Params["receiver_email"];
        ph.ReceiverID = HttpContext.Current.Request.Params["receiver_id"];
        ph.Custom = HttpContext.Current.Request.Params["custom"];
        ph.Memo = HttpContext.Current.Request.Params["memo"];
        ph.Invoice = HttpContext.Current.Request.Params["invoice"];
        ph.Tax = HttpContext.Current.Request.Params["tax"];
        ph.QuantityCartItems = HttpContext.Current.Request.Params["num_cart_items"];
        ph.PaymentDate = HttpContext.Current.Request.Params["payment_date"];
        ph.PaymentStatus = HttpContext.Current.Request.Params["payment_status"];
        ph.PaymentType = HttpContext.Current.Request.Params["payment_type"];
        ph.PendingReason = HttpContext.Current.Request.Params["pending_reason"];
        ph.TXN_ID = HttpContext.Current.Request.Params["txn_id"];
        ph.TXN_Type = HttpContext.Current.Request.Params["txn_type"];
        ph.PaymentFee = HttpContext.Current.Request.Params["mc_fee"];
        ph.PaymentGross = HttpContext.Current.Request.Params["mc_gross"];
        ph.NotifyVersion = HttpContext.Current.Request.Params["notify_version"];
        ph.VerifySign = HttpContext.Current.Request.Params["verify_sign"];
        ph.Currency = HttpContext.Current.Request.Params["mc_currency"];

        if (ph.Business == null)
        {
            ph.Business = "";
        }

        return ph;
    }
Пример #9
0
 private void SavedToDatabase(IPNHolder pdt, string ProfessionalID)
 {
     ////Professional IPN ////
     ProfessionalPDTDataSetTableAdapters.ProfessionalIPNTableAdapter ProfessionalIpnAdapter = new ProfessionalPDTDataSetTableAdapters.ProfessionalIPNTableAdapter();
     ProfessionalIpnAdapter.AddTransaction(Convert.ToDouble(pdt._paymentGross), pdt._invoice, pdt._paymentStatus, pdt._firstName, pdt._lastName,
                                       Convert.ToDouble(pdt._paymentFee), pdt._business, pdt._receiverEmail, pdt._itemName, pdt._currency, pdt._txnID, pdt._custom, "No Subscriber",
                                      Convert.ToInt32(ProfessionalID), Convert.ToInt32(pdt._custom), pdt._txnType, pdt._pendingReason, System.DateTime.UtcNow, pdt._address, pdt._city, pdt._state,
                                       pdt._zip, pdt._country, pdt._countryCode, pdt._addressStatus, pdt._payerStatus, pdt._payerID, pdt._paymentType,
                                       pdt._notifyVersion, pdt._payerPhone, pdt._tax, pdt._payerBusinessName);
     ProcessIpn(pdt, ProfessionalID);
 }
Пример #10
0
    protected void ProcessIpn(IPNHolder pdt, string ProfessionalID)
    {
        //   1  //check that receiver_email is your Primary PayPal email
        //   2  //check the payment_status is Completed
        //   3  //check that payment_amount/payment_currency are correct
        //   4  //check that txn_id has not been previously processed
        //   5  //process payment

        //Professional IPN//
        ProfessionalPDTDataSetTableAdapters.ProfessionalIPNTableAdapter ProfessionalIPNTPDTAdapter = new ProfessionalPDTDataSetTableAdapters.ProfessionalIPNTableAdapter();
        ProfessionalPDTDataSet.ProfessionalIPNDataTable ProfessionalIPNTable = new ProfessionalPDTDataSet.ProfessionalIPNDataTable();
        ProfessionalIPNTPDTAdapter.FillProfessionalIPN(ProfessionalIPNTable);

        //Successful PDT//
        ProfessionalPDTDataSetTableAdapters.ProfessionalSuccessfulPDTTableAdapter ProfessionalSuccessfulPDTAdapter = new ProfessionalPDTDataSetTableAdapters.ProfessionalSuccessfulPDTTableAdapter();
        ProfessionalPDTDataSet.ProfessionalSuccessfulPDTDataTable ProfessionalSuccessfulPDTTable = new ProfessionalPDTDataSet.ProfessionalSuccessfulPDTDataTable();

        //Suspicious IPN//
        ProfessionalPDTDataSetTableAdapters.ProfessionalSuspiciousIPNTableAdapter ProfessionalSuspiciousIPNAdapter = new ProfessionalPDTDataSetTableAdapters.ProfessionalSuspiciousIPNTableAdapter();
        ProfessionalPDTDataSet.ProfessionalSuspiciousIPNDataTable ProfessionalSuspiciousIPNTable = new ProfessionalPDTDataSet.ProfessionalSuspiciousIPNDataTable();

        //Transaction History//
        ProfessionalPDTDataSetTableAdapters.QueriesTableAdapter ProfessionalPDT = new ProfessionalPDTDataSetTableAdapters.QueriesTableAdapter();

        foreach (DataRow row in ProfessionalIPNTable.Rows)
        {
            //1///check that receiver_email is your Primary PayPal email
            if (row["ReceiverEmail"].ToString() == "*****@*****.**")
            {
                //2//check the payment_status is Completed
                if (row["PaymentStatus"].ToString() == "Completed")
                {
                    //3//check that payment_amount/payment_currency are correct
                    ProfessionalSuccessfulPDTAdapter.FillProfessionalSuccededPDT(ProfessionalSuccessfulPDTTable, Convert.ToInt32(ProfessionalID), Convert.ToInt32(row["ProjectID"].ToString()));
                    foreach (DataRow row1 in ProfessionalSuccessfulPDTTable.Rows)
                    {
                        if ((string.Equals(row1["CurrencyCode"].ToString(), row["CurrencyCode"].ToString())) && (string.Equals(row1["GrossTotal"].ToString(), row["GrossTotal"].ToString())))
                        {
                            //Professional had the confirmation page and the amount is right
                            //Successful IPN//
                            ProfessionalPDTDataSetTableAdapters.ProfessionalSuccesfulIPNTableAdapter ProfessionalSuccessfulIPNAdapter = new ProfessionalPDTDataSetTableAdapters.ProfessionalSuccesfulIPNTableAdapter();
                            ProfessionalPDTDataSet.ProfessionalSuccesfulIPNDataTable ProfessionalSuccessfulIPNTable = new ProfessionalPDTDataSet.ProfessionalSuccesfulIPNDataTable();

                            //4//check that txn_id has not been previously processed
                            ProfessionalSuccessfulIPNAdapter.FillByTransactionID(ProfessionalSuccessfulIPNTable, Convert.ToInt32(row["ProjectID"].ToString()), Convert.ToInt32(ProfessionalID), row["TransactionId"].ToString());
                            if (ProfessionalSuccessfulIPNTable.Rows.Count == 0)
                            {
                                //Insert a new record
                                ProfessionalSuccessfulIPNAdapter.AddTransaction(Convert.ToInt32(row["IPNID"].ToString()));
                                //Successful IPN
                                ProfessionalPDT.AddProfessionalTransactionHistory(Convert.ToInt32(ProfessionalID),
                                                                          Convert.ToInt32(row["ProjectID"].ToString()), 0);
                                //EmailBuyer
                                EmailBuyer(Resources.Resource.PaypalSuccessfulHeader, "Success", pdt._payerEmail.ToString(), pdt);
                                //EmailAdmin
                                EmailAdmin(("Successful Payment"), pdt);
                            }
                            else
                            {
                                //the record already exist.Don't do anything.
                            }
                        }
                        else
                        {

                            //Suspicicous GrossTotal , CurrencyCode or ProjectID
                            //Professional Close the window or Hacked
                            //Insert a new record to Suspicious
                            ///Suspicious Checking IPN////
                            ProfessionalPDTDataSetTableAdapters.ProfessionalSuspiciousVerificationTableAdapter ProfessionalSuspiciousCheckinIPNAdapter = new ProfessionalPDTDataSetTableAdapters.ProfessionalSuspiciousVerificationTableAdapter();
                            ProfessionalPDTDataSet.ProfessionalSuspiciousVerificationDataTable ProfessionalSuspiciousCheckinIPNTable = new ProfessionalPDTDataSet.ProfessionalSuspiciousVerificationDataTable();
                            ProfessionalSuspiciousCheckinIPNAdapter.FillCheck(ProfessionalSuspiciousCheckinIPNTable, Convert.ToInt32(row["ProjectID"].ToString()), Convert.ToInt32(ProfessionalID.ToString()));
                            //4//check that IPNID has not been previously processed
                            if (ProfessionalSuspiciousCheckinIPNTable.Rows.Count == 0)
                            {
                                ProfessionalSuspiciousIPNAdapter.AddTransactionByID(Convert.ToInt32(row["IPNID"].ToString()));
                                ProfessionalSuspiciousIPNAdapter.UpdatePendingReason("Suspicious Amount", (Convert.ToInt32(row["IPNID"].ToString())));

                                //EmailAdmin
                                EmailAdmin(("Suspicious Payment"), pdt);

                                //Suspicious IPN
                                ProfessionalPDT.AddProfessionalTransactionHistory(Convert.ToInt32(ProfessionalID),
                                                                          Convert.ToInt32(row["ProjectID"].ToString()), 1);

                            }
                        }
                    } //3//check that payment_amount/payment_currency are correct

                }//2//
                else
                {

                }//2//check the payment_status is Completed
            }//1//
            else
            {

            } //1//check that receiver_email is your Primary PayPal email
        }
    }