Paypal Code - Validate Credit Card & CreditCard Payment through Website Payments Pro method

Posted by Venkat | Labels: , , ,

How to Validate the CreditCard in asp.net ??

To validate the CreditCard first you have to check the Card Type then followed by
the no.of digits..etc.. on that Specific Card type. here i am using Luhn Algorithm to validate.

So you have place these algorithm on Separate Class file ie: Create

CardValidator.cs on the App_Code Folder and paste the below code.

using System;

public enum CardType
{
    MasterCard, BankCard, Visa, AmericanExpress, Discover, DinersClub, JCB
};

public sealed class CardValidator
{
    private CardValidator() { } // static only

    public static bool Validate(CardType cardType, string cardNumber)
   {
      byte[] number = new byte[16]; // number to validate

      // Remove non-digits
      int len = 0;
      for(int i = 0; i < cardNumber.Length; i++)
      {
         if(char.IsDigit(cardNumber, i))
         {
            if(len == 16) return false; // number has too many digits
            number[len++] = byte.Parse(cardNumber[i].ToString ());
         }
      }

      // Validate based on card type, first if tests length, second tests prefix
      switch(cardType)
      {
         case CardType.MasterCard:
            if(len != 16)
               return false;
            if(number[0] != 5 || number[1] == 0 || number[1] > 5)
               return false;
            break;

         case CardType.BankCard:
            if(len != 16)
               return false;
            if(number[0] != 5 || number[1] != 6 || number[2] > 1)
               return false;
            break;

         case CardType.Visa:
            if(len != 16 && len != 13)
               return false;
            if(number[0] != 4)
               return false;
            break;

         case CardType.AmericanExpress:
            if(len != 15)
               return false;
            if(number[0] != 3 || (number[1] != 4 && number[1] != 7))
               return false;
            break;

         case CardType.Discover:
            if(len != 16)
               return false;
            if(number[0] != 6 || number[1] != 0 || number[2] != 1 || number[3] != 

1)
               return false;
            break;

         case CardType.DinersClub:
            if(len != 14)
               return false;
            if(number[0] != 3 || (number[1] != 0 && number[1] != 6 && number[1] 

!= 8)
               || number[1] == 0 && number[2] > 5)
               return false;
            break;

         case CardType.JCB:
            if(len != 16 && len != 15)
               return false;
            if(number[0] != 3 || number[1] != 5)
               return false;
            break;
        
      }

      // Use Luhn Algorithm to validate
      int sum = 0;
      for(int i = len - 1; i >= 0; i--)
      {
         if(i % 2 == len % 2)
         {
            int n = number[i] * 2;
            sum += (n / 10) + (n % 10);
         }
         else
            sum += number[i];
      }
      return (sum % 10 == 0);
   }
}

I have the task of payment method through paypal pro using Credit Card.i was

googled a lot with paypal site , fourms and came with the sample code.

The PayPal Name-Value Pair API (NVP API) enables you to leverage thefunctionality of the PayPal API by simply sending an HTTP request to PayPal and specifying request parameters using name-value pairs. The NVP API is a lightweight alternative to the PayPal SOAP API and provides access to the same set of functionality as the SOAP API.

Ref: https://www.paypal.com/IntegrationCenter/ic_nvp.html

Here i am usin NVP API for payment through CreditCard using website Payment Pro

Method , we can also use SOAP API for this we need to do

1)setExpressionCheckout

2) DoExpressionCheckout

3) GetExpressionCheckout.

Either we can use API or through Code. I am Registering on Sandbox.paypal to check the code. we have to create the Buyer , seller Account to check the amount has been transferred or not , so it will automatically create the creditcard no, cardtype for the test account, we have to use this to check the Amount Transfer
or not. While testing , the amount was not deducted on the buyer account but it will credited on Seller account  as this is sanbox test, this is not an issue ,while you upload it on live , it will work smoothly.As i was tested with Sandbox - so you can check it on live.

One of the main advantage of this method is , it will not redirect the user to paypal site,instead the process has been doing on background from the same site after successfull transaction it will give the Transactionid ,
act etc.. so you can store this thing on DB.


While page Designing make sure you have these Fields

1) Card Type

2) Textbox for CreditCard Number

3) Expire Date  / Expire Month

4) Pay button / Cancel button

paybutton_Click
try
        {
              bool validateCard = false;
              if (ddlCCType.SelectedValue.ToString() == "Visa")
              {
                  validateCard = CardValidator.Validate( CardType.Visa , 

txtCCNumber.Text);
              }
              else if (ddlCCType.SelectedValue.ToString() == "MasterCard")
              {
                  validateCard = CardValidator.Validate(CardType.MasterCard , 

txtCCNumber.Text);
              }
              else if (ddlCCType.SelectedValue.ToString() == "AMEX")
              {
                  validateCard = CardValidator.Validate(CardType.AmericanExpress, 

txtCCNumber.Text);
              }

            if (validateCard != false)
            {
                  string ipaddress;

                ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

                if (ipaddress == "" || ipaddress == null)
                {
                    ipaddress = Request.ServerVariables["REMOTE_ADDR"];

                }
        Session["ipAddress"] = ipaddress;

         //API Credentials (3-token)

            string strUsername = "troy2._1261822640_biz_api1.gmail.com";

            string strPassword = "1261822646";

            string strSignature = 

"An5ns1Kso7MWUdW4ErQKJJJ4qi4-A60C4mgCoX2-L9FhwhF2rfGtRPeI";

            string strCredentials = "USER=" + strUsername + "&PWD=" + strPassword 

+ "&SIGNATURE=" + strSignature;
        
            // For Sandbox testing use this API 
            string strNVPSandboxServer = "https://api-3t.sandbox.paypal.com/nvp";

            // Fpr Live Server use this API
            string strNVPLiveServer = "https://api-3t.paypal.com/nvp";

            string strAPIVersion = "2.3";

// here i am assigning the credit card type cardno,expiry date/month to
 //the session variable and pass it here 

                       string strNVP = strCredentials + 

"&METHOD=DoDirectPayment&CREDITCARDTYPE=" + Session["cardType"].ToString() + 

"&ACCT=" + Session["cardNo"].ToString() + "&EXPDATE=" + 

Session["expiryDate"].ToString() + "&CVV2=808&AMT=" + Amount_Label.Text + 

"&FIRSTNAME=" + FirstName_Label.Text + "&LASTNAME=" + LastName_Label.Text + 

"&IPADDRESS=" + Session["ipAddress"].ToString() + "&STREET=" + address1 + "+" + 

address2 + "&CITY=" + city + "&STATE=" + state + "&COUNTRY=" + country + "&ZIP=" 

+ zip + "&COUNTRYCODE=US&PAYMENTACTION=Sale&VERSION=" + strAPIVersion;

  //Create web request and web response objects, make sure you using the correct 

server (sandbox/live)

            HttpWebRequest wrWebRequest = 

(HttpWebRequest)WebRequest.Create(strNVPSandboxServer);

            ////Set WebRequest Properties
            wrWebRequest.Method = "POST";

            //// write the form values into the request message
            StreamWriter requestWriter = new 

StreamWriter(wrWebRequest.GetRequestStream());

            requestWriter.Write(strNVP);
            requestWriter.Close();

            //// Get the response.
            HttpWebResponse hwrWebResponse = 

(HttpWebResponse)wrWebRequest.GetResponse();

            StreamReader responseReader = new 

StreamReader(wrWebRequest.GetResponse().GetResponseStream());

            //// and read the response
            string responseData = responseReader.ReadToEnd();

            responseReader.Close();
            Response.Write(Server.UrlDecode(responseData));
               
            }
            else
            {
                validateCard_Label.Text = "Please check your card number...";
            }
            
            
          
        }
        catch (Exception ex)
        {
            throw ex;
        } 

Finally , once your Transaction is success you will get the output ie:TransactionID with ack

EX: Output

ACK=Success&TIMESTAMP=date/timeOfResponse
&CORRELATIONID=debuggingToken&VERSION=2.300000&BUILD=buildNumber
&TOKEN=EC-3DJ78083ES565113B&EMAIL=abcdef@anyemail.com
&PAYERID=95HR9CM6D56Q2&PAYERSTATUS=verified
&FIRSTNAME=John&LASTNAME=Smith...&AMT=15&TRANSACTIONID=24527936A38716

Invalid postback or callback argument.

Posted by Venkat | Labels:

I came across the post on Forums ie:

Invalid postback or callback argument.  Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation

To Solve this issue Make sure that you are using IsPostback on the Page_Load() event of that page.


 page_Load() event
If (!IsPostBack)
{
// bind the data
}

Check whether Querystring is available or not.

Posted by Venkat | Labels: ,

Now , i am going to explain how to check Whether the Querystring is present or available or not.

For ex: I am passing id as a querystring to the page2.aspx from page1.aspx.

So on Page1.aspx


Button1_Clickevent() Response.Redirect("page2.aspx?id=1",false); Then on Page2.aspx Page2_Loadevent() If(!IsPostback) {        If(!String.ISNullOrEmpty(Request.QueryString["id"]))         {               // get the value of Querstring id , if id is not null or empty         }        else if(!String.ISNullOrEmpty(Request.QueryString["name"]))         {              // get the value of name querystring if name is not null or empty         } }   When you run the above code - ie: on Page2.aspx you can get the id Querystring value. this works fine.   
Suppose if you pass some other querystring name ex: name from the Page1.aspx the above code gives
ie: Button2_Clickevent()
         Response.Redirect("page2.aspx?name=Dotnet",false);
Error : Object Reference Exception. 

Because it first check the  if condition so in the first condition it contains id so the querystring id will not present so it leads to the Null reference exception.


to avoid this exception you have to check like this.

Page2_Loadevent()
If(!IsPostback) {   if(Request.QueryString["id"] != null)     {        If(!String.ISNullOrEmpty(Request.QueryString["id"]))         {               // get the value of Querstring id , if id is not null or empty         }   } if ((Request.QueryString["name"] != null)   {         if(!String.ISNullOrEmpty(Request.QueryString["name"]))         {              // get the value of name querystring if name is not null or empty         } }  }
          This if(Request.QueryString["id"] != null)  - checks if id is a QueryString variable.

  If(!String.ISNullOrEmpty(Request.QueryString["id"]))  - Check if the id is empty or not

     

Setting Autocomplete Off for the Textbox

Posted by Venkat | Labels:

Now i have to show how to set the Autocompletetype - off for the asp.net  - Texbox

If you want to set the autoComplete property  off use AutoComplete="off" for the textbox.

ie: Autocomplete in the sense if the user typed some text on the textbox, then once again he entered the some word starting with the same letter, it shows previos typed word shows like a combobox manner.

To avoid showing that previous typed word by setting the autoComplete ="Off" to the Textbox.

if you want to set it for the whole page set it on the Form tag


<form autocomplete="off" id="form1" runat="server">
</form>

Gridview Edit_Update_Delete Manipulation

Posted by Venkat | Labels: ,

We are going to see how to Edit , Delete , update Gridview rows , when the Gridview is binded through Bound Column.
BoundField in Grid view and bind the data to each field using "Edit Column" option in smart tag of grid view.

We can also add images to Edit and Delete option in Grid view "edit columns" by adding a "commandfield".
This is the Code , here i have take some sample table to do this operation.
String con1 = ConfigurationManager.ConnectionStrings["con"].ToString();

DataSet ds = new DataSet();

To Edit Row

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)

{

GridView1.EditIndex = e.NewEditIndex;

bindata();

}


To Update the Rows :
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)

{

string i = GridView1.DataKeys[e.RowIndex].Value.ToString();

int j = Convert.ToInt32(i);

TextBox t1 = new TextBox();

t1 = (TextBox)GridView1.Rows[e.RowIndex].Cells [0].Controls [0];

TextBox t2 = new TextBox();

t2 = (TextBox)GridView1.Rows[e.RowIndex].Cells [1].Controls [0];

TextBox t3 = new TextBox();

t3 = (TextBox)GridView1.Rows[e.RowIndex].Cells [2].Controls [0];



SqlConnection con = new SqlConnection(con1);

string upt = "update Allergies set Allergy = @allergy, Symptoms = @symptom, Action_to_be_taken =@action where Allergy_id=" + j;



SqlCommand cmd = new SqlCommand(upt, con);

cmd.Parameters.Add("@allergy", SqlDbType.VarChar).Value = t1.Text;

cmd.Parameters.Add("@symptom", SqlDbType.VarChar).Value = t2.Text;

cmd.Parameters.Add("@action", SqlDbType.VarChar).Value = t3.Text;

con.Open();



cmd.ExecuteNonQuery();

con.Close();

GridView1.EditIndex = -1;

bindata();

}
To Cancel the Edit rows :

protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)

{

GridView1.EditIndex = -1;

bindata();

}
To Delete the Rows :
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)

{

string i = GridView1.DataKeys[e.RowIndex].Value.ToString();

int j = Convert.ToInt32(i);

SqlConnection con = new SqlConnection(con1);

string del = "Delete from Allergies where Allergy_id=" + j;

SqlCommand cmd = new SqlCommand(del, con);

con.Open();

cmd.ExecuteNonQuery();

con.Close();

GridView1.EditIndex = -1;

bindata();

}

ASP.NET Performance Tips

Posted by Venkat | Labels:

When i checked the Forums there i have seen the post ie: posted by one members  regard ASP.NET Performance, I am have some articles based on performance so with that this too will  be helpful.
For better performance improvement..kindly flow the following YSLOW rules,
Performance Improving Methods( From YSlow)

1. Make fewer HTTP requests

Decreasing the number of components on a page reduces the number of HTTP requests required to render the page, resulting in faster page loads. Some ways to reduce the number of components include: combine files, combine multiple scripts into one script, combine multiple CSS files into one style sheet, and use CSS Sprites and image maps.

2. Content Delivery Network (CDN)

User proximity to web servers impacts response times. Deploying content across multiple geographically dispersed servers helps users perceive that pages are loading faster.

3. Add Expires headers

Web pages are becoming increasingly complex with more scripts, style sheets, images, and Flash on them. A first-time visit to a page may require several HTTP requests to load all the components. By using Expires headers these components become cacheable, which avoids unnecessary HTTP requests on subsequent page views. Expires headers are most often associated with images, but they can and should be used on all page components including scripts, style sheets, and Flash.

4. Compress components with gzip

Compression reduces response times by reducing the size of the HTTP response. Gzip is the most popular and effective compression method currently available and generally reduces the response size by about 70%. Approximately 90% of today's Internet traffic travels through browsers that claim to support gzip.
5. Grade A on Put CSS at top
Moving style sheets to the document HEAD element helps pages appear to load quicker since this allows pages to render progressively.

6. Put JavaScript at bottom

JavaScript scripts block parallel downloads; that is, when a script is downloading, the browser will not start any other downloads. To help the page load faster, move scripts to the bottom of the page if they are deferrable.

7. Avoid CSS expressions

CSS expressions (supported in IE beginning with Version 5) are a powerful, and dangerous, way to dynamically set CSS properties. These expressions are evaluated frequently: when the page is rendered and resized, when the page is scrolled, and even when the user moves the mouse over the page. These frequent evaluations degrade the user experience.

8. Make JavaScript and CSS external

Using external JavaScript and CSS files generally produces faster pages because the files are cached by the browser. JavaScript and CSS that are inlined in HTML documents get downloaded each time the HTML document is requested. This reduces the number of HTTP requests but increases the HTML document size. On the other hand, if the JavaScript and CSS are in external files cached by the browser, the HTML document size is reduced without increasing the number of HTTP requests.

9. Reduce DNS lookups

The Domain Name System (DNS) maps hostnames to IP addresses, just like phonebooks map people's names to their phone numbers. When you type URL www.yahoo.com into the browser, the browser contacts a DNS resolver that returns the server's IP address. DNS has a cost; typically it takes 20 to 120 milliseconds for it to look up the IP address for a hostname. The browser cannot download anything from the host until the lookup completes.

10. Minify JavaScript and CSS

Minification removes unnecessary characters from a file to reduce its size, thereby improving load times. When a file is minified, comments and unneeded white space characters (space, newline, and tab) are removed. This improves response time since the size of the download files is reduced.

11. Avoid URL redirects

URL redirects are made using HTTP status codes 301 and 302. They tell the browser to go to another location. Inserting a redirect between the user and the final HTML document delays everything on the page since nothing on the page can be rendered and no components can be downloaded until the HTML document arrives.

12.Remove duplicate JavaScript and CSS

Duplicate JavaScript and CSS files hurt performance by creating unnecessary HTTP requests (IE only) and wasted JavaScript execution (IE and Firefox). In IE, if an external script is included twice and is not cacheable, it generates two HTTP requests during page loading. Even if the script is cacheable, extra HTTP requests occur when the user reloads the page. In both IE and Firefox, duplicate JavaScript scripts cause wasted time evaluating the same scripts more than once. This redundant script execution happens regardless of whether the script is cacheable.

12. Configure entity tags (ETags)

Entity tags (ETags) are a mechanism web servers and the browser use to determine whether a component in the browser's cache matches one on the origin server. Since ETags are typically constructed using attributes that make them unique to a specific server hosting a site, the tags will not match when a browser gets the original component from one server and later tries to validate that component on a different server.

13. Make AJAX cacheable

One of AJAX's benefits is it provides instantaneous feedback to the user because it requests information asynchronously from the backend web server. However, using AJAX does not guarantee the user will not wait for the asynchronous JavaScript and XML responses to return. Optimizing AJAX responses is important to improve performance, and making the responses cacheable is the best way to optimize them.

14. GET for AJAX requests

When using the XMLHttpRequest object, the browser implements POST in two steps: (1) send the headers, and (2) send the data. It is better to use GET instead of POST since GET sends the headers and the data together (unless there are many cookies). IE's maximum URL length is 2 KB, so if you are sending more than this amount of data you may not be able to use GET.

15. Reduce the number of DOM elements


A complex page means more bytes to download, and it also means slower DOM access in JavaScript. Reduce the number of DOM elements on the page to improve performance.

16. Avoid HTTP 404 (Not Found) error

Making an HTTP request and receiving a 404 (Not Found) error is expensive and degrades the user experience. Some sites have helpful 404 messages (for example, "Did you mean ...?"), which may assist the user, but server resources are still wasted.

17. Reduce cookie size

HTTP cookies are used for authentication, personalization, and other purposes. Cookie information is exchanged in the HTTP headers between web servers and the browser, so keeping the cookie size small minimizes the impact on response time.

18. Use cookie-free domains

When the browser requests a static image and sends cookies with the request, the server ignores the cookies. These cookies are unnecessary network traffic. To workaround this problem, make sure that static components are requested with cookie-free requests by creating a subdomain and hosting them there.


19. Avoid AlphaImageLoader filter

The IE-proprietary AlphaImageLoader filter attempts to fix a problem with semi-transparent true color PNG files in IE versions less than Version 7. However, this filter blocks rendering and freezes the browser while the image is being downloaded. Additionally, it increases memory consumption. The problem is further multiplied because it is applied per element, not per image.

20. Do not scale images in HTML

Web page designers sometimes set image dimensions by using the width and height attributes of the HTML image element. Avoid doing this since it can result in images being larger than needed. For example, if your page requires image myimg.jpg which has dimensions 240x720 but displays it with dimensions 120x360 using the width and height attributes, then the browser will download an image that is larger than necessary.

21. Make favicon small and cacheable

A favicon is an icon associated with a web page; this icon resides in the favicon.ico file in the server's root. Since the browser requests this file, it needs to be present; if it is missing, the browser returns a 404 error (see "Avoid HTTP 404 (Not Found) error" above). Since favicon.ico resides in the server's root, each time the browser requests this file, the cookies for the server's root are sent. Making the favicon small and reducing the cookie size for the server's root cookies improves performance for retrieving the favicon. Making favicon.ico cacheable avoids frequent requests for it.

Regex for Indian Phone Numbers

Posted by Venkat | Labels: ,

Today , we are going to discuss about the Regular Expression for Indian Phone Numbers.
Default there is only few Regex available on .net Regularexperssion validator controls.
so if we want to validate our textbox field like indian phone numbers, landline number we have write it own Expression.

There is expression tools available to - Check the Expression is valid or not. I have no idea about this because i have not used.

To accept Indian (Landline) phone numbers check this Regex   :   /^[0-9]\d{2,4}-\d{6,8}$/

This is indian phone number. where it will take a format of std code 3 to 4 digits, hypen and rest of the 6 to 8 digits.
Ex: 0222-8345622 or 09786-567567


This one is for eight digit no ::  \d{8}    eg: 26440050

This one is for mobile no:: \d{10}     eg: 9998945678

This one is for mobile no with india code \d{13}   eg 9109998945678

This one is for Mobile no with india code then space and then mobile no whith zero as starting :: +\d{2}\s\d{9}    eg:+91 09998945678

Extract the EmailID from the Text File

Posted by Venkat | Labels: ,

Here is the another article ie: which is going to find the emailID on the Text File and assign to a string.

Here i have the Textfile ie: Notepad File on the Server folder.

in the notepad file i have some content and emailID too, so i want to get the EmailID from the file so i have to send email to that user.

For this i am using REGEX so its easy to find the emailID on the text file and add or store it on arrays.

Here i am using the Two Method both are using REGEX pattern.


Here you go.. I tested - its working fine.

First Method:

using System.Text.RegularExpressions;
using System.IO;

try
{
//the file is in the root - you may need to change it
string filePath = MapPath("~") + "/EmailText.txt";

using (StreamReader sr = new StreamReader( filePath) )
{
string content = sr.ReadToEnd();
if (content.Length > 0)
{
//this pattern is taken from Asp.Net regular expression validators library
string pattern = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
MatchCollection mc = Regex.Matches(content, pattern);
for (int i = 0; i < mc.Count; i++)
{
//here am just printing it.. You can send mails to mc[i].Value in thsi loop
Response.Write(mc[i].Value + "
");
}
}
}
}
catch (Exception ee)
{
Response.Write(ee.Message);
}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Second Method:

string pattern = @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";

System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(pattern);

//Read file
string sFileContents =System.IO.File.ReadAllText(Server.MapPath("Email.txt"));

System.Text.RegularExpressions.MatchCollection mc = reg.Matches(sFileContents);

//string array for stroing
System.Collections.Generic.List str = new System.Collections.Generic.List();foreach (System.Text.RegularExpressions.Match m in mc)

{

str.Add(m.Value);

}

OUTPUT

input file
----------

jeevan@test.com This e-mail address is being protected from spambots. You need JavaScript enabled to view it ,

Welcome yo Hyderabadtechies.info
test@test.com This e-mail address is being protected from spambots. You need JavaScript enabled to view it ,
its really cool....

Chandrasekarthotta@gmail.com This e-mail address is being protected from spambots. You need JavaScript enabled to view it

sdf

sdfs

dfsd



output :


jeevan@test.com This e-mail address is being protected from spambots. You need JavaScript enabled to view it , test@test.com This e-mail address is being protected from spambots. You need JavaScript enabled to view it , Chandrasekarthotta@gmail.com

Difference between TypeOf and GetType

Posted by Venkat | Labels: ,

Here I am going to discuss about the  -  Difference between typeof and GetType ? - typeof and GetType produce the exact same information. But the difference is where they get this information from:

* typeof is used to get the type based on a class. That means if you use typeof with object, it will gives you error. You must pass class as parameter.
* Where GetType is used to get the type based on an object (an instance of a class). Means GetType needs parameter of object rather than class name.

You can understand more with example.

The following code will output “True”:

string instance = “”;

Type type1 = typeof(string);

Type type2 = instance.GetType();

Console.WriteLine(type1 == type2);

Generate 16 Digit Unique Number in CSharp

Posted by Venkat | Labels: ,

Now i am going ot discuss about how to Generate 16 digit Unique number
So ,

5 digit Random using System.Random Class

5 digit number by using TimeSpan

6 numbers by System Time (HH:MM:SS)

This is the Code

System.Random fiveRandom = new Random();
TimeSpan tsFive = new TimeSpan();
tsFive = DateTime .Now.Subtract (Convert.ToDateTime ("01/01/1900"));
string rad = fiveRandom.Next(10000, 99999) +  tsFive.Days.ToString() +   System.DateTime.Now.Hour.ToString ("00") +          System.DateTime.Now.Minute.ToString ("00") +   System.DateTime.Now.Second.ToString ("00")  ;

PayOffers.in