Fix QR code generation for Xero invoice

This commit is contained in:
Rene Vergara 2023-06-22 16:40:36 -05:00
parent a05b76ebed
commit 84c31bc824
Signed by: pitmutt
GPG Key ID: 65122AD495A7F5B2
2 changed files with 28 additions and 24 deletions

View File

@ -131,7 +131,7 @@
</div>
<div class="invoiceDetail"
*ngIf="reportType==0"
id="invoice">
>
<div class="invoiceHdrTxt1">{{ vE.pmtserviceHdrTxt1 }}</div>
<div class="invoiceHdrTxt2">{{ vE.pmtserviceHdrTxt2 }}{{orderId}}</div>
<div class="invoiceHdrTxt3">{{ vE.pmtserviceHdrTxt3 }}{{order.timestamp | date}}
@ -206,7 +206,7 @@
</td>
<td width="25%">
<div style="text-align: right;"
id="payment-qr"
id="invoice-qr"
*ngIf="!order.paid"></div>
</td>
</tr>

View File

@ -80,10 +80,10 @@ export class PmtserviceComponent implements OnInit {
private invData_raw : string = '';
private invData_buff : any = null;
public reportType = 1000;
public reportType = 0;
public Status = 0;
codeString: string = '';
codeString: string = 'ZGo - The Zcash Register';
zcashUrl: SafeUrl = '';
zPrice: number = 1.0;
name: string = '';
@ -139,10 +139,6 @@ export class PmtserviceComponent implements OnInit {
private sanitizer: DomSanitizer,
private notifierService : NotifierService,
private languageService : LanguageService ){
}
ngOnInit() {
var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
this.activatedRoute.queryParams.subscribe((params) => {
@ -156,6 +152,9 @@ export class PmtserviceComponent implements OnInit {
this.chgUILanguage();
}
ngOnInit() {
}
getInvoiceData( reqData : PmtData ) {
//this.getXeroInvoiceData( reqData );
let obs = this.http.post<{reportType: number, order: Order, shop: string}>
@ -164,26 +163,31 @@ export class PmtserviceComponent implements OnInit {
{headers: this.reqHeaders, observe: 'response' }
);
obs.subscribe((invoiceData) => {
this.reportType = invoiceData.body!.reportType;
this.order = invoiceData.body!.order;
this.shop = invoiceData.body!.shop;
this.orderId = String(this.order._id);
if(invoiceData.status == 201) {
this.reportType = invoiceData.body!.reportType;
this.order = invoiceData.body!.order;
this.shop = invoiceData.body!.shop;
this.orderId = String(this.order._id);
// console.log('Generating QRCode....')
// console.log('Generating QRCode....')
this.codeString = `zcash:${this.order.address}?amount=${this.order.totalZec.toFixed(8)}&memo=${URLSafeBase64.encode(Buffer.from('ZGo Order::'.concat(this.orderId).concat(' Invoice: ').concat(this.order.externalInvoice)))}`;
this.codeString = `zcash:${this.order.address}?amount=${this.order.totalZec.toFixed(8)}&memo=${URLSafeBase64.encode(Buffer.from('ZGo Order::'.concat(this.orderId).concat(' Invoice: ').concat(this.order.externalInvoice)))}`;
var qrcode = new QRCode(document.getElementById("payment-qr"), {
text: this.codeString,
logo: "/assets/zcash.png",
width: 180,
height: 180,
logoWidth: 50,
logoHeight: 50,
correctLevel: QRCode.CorrectLevel.H
});
var qrcode = new QRCode(document.getElementById("invoice-qr"), {
text: this.codeString,
logo: "/assets/zcash.png",
width: 180,
height: 180,
logoWidth: 50,
logoHeight: 50,
correctLevel: QRCode.CorrectLevel.H
});
this.zcashUrl = this.sanitizer.bypassSecurityTrustUrl(this.codeString);
this.zcashUrl = this.sanitizer.bypassSecurityTrustUrl(this.codeString);
} else {
this.reportType = invoiceData.body!.reportType;
console.log('reportType ' + invoiceData.body!.reportType + ' code ' + invoiceData.status);
}
});
}