Low cost ecommerce web development India flash website design
STARTING WITH PAYPAL
I have been searching the web for lots of e-commerce tools, credit cards gateways, etc., but the most simple way I have found remains Paypal. They have millions of customer worldwide, and their program is very simple to use. The fee for using paypal is from 0.7% to 2.9% with a 30 ¢ comission per each transaction, which is not bad, considering that other merchants would take up to 5%!
The only problem with paypal is that only French and American banks are allowed. So if you haven't a bank account in France or in the U.S. forget it!
There is a paypal feature called IPN (Instant Paypment Notification), that is a very a good feature. Suppose you buy some products at our virtual store, click on "add to cart", and then checkout. As soon as you pay or by your credit card (or by your paypal account), a script will be executed after the payment was done, performing the database update, and even could send an e-mail to the buyer.
So if you don't still have a paypal account, I suggest you to open one at www.paypal.com
I recommend you open a second paypal account (a Personal account is enough) with no credit card, just for testing. I explain: once you want to test your Paypal script, you can send money to that second account, and thereafter be refunded to yourself!
EXPLANATIONS - THE DATABASE
The database itself is very simple we have a Sales, Products and Customers table.
Picture 1 - The database relations
THE APPLICATION
The application itself is quite simple. Starting with the Global.asax file, we have 3 data adapters (set in design mode) which refers to the database tables, a dataset, named dsPaypalSample. I have changed the connection string at startup to dinamically set the path to the application.
GLOBAL.ASAX
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session is started
cnnPaypalSample.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ Request.MapPath(Request.ApplicationPath) & "/Data/PaypalSample.mdb"
Session("adptCustomers") = adptCustomers
Session("adptProducts") = adptProducts
Session("adptSales") = adptSales
End Sub
DEFAULT.ASPX:
We have a datagrid, which is bound to a dataset, "dsPaypalSample"
Dim adptProducts As OleDbDataAdapter
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
adptProducts = Session("adptProducts")
adptProducts.Fill(DsPaypalSample)
grdProducts.DataBind()
End Sub
It outputs the following screen:
Picture 2 - The main page's output (default.aspx)
How it works? When the user clicks on "Add to Cart", then the Item Number, Name and Price is passed to the Paypal Cart, in a new window (see Picture 4)
(SAVED IN ECOMMERCE FOLDER)
Picture 3 - Partial view of Default.aspx
The notify URL is very important, because it lets Paypal know where the Paypal IPN script is. When a user clicks on add to cart, the following windows appear: Picture 4 - Add to Cart. But where is the info for the Business' e-mail? (in this case rdesalbres@yahoo.com). Simple, it is set when you click on the toolbox, and set the new component's "Business" property to your paypal address. Picture 5 - Toolbox PAYPALIPN.ASPX Now let's take a look at the most interesting part. We have some data which can be retrieved from Paypal, such as customer's address, name, e-mail, etc. ..... Quantity = Request.Params("quantity") Invoice = Request.Params("invoice") Custom = Request.Params("custom") Payment_status = Request.Params("payment_status") Pending_reason = Request.Params("pending_reason") Payment_date = Request.Params("payment_date") Payment_fee = Request.Params("payment_fee") ..... Now we use a variable to loop thought the number of cart items (each time the user presses the "Add to Cart" button) CartItems = Request.Params("num_cart_items") For i = 1 To CartItems ItemNo(i) = Request.Params("item_number" & i) Next i Finally we use datasets to perform the database's changes. Dim adptCustomers As OleDbDataAdapter = Session("adptCustomers") adptCustomers.Fill(dsPaypalSample) Dim rowCustomer As dsPaypalSample.CustomersRow = dsPaypalSample.Customers.NewRow() With rowCustomer .Full_Name = First_name & " " & Last_name .Address = Address_street & " " & Address_city & " " & Address_zip & " " & Address_country ._e_mail = Payer_email End With Dim IDCustomers As Integer = rowCustomer.IDCustomers dsPaypalSample.Customers.Rows.Add(rowCustomer) adptCustomers.Update(dsPaypalSample) Dim adptSales As OleDbDataAdapter = Session("adptSales") adptSales.Fill(dsPaypalSample) For i = 1 To CartItems Dim rowSales As dsPaypalSample.SalesRow = dsPaypalSample.Sales.NewRow() rowSales.IDProducts = ItemNo(i) rowSales.IDCustomers = IDCustomers dsPaypalSample.Sales.Rows.Add(rowSales) Next i adptSales.Update(dsPaypalSample) And that's it! The possibilities are endless!
freelance web designer India web development
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73