• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 571
  • Last Modified:

Implementing a paypal with a custom built shopping cart

Hi

I have developed my ecommerce website in asp.net which has its own custom shopping cart. Having read quite a bit about web payments standard it appears that you submit data using a form tag for processing your data at the paypal end.

I found an example of this process online which incidently does not work but there is enough code to demonstrate the process.

My Question is this.
If a user has filled up my shopping cart with say 5 items and different quantities how would I send this to paypal? If I bundle the items up under one title and send this as one transaction how will I know what items my customer has bought? My problem is, without capturing customer details I cannot store orders so how does this work?


On checkout.aspx.....
protected void btnPaypalCheckout_Click(object sender, EventArgs e)
    {
        Page.Validate();
        if (Page.IsValid)
        {
            //store data
            SelectedInvoice.ContactName = this.txtBillingName.Text;
            SelectedInvoice.ContactPhone = this.txtBillingPhone.Text;
            SelectedInvoice.ContactEmail = this.txtBillingEmail.Text;

            SelectedInvoice.ContactAddress1 = this.txtBillingAddress1.Text;
            SelectedInvoice.ContactAddress2 = this.txtBillingAddress2.Text;
            SelectedInvoice.ContactCity = this.txtBillingCity.Text;
            SelectedInvoice.ContactStateProvince = this.cboBillingState.SelectedValue;
            SelectedInvoice.ContactZip = this.txtBillingZip.Text;

            SelectedInvoice.ShipToAddress1 = this.txtShipToAddress1.Text;
            SelectedInvoice.ShipToAddress2 = this.txtShipToAddress2.Text;
            SelectedInvoice.ShipToCity = this.txtShipToCity.Text;
            SelectedInvoice.ShipToStateProvince = this.cboShipToState.SelectedValue;
            SelectedInvoice.ShipToZip = this.txtShipToZip.Text;

            SelectedInvoice.CustomerComments = this.txtCustomerComments.Text;

            Session["Invoice"] = SelectedInvoice;

            //redirect
            Response.Redirect("PayPalProcessing.aspx");
        }
    }

On PaypalProcessing.aspx....

Code Behind
private Invoice _selectedInvoice = new Invoice();
    public Invoice SelectedInvoice
    {
        get
        {
            if (_selectedInvoice.InvoiceId == "")
            {
                try
                {
                    _selectedInvoice = (Invoice)Session["Invoice"];
                }
                catch { }               
            }
            return _selectedInvoice;
        }
    }

HTML Section
<!-- item_number should get passed back -->
		<form id="Paypal" name="Paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
			
			<input type="hidden" name="cmd" value="_cart" />
			<input type="hidden" name="upload" value="1" />
			
			<!-- The following is for aggregated PayPal data instead of itemized -->
			<!--
			<input type="hidden" name="item_name" value="Aggregated Items" />
			<input type="hidden" name="amount" value="<%=SelectedInvoice.Total.ToString("#.00") %>" />
			-->
			
			<!-- The following is for itemized PayPal data instead of the aggregated version -->
			<%=SelectedInvoice.PaypalItemList%>
			<input type="hidden" name="tax_cart" value="<%=SelectedInvoice.Taxes.ToString("#.00")%>" />
			
			<!-- STANDARD DATA -->
			<input type="hidden" name="business" value="<%=System.Web.Configuration.WebConfigurationManager.AppSettings["paypalAccount"] %>" />
									
			<input type="hidden" name="invoice" value="<%=SelectedInvoice.InvoiceId.ToString()%>" />
			<input type="hidden" name="no_note" value="0" /> 
			<input type="hidden" name="currency_code" value="<%=SelectedInvoice.Currency %>" />
			<input type="hidden" name="lc" value="<%=SelectedInvoice.ShipToCountry %>" /> 
			<input type="hidden" name="return" value="<%=System.Web.Configuration.WebConfigurationManager.AppSettings["websiteUrl"] %>/ThankYou.aspx" />
			<input type="hidden" name="cancel_return" value="<%=System.Web.Configuration.WebConfigurationManager.AppSettings["websiteUrl"] %>" />
			<input type="hidden" name="email" value="<%=System.Web.Configuration.WebConfigurationManager.AppSettings["paypalAccount"] %>" /> 
			<input type="hidden" name="cn" value="How did you hear about us?" />
           <input type="submit" value="Submit Payment Info" />
		</form>
		<%=SelectedInvoice.ToString() %>

Open in new window

0
jazz__man
Asked:
jazz__man
  • 2
1 Solution
 
Friman001Commented:
I would go to paypal to ask about this.  I would assume they have a way to send data to them.  You could very easily store all the information from your website into a struct and have easy access to it for send, but as far as sending to paypal, I would say that they would have a method to do that.
0
 
Friman001Commented:
I really don't see anything to do with the amount of items or what they purchesed in the checkout code behind file or even how much money they spent.  You would need to add fields for the item name, quantity, cost, ect., too!
0
 
CSIPComputingCommented:
Paypal publishes a full API for this sort of transaction with full 2-way confirmation and handshaking.

This includes a sandbox environment where you can test etc,

Search paypal for IPN the Instant Payment Notification system.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now