From 75cc66dfef54df240528e52532ec4b350a1dbd22 Mon Sep 17 00:00:00 2001 From: Rene Vergara A Date: Mon, 1 Aug 2022 19:41:47 -0500 Subject: [PATCH 1/5] Rev=move order when last Item is deleted --- src/app/order/order.component.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/order/order.component.ts b/src/app/order/order.component.ts index 3b408c6..6f74da7 100644 --- a/src/app/order/order.component.ts +++ b/src/app/order/order.component.ts @@ -124,7 +124,7 @@ export class OrderComponent implements OnInit{ this.notifierService .showNotification("Order successfully cancelled!", "Close","success"); - });; + }); } else { console.log('Returning to page'); } @@ -227,6 +227,12 @@ export class OrderComponent implements OnInit{ // + " => (" + item.name +")"); this.orderService.updateOrder(item.line_id,lines); this.orderService.getOrder(); + if ( this.order.lines.length == 0 ) { + this.orderService.cancelOrder(this.order._id!) + .subscribe((response) => { + this.orderService.getOrder(); + }); + } } else { console.log('Returning to order'); From ee09c1f71043a4a5370e90eae1e89ea810bd1396 Mon Sep 17 00:00:00 2001 From: Rene Vergara A Date: Mon, 1 Aug 2022 21:29:07 -0500 Subject: [PATCH 2/5] Payment service component added - initial testing version --- src/app/app-routing.module.ts | 2 ++ src/app/app.module.ts | 4 ++- src/app/pmtservice/pmtservice.component.css | 0 src/app/pmtservice/pmtservice.component.html | 1 + .../pmtservice/pmtservice.component.spec.ts | 23 ++++++++++++ src/app/pmtservice/pmtservice.component.ts | 36 +++++++++++++++++++ src/app/pmtservice/pmtservice.model.ts | 7 ++++ src/app/pmtservice/url.txt | 1 + 8 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 src/app/pmtservice/pmtservice.component.css create mode 100644 src/app/pmtservice/pmtservice.component.html create mode 100644 src/app/pmtservice/pmtservice.component.spec.ts create mode 100644 src/app/pmtservice/pmtservice.component.ts create mode 100644 src/app/pmtservice/pmtservice.model.ts create mode 100644 src/app/pmtservice/url.txt diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 0d0bdac..b9348ce 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -8,6 +8,7 @@ import { InvoiceComponent } from './invoice/invoice.component'; import { ListOrdersComponent } from './listorders/listorders.component'; import { AuthGuardService } from './auth-guard.service'; import { NodeResolverService } from './node-resolver.service'; +import { PmtserviceComponent } from './pmtservice/pmtservice.component'; const routes: Routes = [ { path: '', component: LoginComponent, resolve: { response: NodeResolverService} }, @@ -17,6 +18,7 @@ const routes: Routes = [ { path: 'biz', component: BusinessComponent, canActivate: [AuthGuardService]}, { path: 'receipt/:orderId', component: ReceiptComponent}, { path: 'invoice/:orderId', component: InvoiceComponent}, + { path: 'pmtservice', component: PmtserviceComponent}, { path: 'login', component: LoginComponent, resolve: { response: NodeResolverService}} ]; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 9183d10..d8373c9 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -45,6 +45,7 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { PromptInvoiceComponent } from './prompt-invoice/prompt-invoice.component'; import { PromptReceiptComponent } from './prompt-receipt/prompt-receipt.component'; import { NotifierComponent } from './notifier/notifier.component'; +import { PmtserviceComponent } from './pmtservice/pmtservice.component'; @NgModule({ declarations: [ @@ -71,7 +72,8 @@ import { NotifierComponent } from './notifier/notifier.component'; InvoiceComponent, PromptInvoiceComponent, PromptReceiptComponent, - NotifierComponent + NotifierComponent, + PmtserviceComponent ], imports: [ BrowserModule, diff --git a/src/app/pmtservice/pmtservice.component.css b/src/app/pmtservice/pmtservice.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pmtservice/pmtservice.component.html b/src/app/pmtservice/pmtservice.component.html new file mode 100644 index 0000000..d7bbf3a --- /dev/null +++ b/src/app/pmtservice/pmtservice.component.html @@ -0,0 +1 @@ +

{{ pmtData.ownerId }}

diff --git a/src/app/pmtservice/pmtservice.component.spec.ts b/src/app/pmtservice/pmtservice.component.spec.ts new file mode 100644 index 0000000..8b1c67b --- /dev/null +++ b/src/app/pmtservice/pmtservice.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PmtserviceComponent } from './pmtservice.component'; + +describe('PmtserviceComponent', () => { + let component: PmtserviceComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PmtserviceComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(PmtserviceComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pmtservice/pmtservice.component.ts b/src/app/pmtservice/pmtservice.component.ts new file mode 100644 index 0000000..543dc24 --- /dev/null +++ b/src/app/pmtservice/pmtservice.component.ts @@ -0,0 +1,36 @@ +import { Component, OnInit } from '@angular/core'; +import { Router, ActivatedRoute, Params } from "@angular/router"; +import { PmtData } from "./pmtservice.model" + +@Component({ + selector: 'app-pmtservice', + templateUrl: './pmtservice.component.html', + styleUrls: ['./pmtservice.component.css'] +}) + +export class PmtserviceComponent implements OnInit { + + + public pmtData : PmtData = { + ownerId :'', + invoice: '', + amount: 0, + currency: '', + shortcode: '' + }; + + constructor(private activatedRoute: ActivatedRoute) {} + + ngOnInit() { + this.activatedRoute.queryParams.subscribe((params) => { + this.pmtData.ownerId = params["ownerid"]; + this.pmtData.invoice = params["invoice"]; + this.pmtData.amount = params["amount"]; + this.pmtData.currency = params["currency"]; + this.pmtData.shortcode = params["shortcode"]; + + console.log(this.pmtData); + }); + } + +} diff --git a/src/app/pmtservice/pmtservice.model.ts b/src/app/pmtservice/pmtservice.model.ts new file mode 100644 index 0000000..bcf64a0 --- /dev/null +++ b/src/app/pmtservice/pmtservice.model.ts @@ -0,0 +1,7 @@ +export interface PmtData { + ownerId: string; + invoice: string; + amount: number; + currency: string; + shortcode: string; +} diff --git a/src/app/pmtservice/url.txt b/src/app/pmtservice/url.txt new file mode 100644 index 0000000..1d562d8 --- /dev/null +++ b/src/app/pmtservice/url.txt @@ -0,0 +1 @@ +http://localhost:4200/pmtservice?ownerid=Rene&amount=30¤cy=USD&invoice=INV-003234&shortcode=abcde \ No newline at end of file From b5885517e9a0817786830df3c202074671e7b444 Mon Sep 17 00:00:00 2001 From: Rene Vergara A Date: Wed, 3 Aug 2022 09:33:21 -0500 Subject: [PATCH 3/5] Add console.log to Checkout component for debugging --- src/app/checkout/checkout.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/checkout/checkout.component.ts b/src/app/checkout/checkout.component.ts index 6a24355..5298fc0 100644 --- a/src/app/checkout/checkout.component.ts +++ b/src/app/checkout/checkout.component.ts @@ -24,6 +24,7 @@ export class CheckoutComponent implements OnInit{ private sanitizer: DomSanitizer, @Inject(MAT_DIALOG_DATA) public data: { totalZec: number, addr: string, orderId: string} ) { + console.log("Entra a Constructor") this.address = data.addr; this.total = data.totalZec; this.orderId = data.orderId; @@ -42,7 +43,7 @@ export class CheckoutComponent implements OnInit{ logoHeight: 60, correctLevel: QRCode.CorrectLevel.H }); -// console.log(">>> " + qrcode); + console.log("mgOnInit - pasa"); } From de1a19ffd0c8e7ab9b2722faf952568776d7a143 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 4 Aug 2022 14:43:46 -0500 Subject: [PATCH 4/5] Fix checkout payment memo --- CHANGELOG.md | 1 + src/app/checkout/checkout.component.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bff525d..0c5f5fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed +- Fixed order memo for checkout - Fixed display of amounts in item list when using *zatoshis* - Fixed sorting of items in list - Fixed sorting of orders in list diff --git a/src/app/checkout/checkout.component.ts b/src/app/checkout/checkout.component.ts index 5298fc0..815afe0 100644 --- a/src/app/checkout/checkout.component.ts +++ b/src/app/checkout/checkout.component.ts @@ -28,7 +28,7 @@ export class CheckoutComponent implements OnInit{ this.address = data.addr; this.total = data.totalZec; this.orderId = data.orderId; - this.codeString = `zcash:${this.address}?amount=${this.total.toFixed(6)}&memo=${URLSafeBase64.encode(Buffer.from('Z-Go Order '.concat(this.orderId)))}`; + this.codeString = `zcash:${this.address}?amount=${this.total.toFixed(8)}&memo=${URLSafeBase64.encode(Buffer.from('ZGo Order::'.concat(this.orderId)))}`; this.zcashUrl = this.sanitizer.bypassSecurityTrustUrl(this.codeString); } From 8243b4e3f8bc4617a18c558537813ec253b4a2d0 Mon Sep 17 00:00:00 2001 From: Rene Vergara A Date: Thu, 4 Aug 2022 16:31:37 -0500 Subject: [PATCH 5/5] Add buttons to checkout component --- src/app/checkout/checkout.component.html | 32 ++++++++++++-- src/app/checkout/checkout.component.ts | 55 ++++++++++++++++++++++-- 2 files changed, 80 insertions(+), 7 deletions(-) diff --git a/src/app/checkout/checkout.component.html b/src/app/checkout/checkout.component.html index 401da48..3d7efbe 100644 --- a/src/app/checkout/checkout.component.html +++ b/src/app/checkout/checkout.component.html @@ -1,4 +1,5 @@ -
+
Scan to make payment @@ -14,7 +15,7 @@ - +
@@ -32,6 +33,31 @@
- +
+
+ + Can't scan?
Use this wallet link, or +
+ + +
+ + +
diff --git a/src/app/checkout/checkout.component.ts b/src/app/checkout/checkout.component.ts index 815afe0..7273f13 100644 --- a/src/app/checkout/checkout.component.ts +++ b/src/app/checkout/checkout.component.ts @@ -2,6 +2,8 @@ import { Inject, Component, OnInit, ViewEncapsulation} from '@angular/core'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; +import { NotifierService } from '../notifier.service'; + var QRCode = require('easyqrcodejs'); var URLSafeBase64 = require('urlsafe-base64'); var Buffer = require('buffer/').Buffer; @@ -22,8 +24,9 @@ export class CheckoutComponent implements OnInit{ constructor( private dialogRef: MatDialogRef, private sanitizer: DomSanitizer, - @Inject(MAT_DIALOG_DATA) public data: { totalZec: number, addr: string, orderId: string} - ) { + @Inject(MAT_DIALOG_DATA) public data: { totalZec: number, addr: string, orderId: string}, + private notifierService : NotifierService ) { + console.log("Entra a Constructor") this.address = data.addr; this.total = data.totalZec; @@ -37,8 +40,8 @@ export class CheckoutComponent implements OnInit{ { text: this.codeString, logo: "/assets/zcash.png", - width: 220, - height: 220, + width: 230, + height: 230, logoWidth: 60, logoHeight: 60, correctLevel: QRCode.CorrectLevel.H @@ -54,4 +57,48 @@ export class CheckoutComponent implements OnInit{ close() { this.dialogRef.close(false); } + + copyAddress() { + if (!navigator.clipboard) { +// alert("Copy functionality not supported"); + this.notifierService + .showNotification("Copy functionality not supported","Close","error"); + } + try { + navigator.clipboard.writeText(this.address); + } catch (err) { + this.notifierService + .showNotification("Error copying address","Close","error"); +// console.error("Error", err); + } + } + copyAmount() { + if (!navigator.clipboard) { +// alert("Copy functionality not supported"); + this.notifierService + .showNotification("Copy functionality not supported","Close","error"); + } + try { + navigator.clipboard.writeText(this.total.toString()); + } catch (err) { + this.notifierService + .showNotification("Error while copying ammount","Close","error"); +// console.error("Error", err); + } + } + + copyMemo() { + if (!navigator.clipboard) { +// alert("Copy functionality not supported"); + this.notifierService + .showNotification("Copy functionality not supported","Close","error"); + } + try { + navigator.clipboard.writeText("ZGo Order::" + this.orderId); + } catch (err) { + this.notifierService + .showNotification("Error while copying Memo","Close","error"); +// console.error("Error", err); + } + } }