public static void Send(PayPalIPN payPalIPN, bool resend = false) { Logger.Trace0("enter."); var productName = payPalIPN.PayPal.ItemNumber; var name = payPalIPN.PayPal.PayerFirstName + " " + payPalIPN.PayPal.PayerLastName; var email = payPalIPN.PayPal.PayerEmail; if (String.IsNullOrEmpty(name.Trim())) { // make note of this var error = String.Format("{0} [{1}] [{2}]", "Name value is blank.", name.Trim(), email); payPalIPN.EmailUs(error); Logger.TraceErr(error); } else { string licenseKey; var product = Helper.GetProductAndLicenseKey(name, email, productName, out licenseKey); Logger.TraceInfo("Sending key [" + licenseKey + "] to " + name); var emailBody = GetBuyerLicenseKeyEmailTemplate(product.FriendlyName, name, licenseKey, product.DownloadLink); // email name and key to the end user payPalIPN.EmailBuyer(String.Format(Settings.Default.BuyerLicenseKeyEmailSubject, (object)product.FriendlyName), emailBody); payPalIPN.EmailUs(String.Format("{0} [{1}] [{2}]", String.Format(Settings.Default.UsLicenseSentEmailSubject, (object)product.FriendlyName), name, Utility.FormatLicenseKey(licenseKey))); decimal fee; Decimal.TryParse(payPalIPN.PayPal.PaymentFee, out fee); decimal productPrice; Decimal.TryParse(payPalIPN.PayPal.PaymentGross, out productPrice); decimal ourTake = productPrice - fee; // update the database unless this is a resend) if (!resend) { try { StoreLicenseInformation(name, email, productName, licenseKey, productPrice, ourTake, payPalIPN.PayPal.RawData); } catch (Exception exception) { payPalIPN.EmailUs(String.Format("{0} [{1}] [{2}]", exception.Message, name, Utility.FormatLicenseKey(licenseKey))); throw; } } } Logger.Trace0("exit."); }
public static PayPalIPN Create() { Crypto.ResetIV(); Crypto.ResetKey(); var result = new PayPalIPN(Settings.Default.IPNMode) { FromEmail = Settings.Default.FromEmail, SmtpHostUserName = Settings.Default.SmtpHostUserName, SmtpHostPassword = Crypto.BytesToAscii(Crypto.DecryptFromBase64String( Settings.Default.SmtpHostPassword)), SmtpHost = Settings.Default.SmtpHostAddress, SmtpPort = Settings.Default.SmtpHostPort, IsSmtpHostSSL = Settings.Default.IsSmtpHostSSL, UsEmail = Settings.Default.PayPalPrimaryEmail, IsBodyHTML = Settings.Default.IsBuyerEmailHTML }; return result; }