Convenience buttons added to PmtService invoice

This commit is contained in:
Rene V. Vergara A. 2022-08-24 19:57:44 -05:00
parent 3053d17740
commit f7749cb2f7
8 changed files with 189 additions and 6 deletions

View File

@ -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

View File

@ -88,6 +88,43 @@
</td>
</tr>
</table>
<div style="height: 15px;"></div>
<div width="100%"
style="font-size: 14px;
font-weight: 700;
font-style: italic;
text-align: center;">
Scan the QR code with your wallet to make payment
</div>
<div style="text-align: center;
margin-top: 10px;
line-height: 30px;">
<div style="font-family: 'Spartan';
font-size: 14px;
line-height: 20px;">
Can't scan?<br>Use this <a [href]="zcashUrl">wallet link</a>, or
</div>
<div style="display: flex;
justify-content: space-between;">
<button style="margin-top: 20px;
font-weight: 700;
background-color: lightgray;"
mat-raised-button
(click)="copyAddress()">Copy Address</button>
<button style="margin-top: 20px;
font-weight: 700;
background-color: lightgray;"
mat-raised-button
(click)="copyAmount()">Copy Amount</button>
</div>
<button style="margin-top: 20px;
font-weight: 700;
background-color: lightgray;"
mat-raised-button
(click)="copyMemo()">Copy Memo</button>
</div>
</div>
</div>

View File

@ -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);
}
}
}

View File

@ -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) {

View File

@ -53,6 +53,7 @@ export class OrderService {
viewkey: ''
},
order: {
_id: '',
address: '',
session: '',
timestamp: '',

View File

@ -218,6 +218,34 @@
text-align: center;">
Scan the QR code with your wallet to make payment
</div>
<div style="text-align: center;
margin-top: 10px;
line-height: 30px;">
<div style="font-family: 'Spartan';
font-size: 14px;
line-height: 20px;">
Can't scan?<br>Use this <a [href]="zcashUrl">wallet link</a>, or
</div>
<div style="display: flex;
justify-content: space-between;">
<button style="margin-top: 20px;
font-weight: 700;
background-color: lightgray;"
mat-raised-button
(click)="copyAddress()">Copy Address</button>
<button style="margin-top: 20px;
font-weight: 700;
background-color: lightgray;"
mat-raised-button
(click)="copyAmount()">Copy Amount</button>
</div>
<button style="margin-top: 20px;
font-weight: 700;
background-color: lightgray;"
mat-raised-button
(click)="copyMemo()">Copy Memo</button>
</div>
</div>
</div>

View File

@ -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);
}
}
}

View File

@ -1,3 +1,7 @@
http://localhost:4200/pmtservice?ownerid=62cca13f5530331e2a97c78e&invoiceNo=INV-0034&currency=USD&amount=753.95&shortCode=!w8T62
https://test.zgo.cash/api/invdata?address=zs17faa6l5ma55s55exq9rnr32tu0wl8nmqg7xp3e6tz0m5ajn2a6yxlc09t03mqdmvyphavvf3sl8&inv=INV-0034
https://test.zgo.cash/api/invdata?address=zs17faa6l5ma55s55exq9rnr32tu0wl8nmqg7xp3e6tz0m5ajn2a6yxlc09t03mqdmvyphavvf3sl8&inv=INV-0034
https://app.zgo.cash/invoice/