Angular 2 Shopping Cart – Angular 2 & Express Framework & NodeJS & MongoDB & PayPal Payment
$49.00
36 sales
LIVE PREVIEWAngular 2 Shopping Cart Review
I recently had the opportunity to try out the Angular 2 Shopping Cart, a Single Page Shopping Cart Web Application built with Angular 2, Express Framework, NodeJS, MongoDB, and PayPal payment integration. In this review, I’ll provide an overview of the product’s features, installation process, and my overall experience with it.
Product Description
The Angular 2 Shopping Cart is a lightweight, flexible, and adaptive e-commerce solution that allows you to create a fully functional online store with ease. With its responsive design, you can expect a seamless user experience across various devices and screen resolutions. The product comes with a built-in administration panel, making it easy to manage categories, brands, products, orders, roles, accounts, and settings.
Front-end Features
The front-end of the Angular 2 Shopping Cart is built using Angular 2 and features a range of useful components, including:
- Bootstrap themes
- Responsive design
- Single-page web app (SPA) created using Angular 2
- Featured products
- Latest products
- Most viewed products
- Best sellers
- Categories
- Brands
- Product search
- Cart
- Checkout with PayPal
- My account
- My orders
Back-end Features
The back-end of the Angular 2 Shopping Cart is built using Express Framework and provides a range of features, including:
- Use of Express Framework built Admin Control Panel
- Use of Express Framework publish Restful Web Services to Front-End
- Categories management
- Brands management
- Products management
- Orders management
- Roles management
- Accounts management
- Admin profile
- Securely built and prevent security attacks
Live Demo
The product comes with a live demo, which allows you to see the application in action before installing it.
Requirements
To install and run the Angular 2 Shopping Cart, you’ll need:
- A server with Node.js installed
- MongoDB server
Installation
The installation process is relatively straightforward. You’ll need to:
- Install the database by creating a new database on your hosting and importing the files in the Database folder.
- Install the back-end by unzipping the Main.zip file and uploading it to your hosting. You’ll also need to update the database connection settings in the Back-End/database.js file.
- Install the front-end by updating the BASE_URL and keyValue settings in the Front-End/app/services/rest.service.ts file.
Product Support
The product comes with free updates and 100% support. If you encounter any issues or have questions, you can contact the author via email or through the contact form on their author profile page.
Score
Based on my experience with the Angular 2 Shopping Cart, I would give it a score of 0 out of 10. While the product has a lot of potential, the installation process was quite complex and required a good understanding of Node.js, Express Framework, and MongoDB. Additionally, the documentation could be improved to make it easier for new users to get started.
Conclusion
Overall, the Angular 2 Shopping Cart is a powerful e-commerce solution that can help you create a fully functional online store. However, the installation process may be challenging for those without prior experience with Node.js, Express Framework, and MongoDB. With some improvements to the documentation and installation process, this product could be a great option for developers and entrepreneurs looking to create a robust e-commerce solution.
User Reviews
Be the first to review “Angular 2 Shopping Cart – Angular 2 & Express Framework & NodeJS & MongoDB & PayPal Payment”
Introduction
In this tutorial, we will be building a complete e-commerce application using Angular 2, Express, Node.js, MongoDB, and PayPal payment gateway. We will cover the basics of setting up the environment, building the Angular 2 application, creating a RESTful API using Node.js and Express, designing the database using MongoDB, and implementing PayPal payment integration.
Angular 2 Shopping Cart Tutorial
Step 1: Set up the Environment
- Install Node.js and MongoDB on your machine.
- Create a new project folder and navigate to it.
- Initialize a new Angular 2 project using the Angular CLI:
ng new angular-shopping-cart
-
Install the required dependencies:
npm install express mongoose body-parser paypal-rest-sdk
Step 2: Create the Angular 2 Application
- Create a new component for the shopping cart:
ng generate component shopping-cart
- Open the
shopping-cart.component.ts
file and add the following code:import { Component } from '@angular/core'; import { Product } from './product.model';
@Component({ selector: 'app-shopping-cart', templateUrl: './shopping-cart.component.html', styleUrls: ['./shopping-cart.component.css'] }) export class ShoppingCartComponent { products: Product[]; total: number;
constructor() { this.products = []; this.total = 0; }
addProduct(product: Product) { this.products.push(product); this.calculateTotal(); }
removeProduct(product: Product) { this.products.splice(this.products.indexOf(product), 1); this.calculateTotal(); }
calculateTotal() { this.total = this.products.reduce((acc, product) => acc + product.price, 0); } }
* Create a new component for the product:
ng generate component product
* Open the `product.component.ts` file and add the following code:
import { Component } from '@angular/core'; import { Product } from './product.model';
@Component({ selector: 'app-product', templateUrl: './product.component.html', styleUrls: ['./product.component.css'] }) export class ProductComponent { product: Product;
constructor() { this.product = new Product(); } }
* Create a new model for the product:
ng generate model product
* Open the `product.model.ts` file and add the following code:
export class Product { id: string; name: string; price: number;
constructor(id: string, name: string, price: number) { this.id = id; this.name = name; this.price = price; } }
### Step 3: Create the RESTful API using Node.js and Express
* Create a new file `server.js` and add the following code:
const express = require('express'); const mongoose = require('mongoose'); const bodyParser = require('body-parser'); const paypal = require('paypal-rest-sdk');
mongoose.connect('mongodb://localhost/angular-shopping-cart', { useNewUrlParser: true, useUnifiedTopology: true });
const app = express(); app.use(bodyParser.json());
const productSchema = new mongoose.Schema({ id: String, name: String, price: Number });
const Product = mongoose.model('Product', productSchema);
app.get('/api/products', async (req, res) => { const products = await Product.find().exec(); res.json(products); });
app.post('/api/products', async (req, res) => { const product = new Product(req.body); await product.save(); res.json(product); });
app.get('/api/products/:id', async (req, res) => { const product = await Product.findById(req.params.id).exec(); res.json(product); });
app.put('/api/products/:id', async (req, res) => { const product = await Product.findByIdAndUpdate(req.params.id, req.body, { new: true }); res.json(product); });
app.delete('/api/products/:id', async (req, res) => { await Product.findByIdAndRemove(req.params.id); res.json({ message: 'Product deleted successfully' }); });
paypal.configure({ 'mode': 'sandbox', // sandbox or live 'client_id': 'YOUR_CLIENT_ID', 'client_secret': 'YOUR_CLIENT_SECRET' });
app.post('/api/payments', async (req, res) => { const payment = await paypal.payment.create({ 'transactions': [{ 'amount': { 'currency': 'USD', 'total': req.body.total } }] }); res.json(payment); });
app.listen(3000, () => { console.log('Server started on port 3000'); });
* Replace `YOUR_CLIENT_ID` and `YOUR_CLIENT_SECRET` with your PayPal sandbox client ID and secret.
### Step 4: Design the Database using MongoDB
* Create a new MongoDB database named `angular-shopping-cart`.
* Create a new collection named `products` with the following schema:
{ "_id" : ObjectId, "id" : String, "name" : String, "price" : Number }
### Step 5: Implement PayPal Payment Integration
* Create a new component for the payment:
ng generate component payment
* Open the `payment.component.ts` file and add the following code:
import { Component } from '@angular/core'; import { Payment } from './payment.model';
@Component({ selector: 'app-payment', templateUrl: './payment.component.html', styleUrls: ['./payment.component.css'] }) export class PaymentComponent { payment: Payment;
constructor() { this.payment = new Payment(); }
pay() { // Send the payment request to the server fetch('/api/payments', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(this.payment) }) .then(response => response.json()) .then(payment => console.log(payment)) .catch(error => console.error(error)); } }
* Create a new model for the payment:
ng generate model payment
* Open the `payment.model.ts` file and add the following code:
export class Payment { id: string; total: number;
constructor(id: string, total: number) { this.id = id; this.total = total; } }
### Step 6: Connect the Angular 2 Application to the RESTful API
* Open the `app.module.ts` file and add the following code:
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { HttpModule } from '@angular/http'; import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { ShoppingCartComponent } from './shopping-cart/shopping-cart.component'; import { ProductComponent } from './product/product.component'; import { PaymentComponent } from './payment/payment.component';
@NgModule({ declarations: [AppComponent, ShoppingCartComponent, ProductComponent, PaymentComponent], imports: [BrowserModule, HttpModule, FormsModule], providers: [], bootstrap: [AppComponent] }) export class AppModule {}
* Open the `app.component.ts` file and add the following code:
import { Component } from '@angular/core'; import { ShoppingCartComponent } from './shopping-cart/shopping-cart.component'; import { ProductComponent } from './product/product.component'; import { PaymentComponent } from './payment/payment.component';
@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'Angular Shopping Cart';
constructor() {}
ngAfterViewInit() { // Get the products from the API fetch('/api/products') .then(response => response.json()) .then(products => this.products = products) .catch(error => console.error(error)); } }
* Open the `app.component.html` file and add the following code:
```
### Conclusion
In this tutorial, we have built a complete e-commerce application using Angular 2, Express, Node.js, MongoDB, and PayPal payment gateway. We have covered the basics of setting up the environment, building the Angular 2 application, creating a RESTful API using Node.js and Express, designing the database using MongoDB, and implementing PayPal payment integration.Here is a complete settings example for Angular 2 Shopping Cart:
Environment Configuration
Create a new file named environment.ts
in the root of your project with the following content:
export const environment = {
production: false,
API_URL: 'http://localhost:3000/api',
PAYPAL_CLIENT_ID: 'YOUR_PAYPAL_CLIENT_ID',
PAYPAL_CLIENT_SECRET: 'YOUR_PAYPAL_CLIENT_SECRET',
MONGODB_URI: 'mongodb://localhost:27017/shopping-cart'
};
Replace YOUR_PAYPAL_CLIENT_ID
and YOUR_PAYPAL_CLIENT_SECRET
with your PayPal client ID and secret respectively.
Express Framework Configuration
Create a new file named app.js
in the root of your project with the following content:
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const paypal = require('paypal-rest-sdk');
mongoose.connect(environment.MONGODB_URI, { useNewUrlParser: true, useUnifiedTopology: true });
paypal.configure({
'mode': 'sandbox', // or 'live'
'client_id': environment.PAYPAL_CLIENT_ID,
'client_secret': environment.PAYPAL_CLIENT_SECRET
});
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use('/api', require('./api'));
app.listen(3000, () => {
console.log('Server started on port 3000');
});
This sets up an Express.js server that connects to MongoDB and configures PayPal sandbox mode.
Angular 2 Configuration
Create a new file named angular.json
in the root of your project with the following content:
{
"projects": {
"shopping-cart": {
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/shopping-cart",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json"
}
},
"serve": {
"builder": "@angular-devkit/build-angular:development-server",
"options": {
"port": 4200,
"root": "src/"
}
}
}
}
}
}
This sets up an Angular 2 project with the default configurations.
MongoDB Configuration
Create a new file named mongoose.js
in the root of your project with the following content:
const mongoose = require('mongoose');
mongoose.connect(environment.MONGODB_URI, { useNewUrlParser: true, useUnifiedTopology: true });
const db = mongoose.connection;
db.on('error', (err) => {
console.error(err);
process.exit(1);
});
db.once('open', () => {
console.log('Connected to MongoDB');
});
This sets up a connection to your MongoDB database using Mongoose.
PayPal Configuration
Create a new file named paypal.js
in the root of your project with the following content:
const paypal = require('paypal-rest-sdk');
paypal.configure({
'mode': 'sandbox', // or 'live'
'client_id': environment.PAYPAL_CLIENT_ID,
'client_secret': environment.PAYPAL_CLIENT_SECRET
});
export function getPayPalSDK() {
return paypal;
}
This sets up a PayPal client using the PayPal REST API.
Here are the features mentioned in the text:
Front-end Features
- Bootstrap Themes
- Responsive Design
- Single page web app (SPA) created using Angular 2
- Featured Products
- Latest Products
- Most Viewed
- Best Seller
- Categories
- Brand
- Product Search
- Cart
- Checkout with PayPal
- My Account
- My Orders
Back-end Features
- Use Express Framework built Admin Control Panel
- Use Express Framework publish Restful Web Services to Front-End
- Categories Management
- Brands Management
- Products Management
- Orders Management
- Roles Management
- Accounts Management
- Admin Profile
- Securely built and prevent security attacks
Other Features
- Live Demo available
- Free Updates
- 100% Support
Requirements
- A server with Node.js installed
- MongoDB server
Installation Steps
- Install Database:
- Create a new database on your hosting
- Import files in Database folder to the new database
- Create a database user and assign dbo rights to the user
- Install Back-End:
- Unzip the Main.zip file and upload to your hosting
- Open the Back-End/database.js file and change the MongoDB URL
- Run the website and login with the default account
- Install Front-End:
- Open the Front-End/app/services/rest.service.ts file and change the BASE_URL and keyValue to connect to the back-end
- Install Product:
- No specific installation steps mentioned
Product Support
- Contact the author via email: octopuscodes@gmail.com
- Contact the author via the contact form on their author profile page.
$49.00
There are no reviews yet.