protected void Page_Load(object sender, EventArgs e) { try { byte[] parameters = Request.BinaryRead(HttpContext.Current.Request.ContentLength); if (parameters.Length > 0) { IPNMessage ipn = new IPNMessage(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; } }
public void IPNRequest() { NameValueCollection nvc = HttpUtility.ParseQueryString(ipnMsg); IPNMessage ipn = new IPNMessage(nvc); Assert.IsTrue(ipn.Validate()); }
public void IPNRequestInvalid() { NameValueCollection nvc = HttpUtility.ParseQueryString("test=tests"); IPNMessage ipn = new IPNMessage(nvc); Assert.IsFalse(ipn.Validate()); }
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; } }
/// <summary> /// IPN messages received. /// This is only for handling special cases like sending email or /// automating a workflow. It is not for simple transactions /// </summary> public void HandleIPNMessage(byte[] parameters) { if (parameters != null && parameters.Length > 0) { // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer at // (https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters) Dictionary <string, string> configurationMap = FWUtils.ConfigUtils.GetAppSettings().Paypal.GetConfig(); IPNMessage ipn = new IPNMessage(configurationMap, parameters); bool isIpnValidated = ipn.Validate(); string transactionType = ipn.TransactionType; NameValueCollection map = ipn.IpnMap; string logMsg = "Map:" + map + "\r\n" + "TranType:" + transactionType + "\r\n" + "IsValidated:" + isIpnValidated; long?userId = null; if (FWUtils.SecurityUtils.IsUserAuthenticated()) { userId = FWUtils.SecurityUtils.GetCurrentUserIDLong(); } FWUtils.ExpLogUtils.Logger.WriteLog(new AppLog() { AppLogTypeID = (short)EntityEnums.AppLogType.PayPal_IPNURL, UserID = userId, ExtraString1 = logMsg }); } }
public void IPNConfigMissingIpnEndpoint() { Encoding ipnEncoding = Encoding.GetEncoding("windows-1252"); byte[] message = ipnEncoding.GetBytes(ipnMsg); Dictionary<string, string> config = ConfigManager.Instance.GetProperties(); config.Remove(BaseConstants.IPNEndpointConfig); IPNMessage ipn = new IPNMessage(config, message); Assert.IsTrue(ipn.Validate()); }
public void IPNConfigMissingModeAndIpnEndpoint() { Encoding ipnEncoding = Encoding.GetEncoding("windows-1252"); byte[] message = ipnEncoding.GetBytes(ipnMsg); Dictionary<string, string> config = ConfigManager.Instance.GetProperties(); config.Remove(BaseConstants.ApplicationModeConfig); config.Remove(BaseConstants.IPNEndpointConfig); IPNMessage ipn = new IPNMessage(config, message); Assert.Throws(typeof(ConfigException), new NUnit.Framework.TestDelegate(delegate { ipn.Validate(); } )); }
public void IPNConfigMissingIpnEndpoint() { Encoding ipnEncoding = Encoding.GetEncoding("windows-1252"); byte[] message = ipnEncoding.GetBytes(ipnMsg); Dictionary <string, string> config = ConfigManager.Instance.GetProperties(); config.Remove(BaseConstants.IPNEndpointConfig); IPNMessage ipn = new IPNMessage(config, message); Assert.IsTrue(ipn.Validate()); }
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); } }