Beispiel #1
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);
 }
Beispiel #2
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
        }
    }