Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Auto subscription renewal

Posted on 2010-11-22
4
Medium Priority
?
706 Views
Last Modified: 2012-05-10
Hello Experts,

i am currently commissioned to build a subscription management system and I am not sure how to manage subscription renewals, notification and auto payment any assistance in detail will be appreciated.
0
Comment
Question by:XGIS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34190852
That's a fairly broad question on a somewhat involved task, and "assistance in detail" for such a question is probably beyond the scope of a forum such as this. ;)

But, to offer less detail and more of an overview...

Subscriptions will need to be stored in a database.  A simple Windows service, or scheduled task, to query the database daily WHERE Expires < TODAY() AND AutoRenew = True.  Then process the payment, and if successful update the database with the new subscription details; the System.Net.Mail classes can provide you the means to notify the customer.
0
 
LVL 7

Author Comment

by:XGIS
ID: 34193452
hello tqerbert:

Thanks for your response, I understand that data is stored in a database I have got the sql 2008 schema in place, I was uncertain as to when the subscription expires how does the payment take place, and how is the email sent?? is the email sent via SQL or does a scheduled task run the classes in the website?? and how does the payment take place automatically until the client unsubscribes?
0
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 2000 total points
ID: 34200133
Well, like I said - you'll probably write a program that runs as a Windows Service, or runs as a Scheduled Task, to poll the database.  That program can then process the payment, notify the customer via e-mail of renewal status, perhaps advise them a week ahead of time it's about to auto-renew, etc.

You may be better off asking more specific questions as you actually encounter issues...your project would seem to involve several different issues, not all of which I can help you with.  Searching Experts-Exchange or Google would likely get you most, if not all, the answers you need.

1. How can I securely collect and store customers' payment information (credit card/PayPal/etc) from an ASP.Net application?

2. How can I query a SQL database at regular intervals and get records based on a DateTime column?

3. How can I automatically process a credit card payment using stored information, without human intervention, from a service using C#?

4. How can I send e-mail, through an SMTP server for example, from a .Net application?

These seem to be the questions I think you need to ask, and think you'll find someone has already answered these very questions here on EE; 2 and 4 are easy and I can help with that quickly.

2: Write a program in C# to do the work.  Use some mechanism, such as the Windows Task Scheduler, to run the program at regular intervals.
4: Use System.Net.Mail.SmtpClient and System.Net.Mail.MailMessage to send e-mails via an SMTP server.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Net.Mail;

namespace ConsoleApplication1
{
	class Program
	{
		static void Main(string[] args)
		{
			// Connect to the SQL server
			using (SqlConnection cnx = new SqlConnection("Your Connection String"))
			{
				cnx.Open();

				// Get a SqlCommand object for this connection
				using (SqlCommand cmd = cnx.CreateCommand())
				{
					// Set the SQL query
					cmd.CommandText = "SELECT * FROM Subscriptions WHERE Expires <= @CurrentDate AND AutoRenew = true";
					// Set the value of the @CurrentDate parameter to today's date
					cmd.Parameters.AddWithValue("@CurrentDate", DateTime.Today).DbType = DbType.Date;

					// Create the SMTP client we'll use to send email
					using (SmtpClient smtp = new SmtpClient("your.email.server.com"))
					{
						// Set the logon username/password for the SMTP server (if needed)
						smtp.Credentials = new NetworkCredential("username", "Password");

						// Execute the command, and get a SqlDataReader object
						using (SqlDataReader reader = cmd.ExecuteReader())
						{
							// Loop through each record, process payment, send email
							if (ProcessPayment(reader["CreditCardNumber"].ToString()))
								SendEmail(smtp, reader["EmailAddress"].ToString(), "donotreply@yourdomain.com", "Payment Successful", "Your subscription auto-renewed.", false);
							else
								SendEmail(smtp, reader["EmailAddress"].ToString(), "donotreply@yourdomain.com", "Payment Failed", "Your subscription has expired.", false);
						}
					}
					
				}

				cnx.Close();
			}
		}

		static void SendEmail(SmtpClient smtpClient, string toAddress, string fromAddress, string subject, string message, bool html)
		{
			// Create an email message, set some properties, and use the
			// smtp client that was passed in to send it
			using (MailMessage email = new MailMessage(fromAddress, toAddress))
			{
				email.Body = message;
				email.BodyEncoding = Encoding.UTF8;
				email.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
				email.IsBodyHtml = html;
				email.Priority = MailPriority.High;
				email.Subject = subject;
				email.SubjectEncoding = Encoding.UTF8;
			}
		}

		static bool ProcessPayment(string cardNo)
		{
			// Process the payment here, return true if successful
			// or false otherwise
			return true;
		}
	}
}

Open in new window

0
 
LVL 7

Author Closing Comment

by:XGIS
ID: 34203439
wonderfull
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question