From f7749cb2f74f7eb09fd057798ddfe872d0e7cf64 Mon Sep 17 00:00:00 2001 From: Rene Vergara A Date: Wed, 24 Aug 2022 19:57:44 -0500 Subject: [PATCH] Convenience buttons added to PmtService invoice --- CHANGELOG.md | 1 + src/app/invoice/invoice.component.html | 37 ++++++++++++ src/app/invoice/invoice.component.ts | 58 ++++++++++++++++++- src/app/order/order.component.ts | 5 ++ src/app/order/order.service.ts | 1 + src/app/pmtservice/pmtservice.component.html | 28 ++++++++++ src/app/pmtservice/pmtservice.component.ts | 59 ++++++++++++++++++-- src/app/pmtservice/url.txt | 6 +- 8 files changed, 189 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61bb8ab..197d89b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Added new service for Xero integration ### Changed + - Settings component updated to use owner's invoices field to control integrations tab (Pro version) - Orders list updated to show payment confirmation only when service is diff --git a/src/app/invoice/invoice.component.html b/src/app/invoice/invoice.component.html index b155848..d682959 100644 --- a/src/app/invoice/invoice.component.html +++ b/src/app/invoice/invoice.component.html @@ -88,6 +88,43 @@ +
+
+ Scan the QR code with your wallet to make payment +
+
+
+ Can't scan?
Use this wallet link, or +
+
+ + +
+ + +
+ diff --git a/src/app/invoice/invoice.component.ts b/src/app/invoice/invoice.component.ts index 85fbebc..a702b43 100644 --- a/src/app/invoice/invoice.component.ts +++ b/src/app/invoice/invoice.component.ts @@ -1,10 +1,13 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; +import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; import { ReceiptService } from '../receipt.service'; import { Order} from '../order/order.model'; import { Observable } from 'rxjs'; import { faCheck, faHourglass } from '@fortawesome/free-solid-svg-icons'; +import { NotifierService } from '../notifier.service'; + var QRCode = require('easyqrcodejs'); var URLSafeBase64 = require('urlsafe-base64'); var Buffer = require('buffer/').Buffer; @@ -24,7 +27,11 @@ export class InvoiceComponent implements OnInit { error: boolean = false; codeString: string = 'Test'; + zcashUrl: SafeUrl = ''; + + order:Order = { + _id: '', address: '', session: '', timestamp: '', @@ -48,7 +55,9 @@ export class InvoiceComponent implements OnInit { constructor( private _ActiveRoute:ActivatedRoute, private router: Router, - public receiptService: ReceiptService + private sanitizer: DomSanitizer, + public receiptService: ReceiptService, + private notifierService : NotifierService ) { this.orderId = this._ActiveRoute.snapshot.paramMap.get("orderId"); this.orderUpdate = receiptService.orderUpdate; @@ -74,6 +83,9 @@ export class InvoiceComponent implements OnInit { }); this.orderUpdate.subscribe(order => { this.order = order; + this.codeString = `zcash:${this.order.address}?amount=${this.order.totalZec.toFixed(8)}&memo=${URLSafeBase64.encode(Buffer.from('ZGo Order::'.concat(this.orderId!)))}`; + this.zcashUrl = this.sanitizer.bypassSecurityTrustUrl(this.codeString); + }); this.nameUpdate.subscribe(name => { this.name = name; @@ -90,4 +102,48 @@ export class InvoiceComponent implements OnInit { } + copyAddress() { + if (!navigator.clipboard) { +// alert("Copy functionality not supported"); + this.notifierService + .showNotification("Copy functionality not supported","Close","error"); + } + try { + navigator.clipboard.writeText(this.order.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.order.totalZec.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.order._id); + } catch (err) { + this.notifierService + .showNotification("Error while copying Memo","Close","error"); +// console.error("Error", err); + } + } + } diff --git a/src/app/order/order.component.ts b/src/app/order/order.component.ts index e924f2d..0f5e61d 100644 --- a/src/app/order/order.component.ts +++ b/src/app/order/order.component.ts @@ -32,6 +32,7 @@ export class OrderComponent implements OnInit{ faInvoice = faFileInvoiceDollar; public order: Order = { + _id: '', address: '', session: '', timestamp: '', @@ -79,6 +80,8 @@ export class OrderComponent implements OnInit{ this.orderUpdate = orderService.orderUpdate; this.orderUpdate.subscribe((order) => { this.order = order; + + console.log('this.order > ' + JSON.stringify(this.order)); // ------------------------------------------------ this.oLines = []; this.myLines = this.order.lines; @@ -183,6 +186,8 @@ export class OrderComponent implements OnInit{ orderId: this.order._id }; + console.log ('order_id : ' + this.order._id); + const dialogRef = this.dialog.open(PromptInvoiceComponent, dialogConfig); dialogRef.afterClosed().subscribe((val) => { if (val) { diff --git a/src/app/order/order.service.ts b/src/app/order/order.service.ts index 229e0b6..251688f 100644 --- a/src/app/order/order.service.ts +++ b/src/app/order/order.service.ts @@ -53,6 +53,7 @@ export class OrderService { viewkey: '' }, order: { + _id: '', address: '', session: '', timestamp: '', diff --git a/src/app/pmtservice/pmtservice.component.html b/src/app/pmtservice/pmtservice.component.html index 4f5e5d4..4bb8410 100644 --- a/src/app/pmtservice/pmtservice.component.html +++ b/src/app/pmtservice/pmtservice.component.html @@ -218,6 +218,34 @@ text-align: center;"> Scan the QR code with your wallet to make payment +
+
+ Can't scan?
Use this wallet link, or +
+
+ + +
+ + +
diff --git a/src/app/pmtservice/pmtservice.component.ts b/src/app/pmtservice/pmtservice.component.ts index 1016a7c..8585b62 100644 --- a/src/app/pmtservice/pmtservice.component.ts +++ b/src/app/pmtservice/pmtservice.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { Router, ActivatedRoute, Params } from "@angular/router"; import { HttpClient, HttpParams, HttpHeaders } from "@angular/common/http"; +import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; import { PmtData } from "./pmtservice.model"; import { XeroInvoice } from "./xeroinvoice.model"; import { Owner } from '../owner.model'; @@ -9,6 +10,8 @@ import { Order } from '../order/order.model' import { ConfigData } from '../configdata'; import { faCheck, faHourglass } from '@fortawesome/free-solid-svg-icons'; +import { NotifierService } from '../notifier.service'; + var QRCode = require('easyqrcodejs'); var URLSafeBase64 = require('urlsafe-base64'); var Buffer = require('buffer/').Buffer; @@ -104,14 +107,17 @@ public order: Order = { public reportType = 1000; public Status = 0; + codeString: string = ''; + zcashUrl: SafeUrl = ''; zPrice: number = 1.0; name: string = ''; error: boolean = false; - codeString: string = 'Test'; orderId : string = ''; constructor(private activatedRoute : ActivatedRoute, - private http : HttpClient ) {} + private http : HttpClient, + private sanitizer: DomSanitizer, + private notifierService : NotifierService ) {} ngOnInit() { var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64'); @@ -125,7 +131,6 @@ public order: Order = { // console.log(this.pmtData); this.getInvoiceData( this.pmtData ); - }); } @@ -152,7 +157,7 @@ public order: Order = { // // ==> remove "== false" for production enviroment // - if ( this.owner.payconf == false) { + if ( this.owner.invoices ) { // process data console.log("Owner check passed!!!"); this.getXeroInvoiceData( reqData ); @@ -308,6 +313,8 @@ public order: Order = { correctLevel: QRCode.CorrectLevel.H }); + this.codeString = `zcash:${this.order.address}?amount=${this.order.totalZec.toFixed(8)}&memo=${URLSafeBase64.encode(Buffer.from('ZGo Order::'.concat(this.orderId)))}`; + this.zcashUrl = this.sanitizer.bypassSecurityTrustUrl(this.codeString); }, error => { console.log(error.message); @@ -336,4 +343,48 @@ public order: Order = { }); return obs; } + + copyAddress() { + if (!navigator.clipboard) { +// alert("Copy functionality not supported"); + this.notifierService + .showNotification("Copy functionality not supported","Close","error"); + } + try { + navigator.clipboard.writeText(this.order.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.order.totalZec.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); + } + } } \ No newline at end of file diff --git a/src/app/pmtservice/url.txt b/src/app/pmtservice/url.txt index 595f557..6140d72 100644 --- a/src/app/pmtservice/url.txt +++ b/src/app/pmtservice/url.txt @@ -1,3 +1,7 @@ http://localhost:4200/pmtservice?ownerid=62cca13f5530331e2a97c78e&invoiceNo=INV-0034¤cy=USD&amount=753.95&shortCode=!w8T62 -https://test.zgo.cash/api/invdata?address=zs17faa6l5ma55s55exq9rnr32tu0wl8nmqg7xp3e6tz0m5ajn2a6yxlc09t03mqdmvyphavvf3sl8&inv=INV-0034 \ No newline at end of file +https://test.zgo.cash/api/invdata?address=zs17faa6l5ma55s55exq9rnr32tu0wl8nmqg7xp3e6tz0m5ajn2a6yxlc09t03mqdmvyphavvf3sl8&inv=INV-0034 + + + +https://app.zgo.cash/invoice/ \ No newline at end of file