/// <summary> /// valid strings are "TEST" for sandbox use /// "LIVE" for production use /// </summary> /// <param name="mode"></param> public IPNHandler(PaypalPaymentFactory.PaypalMode mode, HttpContext context) { try { this.ModeLiveTest = mode; //Boomers.Utilities.Documents.TextLogger.LogItem("paypalIPN", "getting base url"); this.PostUrl = PaypalPaymentFactory.GetBaseUrl(mode); //Boomers.Utilities.Documents.TextLogger.LogItem("paypalIPN", "filling properties"); this._Message = this.FillIPNProperties(context); //Boomers.Utilities.Documents.TextLogger.LogItem("paypalIPN", "checking status"); //throw new Exception("Boom"); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } }
/// <summary> /// /// </summary> /// <returns>url to redirect to paypal</returns> private string PerformPaypalSubscriptionCheckout() { try { PaypalPaymentFactory sendingPayPal = new PaypalPaymentFactory(); sendingPayPal.Amount = (double)invoice.Subscription.Price; sendingPayPal.BuyerEmailAddress = invoice.InvoiceBilling.Email; sendingPayPal.Code = invoice.Currency; sendingPayPal.ItemName = invoice.Subscription.Description; if (invoice.Mode == PaymentMode.Live) { sendingPayPal.Mode = PaypalPaymentFactory.PaypalMode.live; sendingPayPal.ReturnUrl = ServerConfig.LEAGUE_SUBSCRIPTION_RECIEPT + invoice.InvoiceId.ToString().Replace("-", ""); sendingPayPal.SellerEmailAddress = ServerConfig.DEFAULT_ADMIN_EMAIL_ADMIN; sendingPayPal.CancelUrl = ServerConfig.LEAGUE_SUBSCRIPTION_ADDSUBSUBSCRIBE + invoice.Subscription.InternalObject.ToString().Replace("-", ""); } else if (invoice.Mode == PaymentMode.Test) { sendingPayPal.Mode = PaypalPaymentFactory.PaypalMode.test; sendingPayPal.ReturnUrl = ServerConfig.LEAGUE_SUBSCRIPTION_RECIEPT_DEBUG + invoice.InvoiceId.ToString().Replace("-", ""); sendingPayPal.SellerEmailAddress = ServerConfig.PAYPAL_SELLER_DEBUG_ADDRESS; sendingPayPal.CancelUrl = ServerConfig.LEAGUE_SUBSCRIPTION_ADDSUBSUBSCRIBE_DEBUG + invoice.Subscription.InternalObject.ToString().Replace("-", ""); } sendingPayPal.InvoiceNumber = invoice.InvoiceId.ToString(); sendingPayPal.LogoUrl = ServerConfig.LOGO_URL; EmailServer.EmailServer.SendEmail(ServerConfig.DEFAULT_EMAIL, ServerConfig.DEFAULT_EMAIL_FROM_NAME, ServerConfig.DEFAULT_ADMIN_EMAIL_ADMIN, "Paypal Payment Sent To Paypal", invoice.InvoiceId + " Amount:" + invoice.Subscription.Price); return sendingPayPal.RedirectToPaypal(); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return String.Empty; }