46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { Inject, Component, OnInit, ViewEncapsulation} from '@angular/core';
|
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
|
|
var QRCode = require('easyqrcodejs');
|
|
var URLSafeBase64 = require('urlsafe-base64');
|
|
var Buffer = require('buffer/').Buffer;
|
|
|
|
@Component({
|
|
selector: 'app-checkout',
|
|
templateUrl: './checkout.component.html',
|
|
styleUrls: ['./checkout.component.css']
|
|
})
|
|
|
|
export class CheckoutComponent implements OnInit{
|
|
address: string;
|
|
total: number;
|
|
orderId: string;
|
|
codeString: string = '';
|
|
|
|
constructor(
|
|
private dialogRef: MatDialogRef<CheckoutComponent>,
|
|
@Inject(MAT_DIALOG_DATA) public data: { totalZec: number, addr: string, orderId: string}
|
|
) {
|
|
this.address = data.addr;
|
|
this.total = data.totalZec;
|
|
this.orderId = data.orderId;
|
|
}
|
|
|
|
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"), {
|
|
text: this.codeString,
|
|
logo: "/assets/zcash.png",
|
|
logoWidth: 80,
|
|
logoHeight: 80
|
|
});
|
|
}
|
|
|
|
confirm() {
|
|
this.dialogRef.close(true);
|
|
}
|
|
|
|
close() {
|
|
this.dialogRef.close(false);
|
|
}
|
|
}
|