Implement link alternative to QR code

This commit is contained in:
Rene Vergara 2021-11-05 09:53:50 -05:00
parent 172f4da6b1
commit b88fe7fc20

View file

@ -1,5 +1,7 @@
import { Inject, Component, OnInit, ViewEncapsulation} from '@angular/core'; import { Inject, Component, OnInit, ViewEncapsulation} from '@angular/core';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
var QRCode = require('easyqrcodejs'); var QRCode = require('easyqrcodejs');
var URLSafeBase64 = require('urlsafe-base64'); var URLSafeBase64 = require('urlsafe-base64');
var Buffer = require('buffer/').Buffer; var Buffer = require('buffer/').Buffer;
@ -15,18 +17,21 @@ export class CheckoutComponent implements OnInit{
total: number; total: number;
orderId: string; orderId: string;
codeString: string = ''; codeString: string = '';
zcashUrl: SafeUrl;
constructor( constructor(
private dialogRef: MatDialogRef<CheckoutComponent>, private dialogRef: MatDialogRef<CheckoutComponent>,
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}
) { ) {
this.address = data.addr; this.address = data.addr;
this.total = data.totalZec; this.total = data.totalZec;
this.orderId = data.orderId; 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.zcashUrl = this.sanitizer.bypassSecurityTrustUrl(this.codeString);
} }
ngOnInit() { ngOnInit() {
this.codeString = `zcash:${this.address}?amount=${this.total.toFixed(6)}&memo=${URLSafeBase64.encode(Buffer.from('Z-Go Order '.concat(this.orderId)))}`;
var qrcode = new QRCode(document.getElementById("checkout-qr"), { var qrcode = new QRCode(document.getElementById("checkout-qr"), {
text: this.codeString, text: this.codeString,
logo: "/assets/zcash.png", logo: "/assets/zcash.png",