コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                byte[] parameters = Request.BinaryRead(HttpContext.Current.Request.ContentLength);

                if (parameters.Length > 0)
                {
                    string ipnMsg = Encoding.GetEncoding("windows-1252").GetString(parameters);

                    NameValueCollection nvc = HttpUtility.ParseQueryString(ipnMsg);
                    IPNMessage ipn = new IPNMessage(nvc);
                    bool isIpnValidated = ipn.Validate();
                    string transactionType = ipn.TransactionType;
                    NameValueCollection map = ipn.IpnMap;

                    logger.Info("----------Type-------------------" + this.GetType().Name + "\n"
                               + "*********IPN Name Value Pair****" + map + "\n"
                               + "#########IPN Transaction Type###" + transactionType + "\n"
                               + "=========IPN Validation=========" + isIpnValidated);
                }
            }
            catch (System.Exception ex)
            {
                logger.Debug("Exception in class " + this.GetType().Name + ": " + ex.Message);
                return;
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                byte[] parameters = Request.BinaryRead(HttpContext.Current.Request.ContentLength);

                if (parameters.Length > 0)
                {
                    // Configuration map containing signature credentials and other required configuration.
                    // For a full list of configuration parameters refer in wiki page
                    // (https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters)
                    Dictionary<string, string> configurationMap = Configuration.GetConfig();
                    IPNMessage ipn = new IPNMessage(configurationMap, parameters);

                    bool isIpnValidated = ipn.Validate();
                    string transactionType = ipn.TransactionType;
                    NameValueCollection map = ipn.IpnMap;

                    logger.Info("----------Type-------------------" + this.GetType().Name + "\n"
                               + "*********IPN Name Value Pair****" + map + "\n"
                               + "#########IPN Transaction Type###" + transactionType + "\n"
                               + "=========IPN Validation=========" + isIpnValidated);
                }
            }
            catch (System.Exception ex)
            {
                logger.Debug("Exception in class " + this.GetType().Name + ": " + ex.Message);
                return;
            }
        }
コード例 #3
0
 public void IPNTransaction()
 {
     NameValueCollection nvc = HttpUtility.ParseQueryString(ipnMsg);
     IPNMessage ipn = new IPNMessage(nvc);
     string transactionType = ipn.TransactionType;
     Assert.AreEqual("Adaptive Payment PAY", transactionType);
 }
コード例 #4
0
 public void IPNParameter()
 {
     NameValueCollection nvc = HttpUtility.ParseQueryString(ipnMsg);
     IPNMessage ipn = new IPNMessage(nvc);
     string parameter = ipn.IpnValue("fees_payer");
     Assert.AreEqual("EACHRECEIVER", parameter);
 }
コード例 #5
0
 public void IPNMap()
 {
     NameValueCollection nvc = HttpUtility.ParseQueryString(ipnMsg);
     IPNMessage ipn = new IPNMessage(nvc);
     NameValueCollection ipnMap = ipn.IpnMap;
     Assert.IsNotNull(ipnMap);
 }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {

            try
                {
                        byte[] parameters = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
                        PaymentTransaction paymentTransaction = new PaymentTransaction();
                        PaymentTransactionRepository paymentRepo = new PaymentTransactionRepository();

                        if (parameters.Length > 0)
                        {
                            IPNMessage ipn = new IPNMessage(parameters);
                            bool isIpnValidated = ipn.Validate();
                            string transactionType = ipn.TransactionType;
                            NameValueCollection map = ipn.IpnMap;
                            
                            paymentTransaction.AmountPaid = map["payment_gross"];
                            paymentTransaction.PayPalTransactionId = map["txn_id"];
                            paymentTransaction.UserId = Guid.Parse(map["custom"].ToString());
                            paymentTransaction.Id = Guid.NewGuid();
                            paymentTransaction.IPNTrackId = map["ipn_track_id"];
                            
                            paymentTransaction.PayerEmail = map["payer_email"];
                            paymentTransaction.PayerId = map["payer_id"];
                            paymentTransaction.PaymentStatus = map["payment_status"];

                            
                            
                                logger.Info("Payment Status : " + paymentTransaction.PaymentStatus);
                                logger.Info("User Id : " +paymentTransaction.UserId);
                            

                            paymentTransaction.PaymentDate = DateTime.Now;
                            paymentTransaction.PaypalPaymentDate = map["payment_date"];
                            paymentTransaction.ReceiverId = map["receiver_id"];
                            paymentRepo.SavePayPalTransaction(paymentTransaction);
                            UserRepository userrepo = new UserRepository();
                            if (paymentTransaction.PaymentStatus == "Completed")
                            {
                                userrepo.changePaymentStatus(paymentTransaction.UserId, "paid");
                            }
                        }
                    }
                
                catch (System.Exception ex)
                {
                    logger.Error(ex.StackTrace);
                }
            
            
        }
コード例 #7
0
 public void IPNRequest()
 {
     NameValueCollection nvc = HttpUtility.ParseQueryString(ipnMsg);
     IPNMessage ipn = new IPNMessage(nvc);
     Assert.IsTrue(ipn.Validate());
 }