diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 29e41d0..c89e335 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -14,7 +14,7 @@ import {LocalStorage} from 'webstorage-decorators';
})
export class AppComponent implements OnInit {
@LocalStorage({defaultValue: []})
- cart: {id: string; item: string; price: number; quantity: number}[];
+ cart: {id: string; item: string; price: number; currency: 'CAD' | 'USD'; quantity: number}[];
categories;
user;
@@ -29,8 +29,10 @@ export class AppComponent implements OnInit {
this.categories = this.db.collection('categories').valueChanges();
}
- addToCart(id: string, item: string, price: number, quantity: number) {
- this.cart = [{id: id, item: item, price: Number(price), quantity: Number(quantity)}].concat(this.cart);
+ addToCart(id: string, item: string, price: number, currency: 'CAD' | 'USD', quantity: number) {
+ this.cart = [{id: id, item: item, price: Number(price), currency: currency, quantity: Number(quantity)}].concat(
+ this.cart
+ );
}
cartItemCount() {
diff --git a/src/app/store/cart/cart.component.html b/src/app/store/cart/cart.component.html
index fd9a30f..b07e9ac 100644
--- a/src/app/store/cart/cart.component.html
+++ b/src/app/store/cart/cart.component.html
@@ -14,26 +14,18 @@
{{i + 1}} |
- {{item.item}}
+ {{item.item}}
|
{{item.quantity}} |
- {{item.price | currency}} |
-
- delete
+ | {{item.currency}} {{item.price | currency}} |
+
+
|
-
-
-
-
- Sub Total:
- |
- {{total() | currency}} |
-
-
-
-
+
\ No newline at end of file
diff --git a/src/app/store/cart/cart.component.ts b/src/app/store/cart/cart.component.ts
index 4f7ba4d..134df7e 100644
--- a/src/app/store/cart/cart.component.ts
+++ b/src/app/store/cart/cart.component.ts
@@ -10,7 +10,7 @@ import {Router} from '../../../../node_modules/@angular/router';
})
export class CartComponent {
@LocalStorage({defaultValue: []})
- cart: {id: string; item: string; price: number; quantity: number}[];
+ cart: {id: string; item: string; price: number; curency: 'CAD' | 'USD'; quantity: number}[];
address1: string;
address2: string;
@@ -20,17 +20,32 @@ export class CartComponent {
constructor(private http: Http, private router: Router) {}
- async checkout() {
- let cart = this.cart.map(row => {
- return {id: row.id, quantity: row.quantity};
- });
- let link = await this.http
- .post('https://us-central1-fhsons-7e90b.cloudfunctions.net/checkout', {cart: cart})
- .toPromise();
- window.location.href = link.url;
+ ngOnInit() {
+ if (this.cart.length > 0) {
+ window['paypal'].Button.render(
+ {
+ env: 'sandbox',
+ client: {
+ sandbox: 'AejQ8-4hWWWhg1gYKbcuimT8Nf6-wutpEfYBHDDXiEXdujwJzHt6szwtmXBe2d3zW9d3khb3TgQBZUUJ',
+ live: 'AUhKVWkqvpzRBg0n_IFPMNi9QAl4JCXuWzc04BERDpBdG5ixFH1SimU85I9YSaksqKNCFjp_fOd4OAdd'
+ },
+ style: {size: 'medium', color: 'blue', shape: 'pill'},
+ payment: function(data, actions) {
+ return actions.payment.create({transactions: [{amount: {total: 0.01, currency: 'CAD'}}]});
+ },
+ onAuthorize: function(data, actions) {
+ return actions.payment.execute().then(function() {
+ window.alert('Thank you for your purchase!');
+ });
+ }
+ },
+ '#paypal-button'
+ );
+ }
}
remove(i: number) {
+ console.log('fire');
let c = this.cart;
c.splice(i, 1);
this.cart = c;
diff --git a/src/app/store/products/products.component.html b/src/app/store/products/products.component.html
index 329baae..5084457 100644
--- a/src/app/store/products/products.component.html
+++ b/src/app/store/products/products.component.html
@@ -7,7 +7,7 @@
-