Practical

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 24

E-COMMERCE AND M-COMMERECE

PRACTICAL FILE

(Maharaja Agrasen Institute of technology)

(GURU GOBIND SINGH INDRAPRASTHA UNIVERSITY)

Submitted by Submitted to

SAGAR BHAYANA
02296403113
I-456 (I-6)
EXPERIMENT NO.1

AIM: INTRODUCTION TO E-COMMERECE AND M-COMMERECE

E-Commerce

E-Commerce or Electronics Commerce is a methodology of modern business,


which addresses the need of business organizations, vendors and customers to
reduce cost and improve the quality of goods and services while increasing the
speed of delivery. E-commerce refers to the paperless exchange of business
information using the following ways:
Electronic Data Exchange (EDI)
Electronic Mail (e-mail)
Electronic Bulletin Boards
Electronic Fund Transfer (EFT)
Other Network - based technologies

Features

E-Commerce provides following features : -

1. Non-Cash Payment E-Commerce enables use of credit cards, debit cards,


smart cards, electronic fund transfer via bank's website and other modes of
electronics payment.

2. 24x7 Service availability E-commerce automates business of enterprises and


services provided by them to customers are available anytime, anywhere. Here
24x7 refers to 24 hours of each seven days of a week.

3. Advertising / Marketing E-commerce increases the reach of advertising of


products and services of businesses. It helps in better marketing management of
products / services.

4. Improved Sales Using E-Commerce, orders for the products can be generated
any time, any where without any human intervention. By this way, dependencies to
buy a product reduce at large and sales increases.

SAGAR BHAYANA
02296403113
I-456 (I-6)
5. Support E-Commerce provides various ways to provide pre sales and post
sales assistance to provide better services to customers.

Business Models

E-Commerce or Electronics Commerce business models can generally categorized


in following categories.

Business - to - Business (B2B)


Business - to - Consumer (B2C)
Consumer - to - Consumer (C2C)
Consumer - to - Business (C2B)
Business - to - Government (B2G)
Government - to - Business (G2B)
Government - to - Citizen (G2C)

Business - to - Business (B2B)

Website following B2B business model sells its product to an intermediate buyer
who then sells the product to the final customer. As an example, a wholesaler
places an order from a company's website and after receiving the consignment,
sells the end product to final customer who comes to buy the product at
wholesaler's retail outlet.

SAGAR BHAYANA
02296403113
I-456 (I-6)
Business - to - Consumer(B2C)

Website following B2C business model sells its product directly to a customer. A
customer can view products shown on the website of business organization. The
customer can choose a product and order the same. Website will send a notification
to the business organization via email and organization will dispatch the
product/goods to the customer.

SAGAR BHAYANA
02296403113
I-456 (I-6)
Consumer - to - Consumer (C2C)

Website following C2C business model helps consumer to sell their assets like
residential property, cars, motorcycles etc. or rent a room by publishing their
information on the website. Website may or may not charge the consumer for its
services. Another consumer may opt to buy the product of the first customer by
viewing the post/advertisement on the website.

Consumer - to - Business (C2B)

In this model, a consumer approaches website showing multiple business


organizations for a particular service. Consumer places an estimate of amount
he/she wants to spend for a particular service. For example, comparison of interest
rates of personal loan/ car loan provided by various banks via website. Business
organization who fulfills the consumer's requirement within specified budget
approaches the customer and provides its services.

SAGAR BHAYANA
02296403113
I-456 (I-6)
Business - to - Government (B2G)

B2G model is a variant of B2B model. Such websites are used by government to
trade and exchange information with various business organizations. Such websites
are accredited by the government and provide a medium to businesses to submit
application forms to the government.

Government - to - Business (G2B)

Government uses B2G model website to approach business organizations. Such


websites support auctions, tenders and application submission functionalities.

SAGAR BHAYANA
02296403113
I-456 (I-6)
Government - to - Citizen (G2C)

Government uses G2C model website to approach citizen in general. Such


websites support auctions of vehicles, machinery or any other material. Such
website also provides services like registration for birth, marriage or death
certificates. Main objectives of G2C website are to reduce average time for
fulfilling people requests for various government services.

M-Commerce

Buying and selling products and services through mobile devices are the new
trend. A housewife can purchase her kitchen appliances from the comfort of her

SAGAR BHAYANA
02296403113
I-456 (I-6)
living room, a busy person can order lunch from office, one can use mobile
platforms to sell goods and services all with a few clicks.

What is M-Commerce?

Mobile commerce or simply M-Commerce means engaging users in a buy or sell


process via a mobile device. For instance, when someone buys an Android app or
an iPhone app, that person is engaged in m-commerce. There are a number of
content assets that can be bought and sold via a mobile device such as games,
applications, ringtones, subscriptions etc.

How does M-Commerce Work?

Lets look at some of the points that you need to remember as a business, while
engaging in m-commerce

1. Decide Where to Sell

Before you sell your products or services via m-commerce, you need to decide
what type of outlets or stores suit your business best. Let us suppose you have
created ringtones you can sell them either at specific third-party outlets or to
independent aggregators who charge you a commission for the service.

You can also sell your ringtones on mobile stores or app stores such as Android
marketplace or App store (Apple). These stores are frequently visited by many
SAGAR BHAYANA
02296403113
I-456 (I-6)
buyers and hence ideal for making sales easily and efficiently. Finally, you can
also sell via your own mobile store by creating a mobile website specifically for
sales or as by setting-up an m-commerce page on your main website.

2. Set up Mobile Billing

Once you have decided where to sell, the next step is to set up your merchant
account. For instance, you can use third-party services such as PayPal. This is ideal
for small businesses or also large companies. A third-party application makes it
really easy for you as well as your customers to make the payments, but then they
do charge commission on the transaction.

You can also set-up your own billing and payment gateway, but make sure that you
make it really easy for users. Mobile users do not use keyboards or a mouse so
make sure that the design of your m-commerce site is intuitive, with easy
navigation tools and the right display sizes. Basically, make your m-commerce site
optimized for Smartphone users.

Benefits of M-Commerce

The major benefit of engaging in m-commerce is the sheer size of potential sales.
The probability of your potential customers owning a Smartphone is very high, so
you can safely assume that you will get much more positive response from mobile
devices than your website. M-commerce is recommended for every business
irrespective of its type, scale, and size.

SAGAR BHAYANA
02296403113
I-456 (I-6)
EXPERIMENT NO.2

AIM: CASE STUDY OF E-BUSINESS DESIGN IN ACTION

This steady increase is why the Internet is fast becoming the new economy.
Some people have termed it the equalizer because for the first time in history,
anyone can sell anything from anywhere in the world. The Internet has created a
global economy for both rural and urban entrepreneurs. The only boundaries are
set by lack of connectivity to broadband. As more and more Americans gain access
to broadband, the more lucrative e-selling online becomes.

Below are 10 steps to get you started with your E-Business.

1. Decide on a business.

First you must have something to sell. It can be a product, service, or a


combination of the two. If you are searching for a business idea, you probably have
lots of questions about going into business. However, before launching an E-
Business, it is best to do some preliminary research to determine the need for your
product or service by asking these questions:
What is my online competition?
If there is no competition, why not?
Is there a market for my product/service online?

2. Create a business plan.

Whether you are launching a traditional business or an E-business, you will need a
business plan. A business plan identifies your business, its goals and objectives.
Too often, people decide to eliminate this crucial step in the business start-up
stage. Creating a business plan allows you to think about your present and future
needs.

3. Select a domain name.

The domain name will be the URL (universal resource locator) which is the web
address or location on the Internet for your Web site. Selecting a domain name is
SAGAR BHAYANA
02296403113
I-456 (I-6)
very important. Spend time in your selection process. Select a name that closely
identifies your product or service and one that will be easy for customers to
remember. Keep in mind, your name is your first impression.

4.Select Meta-Tags.

Meta-tags are the keywords, title, and description you select to describe your web
site so that search engines can direct people to your Web site. Heres how it works.
Once a URL is submitted to a search engine, the search engine will crawl your
site with a type of scanning software known as a spider. The spiders read the
information contained in the meta-tags, along with the content of the Web pages
themselves, and uses that information to determine a sites position within search
results.

5.Design a Web site.

There are three options available for Web site design: design it yourself; hire a web
designer; or utilize the one stop method where the Web host designs the Web
page from templates. If you choose to design the Web site yourself, take advantage
of online tutorials and classes at universities.

6.Select a Web host.

Now that you have a Web site, you need a place for the site to reside, called an ISP
(Internet service provider) to host it. You can either own or operate your own Web
server, an option that requires significant financial investment and a high-level of
technical proficiency, or you can use a hosting service, which is essentially
renting
space on a server maintained by someone else.

7.Decide how you will accept orders.

Customer satisfaction is important. Your Web site should be easy for customers to
navigate and when they are ready to make a purchase it should be easy, safe and
convenient.

8.Provide Web site Security.

SAGAR BHAYANA
02296403113
I-456 (I-6)
Buyer beware, couldnt be truer, when it comes to Internet shopping. Sites that
are not secure may have less traffic because people are weary of identity theft. To
ensure that your customers transactions are safe and secure, you will need
to provide security. Although, it comes with a price, it may put dollars in your
pocket in the long run. Consider contracting with a credit card verification
company.

9.Customer Communication System.

Your Web store will need to communicate with its customers. So create a page
providing contact information. That information should include a telephone
number, e-mail, physical address, and mailing address. Once you have received an
order, you will need to acknowledge receipt and send notification of shipment to
the customer. Tracking customer orders is also a valued option.

10.Develop a marketing strategy for your E-Business.

Build it and they will come! Have you ever wondered why so many people
advertise their Web sites on television? Submit your URL to the search engines.
Most people purchase from using an online search engine. Submit your URL to the
big search engines: Google, Yahoo! MSN, Alta Vista, Excite, WebCrawler, Lycos,
and HotBot.

SAGAR BHAYANA
02296403113
I-456 (I-6)
EXPERIMENT NO.3

AIM: IMPLEMENT SESSION TRACKING OF SHOPPING CART

USING JAVA SERVLET

import java.util.HashMap;
public class Cart {
HashMap<String, Integer> cartItems;
public Cart(){
cartItems = new HashMap<>();

}
public HashMap getCartItems(){
return cartItems;
}
public void addToCart(String itemId, int price){
cartItems.put(itemId, price);
}

}
public class Addtocart extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
HttpSession session = request.getSession();
cart shoppingCart;
shoppingCart = (cart) session.getAttribute("cart");
if(shoppingCart == null){
shoppingCart = new cart();
session.setAttribute("cart", shoppingCart);
}
String name = request.getParameter("name");
Integer price = Integer.parseInt(request.getParameter("price"));
shoppingCart.addToCart(name, price);
session.setAttribute("cart", shoppingCart);
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code.
out.println("<!DOCTYPE html>");
out.println("<html>");
SAGAR BHAYANA
02296403113
I-456 (I-6)
out.println("<head>");
out.println("<title>result</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Pizza successfully added to cart </h1>");
out.println("<form action='index.html'>Add more pizza item<input type='submit'
value='go'></form>");
out.println("<hr>");
out.println("<h2>Cart</h2>");
HashMap<String, Integer> items = shoppingCart.getCartItems();
out.println("<table border='1px'>");

for(String key: items.keySet()){


out.println("<tr><td>"+key+" - </td><td>"+"$"+items.get(key)+"</td></tr>");
}
out.println("<table>");
out.println("</body>");
out.println("</html>");

}
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
String name = request.getParameter("name");
HttpSession session = request.getSession();
cart shoppingCart;
shoppingCart = (cart) session.getAttribute("cart");
shoppingCart.deleteFromCart(name);
session.setAttribute("cart", shoppingCart);
shoppingCart = (cart) session.getAttribute("cart");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet deleteItem</title>");
out.println("</head>");
out.println("<body>");
HashMap<String, Integer> items = shoppingCart.getCartItems();
out.println("<table border='1px'>");

for(String key: items.keySet()){

SAGAR BHAYANA
02296403113
I-456 (I-6)
out.println("<form action='deleteItem'><input type='hidden' name='name'
value='"+key+"'><tr><td>"+key+" - </td><td>"+"$"+items.get(key)+"</td><td><input
type='submit' value='delete'></td></tr></form>");
}
out.println("<table>");
out.println("</body>");
out.println("</html>");
}}
EXPERIMENT NO.4

AIM: IMPLEMENT PAYMENT GATEWAY IN JAVA


1. REQUEST.JSP

<%@ page import="java.security.MessageDigest" %>

<%@ page import="java.util.Calendar" %>

<html>

<head>

<title>Elavon Payment Gateway redirect test</title>

<%!

public String getTimestamp() {

String timestamp;

Calendar now = Calendar.getInstance();

timestamp = "" + now.get(Calendar.YEAR);

if ((now.get(Calendar.MONTH) + 1) < 10) {

timestamp += "0" + (now.get(Calendar.MONTH) + 1);

} else {

timestamp += "" + (now.get(Calendar.MONTH) + 1);

SAGAR BHAYANA
02296403113
I-456 (I-6)
}

if (now.get(Calendar.DAY_OF_MONTH) < 10) {

timestamp += "0" + now.get(Calendar.DAY_OF_MONTH);

} else {

timestamp += "" + now.get(Calendar.DAY_OF_MONTH);

if (now.get(Calendar.HOUR_OF_DAY) < 10) {

timestamp += "0" + now.get(Calendar.HOUR_OF_DAY);

} else {

timestamp += "" + now.get(Calendar.HOUR_OF_DAY);

if (now.get(Calendar.MINUTE) < 10) {

timestamp += "0" + now.get(Calendar.MINUTE);

} else {

timestamp += "" + now.get(Calendar.MINUTE);

if (now.get(Calendar.SECOND) < 10) {

timestamp += "0" + now.get(Calendar.SECOND);

} else {

timestamp += "" + now.get(Calendar.SECOND);

SAGAR BHAYANA
02296403113
I-456 (I-6)
}

return timestamp;

public String calcSHA1(String toBeHashed) {

byte[] digestValue = new byte[0];

StringBuffer sb = new StringBuffer();

MessageDigest md;

try {

md = MessageDigest.getInstance("SHA");

md.update(toBeHashed.getBytes());

digestValue = md.digest();

for (int i = 0; i < digestValue.length; i++) {

String c = Integer.toHexString(digestValue[i]);

if (digestValue[i] < 0) c = c.substring(6);

if (c.length() < 2) c = "0" + c;

sb.append(c);

} catch (Exception e) { e.printStackTrace(); }

SAGAR BHAYANA
02296403113
I-456 (I-6)
return sb.toString();

%>

<%

merchantid = "yourMerchantId";

secret = "your shared secret";

orderid = "Order" + timestamp;

curr = "EUR";

amount = "3000";

String testString = timestamp + "." + merchantid + "." + orderid + "." +

amount + "." + curr;

String testStringHashed = calcSHA1(testString);

testString = testStringHashed + "." + secret;

testStringHashed = calcSHA1(testString);

String sha1hash = testStringHashed;

SAGAR BHAYANA
02296403113
I-456 (I-6)
%>

</head>

<body bgcolor="#FFFFFF">

<form action="https://redirect.elavonpaymentgateway.com/epage.cgi" method=post>

<input type=hidden name="MERCHANT_ID" value="<%=merchantid%>">

<input type=hidden name="ORDER_ID" value="<%=orderid%>">

<input type=hidden name="CURRENCY" value="<%=curr%>">

<input type=hidden name="AMOUNT" value="<%=amount%>">

<input type=hidden name="TIMESTAMP" value="<%=timestamp%>">

<input type=hidden name="SHA1HASH" value="<%=sha1hash%>">

<input type=hidden name="AUTO_SETTLE_FLAG" value="1">

<input type=submit value="Proceed to secure server">

</form>

<font face=verdana>

<font size=3><b>JSP Sample - Elavon Payment Gateway epage redirect</b></font>

<p>

<font size=2>Select View/Source to see the output

SAGAR BHAYANA
02296403113
I-456 (I-6)
<ul>

<li>In the example I use the date/time as the order id - you may have your own scheme.

<li>You should replace <code>merchantid</code> and <code>secret</code> with the values


provided by Elavon Payment Gateway support.

</ul>

</font>

</body>

</html>

2. RESPONSE.JSP

<%@ page import="java.security.MessageDigest" %>

<%!

public String calcSHA1(String toBeHashed) {

byte[] digestValue = new byte[0];

StringBuffer sb = new StringBuffer();

MessageDigest md;

try {

md = MessageDigest.getInstance("SHA");

md.update(toBeHashed.getBytes());

digestValue = md.digest();

for (int i = 0; i < digestValue.length; i++) {

String c = Integer.toHexString(digestValue[i]);

if (digestValue[i] < 0) c = c.substring(6);


SAGAR BHAYANA
02296403113
I-456 (I-6)
if (c.length() < 2) c = "0" + c;

sb.append(c);

} catch (Exception e) { e.printStackTrace(); }

return sb.toString();

String timestamp = request.getParameter("TIMESTAMP");

String merchantid = request.getParameter("MERCHANT_ID");

String result = request.getParameter("RESULT");

String order_id = request.getParameter("ORDER_ID");

String message = request.getParameter("MESSAGE");

String authcode = request.getParameter("AUTHCODE");

String pasref = request.getParameter("PASREF");

String sha1hash = request.getParameter("SHA1HASH");

String secret = "secret";

String testString = timestamp + "." + merchantid + "." + order_id + "." +

result + "." + message + "." + pasref + "." + authcode;

String testStringHashed = calcSHA1(testString);

testString = testStringHashed + "." + secret;

testStringHashed = calcSHA1(testString);

SAGAR BHAYANA
02296403113
I-456 (I-6)
if (sha1hash.compareTo(testStringHashed) != 0) {

%>

There has been an error validating the response from our payment provider.

Please contact us on 01 xxxxxx to obtain the status of your order.

<%

} else {

if (result.compareTo("00") == 0) {

// the payment succeeded.

%>

Thank You - Your payment has been accepted. If you have any enquiries

about the order please use this order number: <br>

<% =order_id %>

<br><br>

To continue please <a href="http://yourdomain.com">click here</a>

<%

} else {

%>

We're sorry - there has been a problem processing your order. Please call

SAGAR BHAYANA
02296403113
I-456 (I-6)
01 xxxxxx and quote your order number as: <% =order_id %>

<br>

Your credit card has not been charged. To continue browsing please

<a href="http://yourdomain.com">click here</a>

<%

%>

EXPERIMENT NO.4

AIM: IMPLEMENT DIGITAL SIGNATURE IN JAVA


import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.Signature;

import sun.misc.BASE64Encoder;

public class MainClass {


public static void main(String[] args) throws Exception {
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(1024);
KeyPair keyPair = kpg.genKeyPair();

byte[] data = "test".getBytes("UTF8");

Signature sig = Signature.getInstance("MD5WithRSA");


sig.initSign(keyPair.getPrivate());
sig.update(data);
byte[] signatureBytes = sig.sign();
System.out.println("Singature:" + new BASE64Encoder().encode(signatureBytes));

sig.initVerify(keyPair.getPublic());
SAGAR BHAYANA
02296403113
I-456 (I-6)
sig.update(data);

System.out.println(sig.verify(signatureBytes));
}
}

SAGAR BHAYANA
02296403113
I-456 (I-6)

You might also like