Monday, January 31, 2011

Recurring payment


Recurring payment

I used iTransact payment in my application for Recurring payment.
There are two mode available in Recurring payment
such as
Recurring Billing
Recurring Post back

Recurring Billing:

We have to save the recurring details in payment control panel

When a transaction is initially submitted for processing, recurring details may be passed as part of the form that will automatically create future recurring charges, based on the details that you provide. In addition, you may also modify previously submitted transactions and mark them as recurring. This is done via the Transaction Listing.
The Recurring Billing Module is quite sophisticated, but is easy to use. There are two aspects to the module, as explained below

The Recipe Builder

The Recipt Builder may be Daily, Monthly or Yearly depending upon the payment provider


Initiating Recurring Transactions


Recurring transactions may be initiated at the time the original transaction is processed. To initially set a transaction as recurring, simply add the following input fields to your order form. In this example we’ll use the "monthly13" recipe from the examples above and we’ll have the transaction recur six times


HTML Example

<input type="hidden" name="recur_recipe" value="monthly13">

<input type="hidden" name="recur_reps" value="6">



XML Example



<RecurringData>

<RecurRecipe>test</RecurRecipe>

<RecurReps>5</RecurReps>

<!-- Optional (For Split Recurring) -->

<RecurTotal>100.00</RecurTotal>

<!-- Optional (For Split Recurring) -->

<RecurDesc>test2</RecurDesc>

<!-- Optional (For Split Recurring) -->

</RecurringData>



Recurring Post back:

If you use the recurring transaction features of the gateway, you may specify a URL to receive transaction postback information. This can be enabled via the "Account Settings" link in the Control Panel.

To use this feature, enter the URL to be used for postback information. Each time a recurring transaction is processed through payment system,
Payment system will post the transaction results to your URL.

Eample:www.kingslin.com/RecurringPmt.aspx

The Transction details will in hidden values , To fetch the post back values We can use this
sample code in .Net

if (Request.Form["xid"] != null)
        {
            X_Id = Request.Form["xid"];
        }
        if (Request.Form["authcode"] != null)
        {
            Authcode = Request.Form["authcode"];
        }

by using this we can get all Transaction Details




Sample code for RemotePost Method in .Net


<script runat="server">

   

    void PostMe(Object sender,EventArgs e){

        RemotePost myremotepost =  new RemotePost();

        myremotepost.Url = "http://www.kingslin.com/RecurringPmt.aspx";

        myremotepost.Add("xid", "12345");

        myremotepost.Add("authcode", "kings");

        myremotepost.Post();

    }

   



    public class RemotePost{

            private System.Collections.Specialized.NameValueCollection Inputs = new System.Collections.Specialized.NameValueCollection();





            public string Url = "";

            public string Method = "post";

            public string FormName = "form1";

           

            public void Add(string name,string value){

                Inputs.Add(name,value);

            }

           

            public void Post(){

                System.Web.HttpContext.Current.Response.Clear();



                System.Web.HttpContext.Current.Response.Write("<html><head>");

               

                System.Web.HttpContext.Current.Response.Write(string.Format("</head><body onload=\"document.{0}.submit()\">",FormName));

                System.Web.HttpContext.Current.Response.Write(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >",FormName,Method,Url));

                for(int i=0;i< Inputs.Keys.Count;i++){

                    System.Web.HttpContext.Current.Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">",Inputs.Keys[i],Inputs[Inputs.Keys[i]]));

                }

                System.Web.HttpContext.Current.Response.Write("</form>");

                System.Web.HttpContext.Current.Response.Write("</body></html>");



                System.Web.HttpContext.Current.Response.End();

            }

    }

</script>