ASP.NET - Code for payment process for shopping cart

Asked By Vikas on 01-Nov-11 01:52 AM
I have a shopping cart project in which we process the payment process through credit card or debit card and PO Number .  I have to design a page which have these three functionality . I dont know how to process the payment throgh Po number . And for the all three payment procedure i have to design separate pages or i can work out in a single page.

Please reply
Kirtan Patel replied to Vikas on 01-Nov-11 01:54 AM
you just have to integrate some payment gateway to your application you dont have to code manually about procedure of the payment and connecting to bank etc ..

you need to integrate service of PaymentGateway like

smr replied to Vikas on 01-Nov-11 01:55 AM

Database: For the purpose, I have used the NorthWind database and SQL Server.

The two main tables used are:

  1. Products table
  2. Order Details table.

I have used two classes:

class CartRow { public string id; public string name; public string price; public string items; }; public class Cart { public System.Collections.ArrayList list = new ArrayList(20); };

Jitendra Faye replied to Vikas on 01-Nov-11 01:56 AM

You'll have to use for that. My site runs with Perl, but the way it basically works is as follows:

  1. Customer fills out an order form at my site with their name, address, email.
  2. Customer is being redirected to Paypal
  3. Upon successful payment via Paypal, Paypal calls my IPN-compliant script
  4. My script sends me an e-mail notifying me about the completed order

If the customer does not pay within 30 minutes or so, my database also sends him a reminder with a Paypal payment link for the respective order.

Follow these links also-

Hope this will help you.

smr replied to Vikas on 01-Nov-11 01:57 AM

The following C# code is an example of how all of the supported credit card providers are integrated into my Invoice business object, which gives you a pretty good idea how the class can be used at the Application level:

public bool ProcessCreditCard()


    bool Result = false;


    wws_invoiceRow Inv = this.Entity;

    wws_customersRow Cust = this.Customer.Entity;


    ccProcessing CC = null;

    ccProcessors CCType = App.Configuration.CCProcessor;




      if (CCType == ccProcessors.AccessPoint)


        CC = new ccAccessPoint();


      else if (CCType == ccProcessors.AuthorizeNet)


        CC = new ccAuthorizeNet();

        CC.MerchantPassword = App.Configuration.CCMerchantPassword;


      else if (CCType == ccProcessors.PayFlowPro)


        CC = new ccPayFlowPro();

        CC.MerchantPassword = App.Configuration.CCMerchantPassword;


      else if (CCType == ccProcessors.LinkPoint)


        CC = new ccLinkPoint();

        CC.MerchantPassword = App.Configuration.CCMerchantPassword;

        CC.CertificatePath = App.Configuration.CCCertificatePath;  

        // ie. "d:\app\MyCert.pem"


      else if (CCType == ccProcessors.PayPalWebPaymentsPro)


        CC = new ccPayPalWebPaymentsPro();

        CC.MerchantPassword = App.Configuration.CCMerchantPassword;

        ((ccPayPalWebPaymentsPro)CC).PrivateKeyPassword = "";


      else if (CCType == ccProcessors.BluePay)


        CC = new ccBluePay();

        CC.MerchantId = App.Configuration.CCMerchantId;

        CC.MerchantPassword = App.Configuration.CCMerchantPassword;



      CC.MerchantId = App.Configuration.CCMerchantId;


      //CC.UseTestTransaction = true;


      // *** Tell whether we do SALE or Pre-Auth

      CC.ProcessType = App.Configuration.CCProcessType;


      // *** Disable this for testing to get provider response

      CC.UseMod10Check = true;


      CC.Timeout = App.Configuration.CCConnectionTimeout;  // In Seconds

      CC.HttpLink = App.Configuration.CCHostUrl;     


      CC.LogFile = App.Configuration.CCLogFile;

      CC.ReferingUrl = App.Configuration.CCReferingOrderUrl;


      // *** Name can be provided as a single string or as firstname and lastname

      //CC.Name = Cust.Firstname.TrimEnd() + " " + Cust.Lastname.TrimEnd();

      CC.Firstname = Cust.Firstname.TrimEnd();

      CC.Lastname = Cust.Lastname.TrimEnd();


      CC.Company = Cust.Company.TrimEnd();

      CC.Address = Cust.Address.TrimEnd();

      CC.State = Cust.State.TrimEnd();

      CC.City = Cust.City.TrimEnd();

      CC.Zip = Cust.Zip.TrimEnd();

      CC.Country = Cust.Countryid.TrimEnd();  // 2 Character Country ID

      CC.Phone = Cust.Phone.TrimEnd();

      CC.Email = Cust.Email.TrimEnd();


      CC.OrderAmount = Inv.Invtotal;

      CC.TaxAmount = Inv.Tax;               // Optional

      CC.CreditCardNumber = Inv.Cc.TrimEnd();

      CC.CreditCardExpiration = Inv.Ccexp.TrimEnd();


      CC.SecurityCode = Inv.Ccsecurity.TrimEnd();


      // *** Make this Unique

      CC.OrderId = Inv.Invno.TrimEnd() + "_" + DateTime.Now.ToString();

      CC.Comment = App.Configuration.CompanyName + " Order # " +


      // *** Result returned as true or false

      Result = CC.ValidateCard();


      // *** Pick up the Validated result values from the class

      Inv.Ccresult = CC.ValidatedResult;

      if (!Result)


        this.ErrorMessage = CC.ValidatedMessage;

        Inv.Ccerror = this.ErrorMessage;



      // *** Always write out the raw response

      if (string.NullOrEmpty(CC.RawProcessorResult))

        Inv.Ccresultx = CC.ValidatedMessage;


        Inv.Ccresultx = CC.RawProcessorResult;


    catch (Exception ex)



      Inv.Ccresult = "FAILED";

      Inv.Ccresultx = "Processing Error: " + ex.Message;

      Inv.Ccerror = "Processing Error: " + ex.Message;

      return false;



    return Result;



Web Star replied to Vikas on 01-Nov-11 01:59 AM
you can use single page for one payment with a PO number which having multiple item in you shopping list
Because better is you can keep One invoice number with each payment either that payment contain multipple item or single item.
So you should pay with PO number and keep tracking that invoice number to corresponding all item within that shopping cart.

If you want to partial buy from shopping cart than you should put checkbox for selection of item just before checkout option and invoice consider only those item which had done in payment checkout.
hope this helps
Reena Jain replied to Vikas on 01-Nov-11 02:02 AM

Always try to provide detail information about your problem or query, so we will be help you in  correct direction. you have not mentioned that for which gateway you are asking like sms or payment. I am assuming that you are asking for payment so here is steps for you

Step 1: PayPal provide lot of thing for developer to integrate PayPal in developer web site. Here our first step is to create a developer account on PayPal so we can test it.

For that just login on PayPal Site

Just create your account over here create a buyer and seller account for testing.
PayPal provide Sandbox site for testing.

Step 2:- Once you have done with creating Sandbox work then here we take a task suppose I am a bike seller and I am selling bikes online then I have following page to show bikes
From here user can buy any bike on my site.
And he can do payment by paypal. For this we used PayPal image which you can get by

Step 3:-
On button click we fill this session as shown below.
Private Sub imgBike5_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgBike5.Click
clsSession = New pub_clsBikeInfo
clsSession.lngId = 5
clsSession.strBikeName = “Harley Davidson Model#005″
clsSession.strBikePrice = Me.lblPrice5.Text
clsSession.strBikeDescription = Me.lblDescription5.Text
Session(pub_clsCommon._strBikeSession) = clsSession
Catch ex As Exception
Throw ex
End Try
End Sub ‘imgBike5_Click

Once this done we go for Second page which is PayPalIntegration.aspx.

Step4:-The payPalIntegration.aspx is the main page from this page we interact with PayPal.
On this form we are using Action =””

 which is basically paypal sandbox address and it’s for testing basically.

We have to send some require fields which are necessary for PayPal as hidden variables.
These hidden fields are like
1) Business: – in this yours PayPal business id save like “”
2)cmd :- in this we put value “_cart”
3)Currency_code:- like USD Or other
4)Item_Name_N :- Where n is Item number sequence like 1,2,3. This will keep Item Name
5)Item_description_N :- where n is the item number Sequence like 1,2,3.This will keep Item Description
6)Amount_N :- Where n is the item number Sequence like 1,2,3. This will keep item amount
Similarly we can assign shipping, notes and other variables if required.

Step 5:- once we done with this fields we just post this form after updating item description, name, and amount as our need.
In this way we can use paypal integration in simplest manner.

You can see test code at

and also download code from

You can find much option as your requirement.

Suchit shah replied to Vikas on 01-Nov-11 02:25 AM
please take a look at this link, it contains starter kit for what you are looking .

Also have a Look at
Vikas replied to Reena Jain on 01-Nov-11 03:32 AM
Do you have any idea about the payment transaction through purchase order number ?