RSS

Monthly Archives: September 2009

Tag Cloud using ASP.NET

You can implemenet Tag cloud using asp.net. Tag cloud is something using which user can easily identified the particular word under which the number of items are more.

You can find free source code by visiting following links:

http://www.codeproject.com/KB/custom-controls/cloud.aspx 

http://thetagcloud.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=17637

http://www.4guysfromrolla.com/articles/102506-1.aspx

 

 

Happy Progamming!

 
Leave a comment

Posted by on September 4, 2009 in Tag Cloud

 

Tags: , , ,

Authorized.Net payment gateway implementation

Copy paste following code to implement payment gateway using c#.net:

 String post_url = “https://test.authorize.net/gateway/transact.dll“;

            Hashtable post_values = new Hashtable();

            //the API Login ID and Transaction Key must be replaced with valid values
            post_values.Add(“x_login”, “6zz6m5N4Et”);
            post_values.Add(“x_tran_key”, “9V9wUv6Yd92t27t5”);

            post_values.Add(“x_delim_data”, “TRUE”);
            post_values.Add(“x_delim_char”, ‘|’);
            post_values.Add(“x_relay_response”, “FALSE”);

            post_values.Add(“x_type”, “AUTH_CAPTURE”);
            post_values.Add(“x_method”, “CC”);
            post_values.Add(“x_card_num”, “378282246310005”);
            post_values.Add(“x_exp_date”, “0809”);

            post_values.Add(“x_amount”, “99999.00”);
            post_values.Add(“x_description”, “Sample Transaction”);

            post_values.Add(“x_first_name”, “John”);
            post_values.Add(“x_last_name”, “Doe”);
            post_values.Add(“x_address”, “1234 Street”);
            post_values.Add(“x_state”, “WA”);
            post_values.Add(“x_zip”, “98004”);
            // Additional fields can be added here as outlined in the AIM integration
            // guide at: http://developer.authorize.net

            // This section takes the input fields and converts them to the proper format
            // for an http post.  For example: “x_login=username&x_tran_key=a1B2c3D4”
            String post_string = “”;
            foreach(DictionaryEntry field in post_values)
            {
                post_string += field.Key + “=” + field.Value + “&”;
            }
            post_string = post_string.TrimEnd(‘&’);
           
            // create an HttpWebRequest object to communicate with Authorize.net
            HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(post_url);
            objRequest.Method = “POST”;
            objRequest.ContentLength = post_string.Length;
            objRequest.ContentType = “application/x-www-form-urlencoded”;

            // post data is sent as a stream
            StreamWriter myWriter  = null;
            myWriter = new StreamWriter(objRequest.GetRequestStream());
            myWriter.Write(post_string);
            myWriter.Close();

            // returned values are returned as a stream, then read into a string
            String post_response;
            HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
            using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()) )
            {
                post_response = responseStream.ReadToEnd();
                responseStream.Close();
            }

            // the response string is broken into an array
            // The split character specified here must match the delimiting character specified above
            Array response_array = post_response.Split(‘|’);

            // the results are output to the screen in the form of an html numbered list.
            resultSpan.InnerHtml += “<OL> \n”;
            foreach (string value in response_array)
            {
                resultSpan.InnerHtml += “<LI>” + value + “&nbsp;</LI> \n”;
            }
            resultSpan.InnerHtml += “</OL> \n”;
            // individual elements of the array could be accessed to read certain response
            // fields.  For example, response_array[0] would return the Response Code,
            // response_array[2] would return the Response Reason Code.
            // for a list of response fields, please review the AIM Implementation Guide

 

 

Happy programming!.

 
Leave a comment

Posted by on September 4, 2009 in payment gateway

 

Tags: , , ,

Payment Gateway implementation using PayPal

You can use paypal API to pay the amount from your website. There is no need to redirect to paypal site for the same.

prerequisite:

1. The paypal test account is required to test the code.

2. Capicom dll is required

3. Log4net dll is required

4. paypal_base dll is required

Copy past following code in to the CS file:

/*
 * Copyright 2005, 2008 PayPal, Inc. All Rights Reserved.
 *
 * DoDirectPayment SOAP example; last modified 08MAY23.
 *
 * Process a credit card payment. 
 */
using System;
using com.paypal.sdk.services;
using com.paypal.soap.api;
using com.paypal.sdk.profiles;
using System.Configuration;
/**
 * PayPal .NET SDK sample code
 */
namespace GenerateCodeSOAP
{
 public class DoDirectPayment
 {
  public DoDirectPayment()
  {
  }
  public string DoDirectPaymentCode(string paymentAmount, string buyerLastName, string buyerFirstName, string buyerAddress1, string buyerAddress2, string buyerCity, string buyerState, string buyerZipCode, string creditCardType, string creditCardNumber, string CVV2, int expMonth, int expYear, PaymentActionCodeType paymentAction)
  {
   CallerServices caller = new CallerServices();

   IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
   /*
    WARNING: Do not embed plaintext credentials in your application code.
    Doing so is insecure and against best practices.
    Your API credentials must be handled securely. Please consider
    encrypting them for use in any production environment, and ensure
    that only authorized individuals may view or modify them.
    */

              // Set up your API credentials, PayPal end point, and API version.
              profile.APIUsername = “sdk-three_api1.sdk.com”;
              profile.APIPassword = “QFZCWN5HZM8VBG7Q”;
              profile.APISignature = “A.d9eRKfd1yVkRrtmMfCFLTqa6M9AyodL0SJkhYztxUi8W9pCXF6.4NI”;

          

          
   profile.Environment=”sandbox”;           
   caller.APIProfile = profile;
   // Create the request object.
   DoDirectPaymentRequestType pp_Request = new DoDirectPaymentRequestType();
   pp_Request.Version=”3.0″;
           

   // Add request-specific fields to the request.
   // Create the request details object.
   pp_Request.DoDirectPaymentRequestDetails = new DoDirectPaymentRequestDetailsType();

              pp_Request.DoDirectPaymentRequestDetails.IPAddress = “127.0.0.1”;
   /*pp_Request.DoDirectPaymentRequestDetails.MerchantSessionId = “1X911810264059026”;*/
   pp_Request.DoDirectPaymentRequestDetails.PaymentAction = paymentAction;
   
   pp_Request.DoDirectPaymentRequestDetails.CreditCard = new CreditCardDetailsType();
   
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardNumber = creditCardNumber; 
           
   switch (creditCardType)
   {
    case “Visa”:
     pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Visa;
     break;
    case “MasterCard”:
     pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.MasterCard;
     break;
    case “Discover”:
     pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Discover;
     break;
    case “Amex”:
     pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Amex;
     break;
   }
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CVV2 = CVV2;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonth = expMonth;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYear = expYear;
   
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner = new PayerInfoType();
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Payer = “”;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerID = “”;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerStatus = PayPalUserStatusCodeType.unverified;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerCountry = CountryCodeType.US;

   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address = new AddressType();
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Street1 = buyerAddress1;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Street2 = buyerAddress2;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CityName = buyerCity;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.StateOrProvince= buyerState;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.PostalCode = buyerZipCode;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountryName = “USA”;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Country = CountryCodeType.US;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountrySpecified = true;
  
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName = new PersonNameType();
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.FirstName = buyerFirstName;
   pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.LastName = buyerLastName;
   pp_Request.DoDirectPaymentRequestDetails.PaymentDetails = new PaymentDetailsType();
   pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal = new BasicAmountType();
   // NOTE: The only currency supported by the Direct Payment API at this time is US dollars (USD).

   pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.currencyID = CurrencyCodeType.USD;
   pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.Value = paymentAmount;

              // Execute the API operation and obtain the response.
   DoDirectPaymentResponseType pp_response =new DoDirectPaymentResponseType();
   pp_response= (DoDirectPaymentResponseType) caller.Call(“DoDirectPayment”, pp_Request);
   return pp_response.Ack.ToString();
  }
 }
}

 
Leave a comment

Posted by on September 4, 2009 in payment gateway

 

Tags: , , , ,

Drag and Drop gridview columns in AJAX enable gridview for asp.net

Free source code availble for asp.net gridview. You can drag and drop the gridview columns without post back.

Please refer the following links for the same:

 

 

 

 
Leave a comment

Posted by on September 3, 2009 in AJAX GridView

 

Tags: , , , ,

Grab webpage contents using javascript

You can read/fetch web page contents using  javascript.  The page should be available on the live URL. 

Please find the code below:

<script type=”text/javascript”>
    var PageNm;
    var XmlHttpObj;
    var requestURL = ‘getServerTime.aspx’;
    var is_ie = (navigator.userAgent.indexOf(‘MSIE’) >= 0) ? 1 : 0;
    var is_ie5 = (navigator.appVersion.indexOf(“MSIE 5.5”) != -1) ? 1 : 0;
    var is_opera = ((navigator.userAgent.indexOf(“Opera6”) != -1) || (navigator.userAgent.indexOf(“Opera/6”) != -1)) ? 1 : 0;
    //netscape, safari, mozilla behave the same???
    var is_netscape = (navigator.userAgent.indexOf(‘Netscape’) >= 0) ? 1 : 0;  

 

    function GetResponse() {

        var xhr = CreateXmlHttpObj();
        // Page URL needs to be written here
        xhr.open(“GET”, “Web Page URL”, true);
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    statusDiv = document.getElementById(“stats”);

                    alert(xhr.responseText);
                } else {
                    alert(‘error!’);
                }
            }
        };
        xhr.send(null);
    }

    function CreateXmlHttpObj() {
        // try creating for IE (note: we don’t know the user’s browser type here, just attempting IE first.)
        try {
            if (is_ie) {
                //The object to create depends on version of IE
                //If it isn’t ie5, then default to the Msxml2.XMLHTTP object
                var strObjName = (is_ie5) ? ‘Microsoft.XMLHTTP’ : ‘Msxml2.XMLHTTP’;

                //Attempt to create the object
                try {

                    XmlHttpObj = new ActiveXObject(strObjName);
                    //XmlHttpObj.onreadystatechange = handler;
                }
                catch (e) {
                    //Object creation errored
                    alert(‘IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled’);
                    return;
                }
            }
            else if (is_opera) {
                //Opera has some issues with xmlHttp object functionality
                alert(‘Opera detected. The page may not behave as expected.’);
                return;
            }
            else {
                // Mozilla | Netscape | Safari
                XmlHttpObj = new XMLHttpRequest();
               
            }

 
        }
        catch (e) {
            try {
                XmlHttpObj = new ActiveXObject(“Microsoft.XMLHTTP”);
            }
            catch (oc) {
                XmlHttpObj = null;
            }
        }
        // if unable to create using IE specific code then try creating for Mozilla (FireFox)
        if (!XmlHttpObj && typeof XMLHttpRequest != “undefined”) {
            XmlHttpObj = new XMLHttpRequest();
        }

        return XmlHttpObj;
    }

</script>

 

 
1 Comment

Posted by on September 3, 2009 in Crwalling

 

Tags: , , , ,

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

 
Leave a comment

Posted by on September 3, 2009 in Uncategorized