Remove order-creation logic from component
This commit is contained in:
parent
cb8df58cfc
commit
9a501e9665
2 changed files with 270 additions and 455 deletions
|
@ -24,11 +24,11 @@
|
||||||
<div style="height: 50px;">
|
<div style="height: 50px;">
|
||||||
</div>
|
</div>
|
||||||
<div style="font-weight: 700;
|
<div style="font-weight: 700;
|
||||||
font-size: 25px;
|
fonT-size: 25px;
|
||||||
text-align: center;">
|
text-align: center;">
|
||||||
{{ vE.pmtservicePmtsrvNot }}<br>
|
{{ vE.pmtservicePmtsrvNot }}<br>
|
||||||
{{ vE.pmtserviceEnabledFor }}<br>
|
{{ vE.pmtserviceEnabledFor }}<br>
|
||||||
{{ owner.name}}
|
{{ shop }}
|
||||||
</div>
|
</div>
|
||||||
<div style="height: 40px;">
|
<div style="height: 40px;">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,8 +4,6 @@ import { HttpClient, HttpParams, HttpHeaders } from "@angular/common/http";
|
||||||
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
||||||
import { PmtData } from "./pmtservice.model";
|
import { PmtData } from "./pmtservice.model";
|
||||||
import { XeroInvoice } from "./xeroinvoice.model";
|
import { XeroInvoice } from "./xeroinvoice.model";
|
||||||
import { Owner } from '../owner.model';
|
|
||||||
// import { Item } from '../items/item.model'
|
|
||||||
import { Order } from '../order/order.model'
|
import { Order } from '../order/order.model'
|
||||||
import { ConfigData } from '../configdata';
|
import { ConfigData } from '../configdata';
|
||||||
import { faCheck, faHourglass } from '@fortawesome/free-solid-svg-icons';
|
import { faCheck, faHourglass } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
@ -19,481 +17,298 @@ var Buffer = require('buffer/').Buffer;
|
||||||
import { LanguageService } from '../language.service';
|
import { LanguageService } from '../language.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-pmtservice',
|
selector: 'app-pmtservice',
|
||||||
templateUrl: './pmtservice.component.html',
|
templateUrl: './pmtservice.component.html',
|
||||||
styleUrls: ['./pmtservice.component.css']
|
styleUrls: ['./pmtservice.component.css']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class PmtserviceComponent implements OnInit {
|
export class PmtserviceComponent implements OnInit {
|
||||||
|
|
||||||
faCheck = faCheck;
|
faCheck = faCheck;
|
||||||
faHourglass = faHourglass;
|
faHourglass = faHourglass;
|
||||||
|
|
||||||
beUrl = ConfigData.Be_URL;
|
beUrl = ConfigData.Be_URL;
|
||||||
private reqHeaders: HttpHeaders = new HttpHeaders();
|
private reqHeaders: HttpHeaders = new HttpHeaders();
|
||||||
|
|
||||||
public pmtData : PmtData = {
|
public shop: string = '';
|
||||||
ownerId :'',
|
public pmtData : PmtData = {
|
||||||
invoice: '',
|
ownerId :'',
|
||||||
amount: 0,
|
invoice: '',
|
||||||
currency: '',
|
amount: 0,
|
||||||
shortcode: ''
|
currency: '',
|
||||||
};
|
shortcode: ''
|
||||||
|
};
|
||||||
|
|
||||||
public invData : XeroInvoice = {
|
public invData : XeroInvoice = {
|
||||||
inv_Type : '',
|
inv_Type : '',
|
||||||
inv_Id : '',
|
inv_Id : '',
|
||||||
inv_No : '',
|
inv_No : '',
|
||||||
inv_Contact : '',
|
inv_Contact : '',
|
||||||
inv_Currency : '',
|
inv_Currency : '',
|
||||||
inv_CurrencyRate : 0,
|
inv_CurrencyRate : 0,
|
||||||
inv_Status : '',
|
inv_Status : '',
|
||||||
inv_Total : 0,
|
inv_Total : 0,
|
||||||
inv_Date : new Date(),
|
inv_Date : new Date(),
|
||||||
inv_shortCode : '',
|
inv_shortCode : '',
|
||||||
inv_ProcDate : new Date()
|
inv_ProcDate : new Date()
|
||||||
};
|
};
|
||||||
|
|
||||||
public owner: Owner = {
|
|
||||||
_id: '',
|
|
||||||
address: '',
|
|
||||||
name: '',
|
|
||||||
currency: 'usd',
|
|
||||||
tax: false,
|
|
||||||
taxValue: 0,
|
|
||||||
vat: false,
|
|
||||||
vatValue: 0,
|
|
||||||
paid: false,
|
|
||||||
zats: false,
|
|
||||||
invoices: false,
|
|
||||||
expiration: new Date(Date.now()).toISOString(),
|
|
||||||
payconf: false,
|
|
||||||
crmToken: '',
|
|
||||||
viewkey: ''
|
|
||||||
};
|
|
||||||
|
|
||||||
public order: Order = {
|
public order: Order = {
|
||||||
_id : '',
|
_id : '',
|
||||||
address: '',
|
address: '',
|
||||||
session: '',
|
session: '',
|
||||||
timestamp: '',
|
timestamp: '',
|
||||||
closed: false,
|
closed: false,
|
||||||
currency: '',
|
currency: '',
|
||||||
price: 0,
|
price: 0,
|
||||||
total: 0,
|
total: 0,
|
||||||
totalZec: 0,
|
totalZec: 0,
|
||||||
paid: false,
|
paid: false,
|
||||||
externalInvoice: '',
|
externalInvoice: '',
|
||||||
shortCode: '',
|
shortCode: '',
|
||||||
token: '',
|
token: '',
|
||||||
lines: [
|
lines: [
|
||||||
{
|
{
|
||||||
qty: 1,
|
qty: 1,
|
||||||
name: '',
|
name: '',
|
||||||
cost:0
|
cost:0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
private invData_raw : string = '';
|
private invData_raw : string = '';
|
||||||
private invData_buff : any = null;
|
private invData_buff : any = null;
|
||||||
|
|
||||||
public reportType = 1000;
|
public reportType = 1000;
|
||||||
public Status = 0;
|
public Status = 0;
|
||||||
|
|
||||||
codeString: string = '';
|
codeString: string = '';
|
||||||
zcashUrl: SafeUrl = '';
|
zcashUrl: SafeUrl = '';
|
||||||
zPrice: number = 1.0;
|
zPrice: number = 1.0;
|
||||||
name: string = '';
|
name: string = '';
|
||||||
error: boolean = false;
|
error: boolean = false;
|
||||||
orderId : string = '';
|
orderId : string = '';
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
// Language Support
|
// Language Support
|
||||||
//
|
//
|
||||||
vE = {
|
vE = {
|
||||||
pmtserviceInvalidOwnerid : '',
|
pmtserviceInvalidOwnerid : '',
|
||||||
pmtserviceNotservClose : '',
|
pmtserviceNotservClose : '',
|
||||||
pmtserviceNotservError : '',
|
pmtserviceNotservError : '',
|
||||||
pmtserviceCopyNotavail : '',
|
pmtserviceCopyNotavail : '',
|
||||||
pmtserviceCopyaddressError : '',
|
pmtserviceCopyaddressError : '',
|
||||||
pmtserviceCopyamountError : '',
|
pmtserviceCopyamountError : '',
|
||||||
pmtserviceCopymemoError : '',
|
pmtserviceCopymemoError : '',
|
||||||
pmtservicePaymentNotprocessed : '',
|
pmtservicePaymentNotprocessed : '',
|
||||||
pmtservicePmtsrvNot : '',
|
pmtservicePmtsrvNot : '',
|
||||||
pmtserviceEnabledFor : '',
|
pmtserviceEnabledFor : '',
|
||||||
pmtserviceConnectoXero : '',
|
pmtserviceConnectoXero : '',
|
||||||
pmtserviceServerFailed : '',
|
pmtserviceServerFailed : '',
|
||||||
pmtserviceInvoiceNum : '',
|
pmtserviceInvoiceNum : '',
|
||||||
pmtserviceInvoiceNotfound : '',
|
pmtserviceInvoiceNotfound : '',
|
||||||
pmtserviceInvoiceInvalid : '',
|
pmtserviceInvoiceInvalid : '',
|
||||||
pmtserviceInvoicePaid : '',
|
pmtserviceInvoicePaid : '',
|
||||||
pmtserviceInvoiceCurrency : '',
|
pmtserviceInvoiceCurrency : '',
|
||||||
pmtserviceCurrencyNotsup : '',
|
pmtserviceCurrencyNotsup : '',
|
||||||
pmtserviceAmountDoesnot : '',
|
pmtserviceAmountDoesnot : '',
|
||||||
pmtserviceMatchValue : '',
|
pmtserviceMatchValue : '',
|
||||||
pmtserviceReportedByxero : '',
|
pmtserviceReportedByxero : '',
|
||||||
pmtserviceHdrTxt1 : '',
|
pmtserviceHdrTxt1 : '',
|
||||||
pmtserviceHdrTxt2 : '',
|
pmtserviceHdrTxt2 : '',
|
||||||
pmtserviceHdrTxt3 : '',
|
pmtserviceHdrTxt3 : '',
|
||||||
pmtserviceZecdataPrice : '',
|
pmtserviceZecdataPrice : '',
|
||||||
pmtserviceZecdataTotal : '',
|
pmtserviceZecdataTotal : '',
|
||||||
pmtserviceInvoiceItem : '',
|
pmtserviceInvoiceItem : '',
|
||||||
pmtserviceInvoiceQty : '',
|
pmtserviceInvoiceQty : '',
|
||||||
pmtserviceInvoicePrice : '',
|
pmtserviceInvoicePrice : '',
|
||||||
pmtserviceInvoiceTotal : '',
|
pmtserviceInvoiceTotal : '',
|
||||||
pmtservicePaymentConfirmed : '',
|
pmtservicePaymentConfirmed : '',
|
||||||
pmtservicePaymentPending : '',
|
pmtservicePaymentPending : '',
|
||||||
pmtserviceScanQrcode : '',
|
pmtserviceScanQrcode : '',
|
||||||
pmtserviceCantScan : '',
|
pmtserviceCantScan : '',
|
||||||
pmtserviceUseThis : '',
|
pmtserviceUseThis : '',
|
||||||
pmtserviceWalletLink : '',
|
pmtserviceWalletLink : '',
|
||||||
pmtserviceCopyAddress : '',
|
pmtserviceCopyAddress : '',
|
||||||
pmtserviceCopyAmount : '',
|
pmtserviceCopyAmount : '',
|
||||||
pmtserviceCopyMemo : ''
|
pmtserviceCopyMemo : ''
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
constructor(private activatedRoute : ActivatedRoute,
|
constructor(private activatedRoute : ActivatedRoute,
|
||||||
private http : HttpClient,
|
private http : HttpClient,
|
||||||
private sanitizer: DomSanitizer,
|
private sanitizer: DomSanitizer,
|
||||||
private notifierService : NotifierService,
|
private notifierService : NotifierService,
|
||||||
private languageService : LanguageService ) {}
|
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) => {
|
|
||||||
this.pmtData.ownerId = params["owner"];
|
|
||||||
this.pmtData.invoice = params["invoiceNo"];
|
|
||||||
this.pmtData.amount = params["amount"];
|
|
||||||
this.pmtData.currency = params["currency"];
|
|
||||||
this.pmtData.shortcode = params["shortCode"];
|
|
||||||
this.getInvoiceData( this.pmtData );
|
|
||||||
});
|
|
||||||
this.chgUILanguage();
|
|
||||||
}
|
|
||||||
|
|
||||||
getInvoiceData( reqData : PmtData ) {
|
ngOnInit() {
|
||||||
|
var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
|
||||||
|
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
|
||||||
|
this.activatedRoute.queryParams.subscribe((params) => {
|
||||||
|
this.pmtData.ownerId = params["owner"];
|
||||||
|
this.pmtData.invoice = params["invoiceNo"];
|
||||||
|
this.pmtData.amount = params["amount"];
|
||||||
|
this.pmtData.currency = params["currency"];
|
||||||
|
this.pmtData.shortcode = params["shortCode"];
|
||||||
|
this.getInvoiceData( this.pmtData );
|
||||||
|
});
|
||||||
|
this.chgUILanguage();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
getInvoiceData( reqData : PmtData ) {
|
||||||
// Verify owner id ( Status = 1 if not exists )
|
//this.getXeroInvoiceData( reqData );
|
||||||
// ( Status = 2 if service not available for user )
|
let obs = this.http.post<{reportType: number, order: Order, shop: string}>
|
||||||
//
|
(this.beUrl+'invdata',
|
||||||
// console.log('getOwner -> '+ reqData.ownerId);
|
{payload: reqData},
|
||||||
// console.log('received amount -> ' + reqData.amount);
|
{headers: this.reqHeaders, observe: 'response' }
|
||||||
const ownParams = new HttpParams().append('id', reqData.ownerId);
|
);
|
||||||
let obs = this.http.get<{message:string, owner: any}>
|
obs.subscribe((invoiceData) => {
|
||||||
( this.beUrl+'ownerid',
|
this.reportType = invoiceData.body!.reportType;
|
||||||
{ headers: this.reqHeaders,
|
this.order = invoiceData.body!.order;
|
||||||
params: ownParams,
|
this.shop = invoiceData.body!.shop;
|
||||||
observe: 'response'});
|
this.orderId = String(this.order._id);
|
||||||
obs.subscribe((OwnerDataResponse) => {
|
|
||||||
//console.log('api/getowner', OwnerDataResponse.status);
|
|
||||||
if (OwnerDataResponse.status == 200) {
|
|
||||||
this.owner = OwnerDataResponse.body!.owner;
|
|
||||||
console.log('Owner => ' + this.owner.name );
|
|
||||||
//
|
|
||||||
// ==> remove "== false" for production enviroment
|
|
||||||
//
|
|
||||||
if ( this.owner.invoices ) {
|
|
||||||
// process data
|
|
||||||
console.log("Owner check passed!!!");
|
|
||||||
this.getXeroInvoiceData( reqData );
|
|
||||||
} else {
|
|
||||||
console.log("Owner check failed!!!")
|
|
||||||
this.reportType = 2;
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
if ( OwnerDataResponse.status == 204 ) {
|
|
||||||
console.log('Res.Status = ' + OwnerDataResponse.status)
|
|
||||||
console.log('Owner id not found!!!');
|
|
||||||
this.reportType = 1;
|
|
||||||
}
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
|
|
||||||
getXeroInvoiceData( reqData : PmtData ) {
|
// 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)))}`;
|
||||||
// Call test Xero API
|
|
||||||
let url : string = "http://localhost:3000/xero/" + reqData.invoice;
|
|
||||||
this.http
|
|
||||||
.get<any>(url)
|
|
||||||
*/
|
|
||||||
console.log('>> find current zcash price');
|
|
||||||
this.getPrice(this.owner.currency);
|
|
||||||
|
|
||||||
console.log('get Invoice -> ' + reqData.invoice);
|
var qrcode = new QRCode(document.getElementById("payment-qr"), {
|
||||||
let invParams = new HttpParams();
|
text: this.codeString,
|
||||||
invParams = invParams.append('address', this.owner.address);
|
logo: "/assets/zcash.png",
|
||||||
invParams = invParams.append('inv', reqData.invoice);
|
width: 180,
|
||||||
let inv = this.http.get<{message:string, invData: any}>
|
height: 180,
|
||||||
( this.beUrl+'invdata',
|
logoWidth: 50,
|
||||||
{ headers: this.reqHeaders,
|
logoHeight: 50,
|
||||||
params: invParams,
|
correctLevel: QRCode.CorrectLevel.H
|
||||||
observe: 'response'});
|
});
|
||||||
inv.subscribe( invDataResponse => {
|
|
||||||
// console.log('Response from ZGo-Xero');
|
|
||||||
// console.log(invDataResponse.status);
|
|
||||||
this.invData_buff = invDataResponse.body;
|
|
||||||
this.invData.inv_Type = this.invData_buff.invdata.inv_Type;
|
|
||||||
this.invData.inv_Id = this.invData_buff.invdata.inv_Id;
|
|
||||||
this.invData.inv_No = this.invData_buff.invdata.inv_No;
|
|
||||||
this.invData.inv_Contact = this.invData_buff.invdata.inv_Contact;
|
|
||||||
this.invData.inv_Currency = this.invData_buff.invdata.inv_Currency;
|
|
||||||
this.invData.inv_CurrencyRate = this.invData_buff.invdata.inv_CurrencyRate;
|
|
||||||
this.invData.inv_Total = this.invData_buff.invdata.inv_Total;
|
|
||||||
this.invData.inv_Status = this.invData_buff.invdata.inv_Status;
|
|
||||||
this.invData.inv_Date = this.invData_buff.invdata.inv_Date;
|
|
||||||
this.invData.inv_shortCode = reqData.shortcode;
|
|
||||||
/*
|
|
||||||
console.log('>>> inv_Type -> ' + this.invData.inv_Type);
|
|
||||||
console.log('>>> inv_Id -> ' + this.invData.inv_Id);
|
|
||||||
console.log('>>> inv_No -> ' + this.invData.inv_No);
|
|
||||||
console.log('>>> inv_Contact -> ' + this.invData.inv_Contact);
|
|
||||||
console.log('>>> inv_Currency-> ' + this.invData.inv_Currency);
|
|
||||||
console.log('>>> inv_CurrencyRate -> ' + this.invData.inv_CurrencyRate);
|
|
||||||
console.log('>>> inv_Total -> ' + this.invData.inv_Total);
|
|
||||||
console.log('>>> inv_Status-> ' + this.invData.inv_Status);
|
|
||||||
console.log('>>> inv_Date -> ' + this.invData.inv_Date);
|
|
||||||
*/
|
|
||||||
if ( this.invData.inv_Type == 'ACCREC' ) {
|
|
||||||
console.log('Invoice type is correct!!');
|
|
||||||
// Test if invoice is not already paid
|
|
||||||
if ( this.invData.inv_Status == 'AUTHORISED') {
|
|
||||||
console.log('invoice is payable');
|
|
||||||
// Test if Invoice's currency is supported
|
|
||||||
if ( this.invData.inv_Currency == reqData.currency ) {
|
|
||||||
console.log('Invoice currency supported');
|
|
||||||
// Test if requested amount is as reported by Xero
|
|
||||||
if ( this.invData.inv_Total == reqData.amount ) {
|
|
||||||
console.log('Invoice amount Ok - create Order');
|
|
||||||
// =====> Create order here
|
|
||||||
this.createOrder();
|
|
||||||
//
|
|
||||||
} else {
|
|
||||||
console.log('Invoice amount does not match')
|
|
||||||
this.reportType = 8;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log('Invoice currency not supported');
|
|
||||||
this.reportType = 7;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log('Invoice already paid');
|
|
||||||
this.reportType = 6;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log('Invoice type is invalid' );
|
|
||||||
this.reportType = 5;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
console.log("Error while getting invData!!!");
|
|
||||||
console.log(error);
|
|
||||||
console.log(error.status);
|
|
||||||
if ( error.status == 500 ) {
|
|
||||||
// Assume that invoice was not found by haskell server
|
|
||||||
this.reportType = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
this.zcashUrl = this.sanitizer.bypassSecurityTrustUrl(this.codeString);
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
createOrder() {
|
getIconStyle(order : Order) {
|
||||||
this.reportType = 0;
|
if( order.paid )
|
||||||
// console.log('Starting order generation');
|
return "font-size: 14px; color: #72cc50; margin-bottom: -2px;";
|
||||||
// console.log('>> find current zcash price');
|
return "color: #FB4F14; margin-bottom: -2px; cursor: pointer;";
|
||||||
|
|
||||||
this.order = {
|
}
|
||||||
_id: '',
|
|
||||||
address: this.owner.address,
|
|
||||||
session: 'Xero-' + this.owner._id,
|
|
||||||
currency: this.owner.currency,
|
|
||||||
timestamp: new Date(Date.now()).toISOString(),
|
|
||||||
closed: true,
|
|
||||||
totalZec: this.invData.inv_Total/this.zPrice,
|
|
||||||
price: this.zPrice,
|
|
||||||
total: this.invData.inv_Total,
|
|
||||||
paid: false,
|
|
||||||
externalInvoice: this.invData.inv_No,
|
|
||||||
shortCode: this.invData.inv_shortCode,
|
|
||||||
token: '',
|
|
||||||
lines: [{qty: 1,
|
|
||||||
name: 'Invoice from ' + this.owner.name + '[' + this.invData.inv_No + ']',
|
|
||||||
cost: this.invData.inv_Total}]
|
|
||||||
};
|
|
||||||
|
|
||||||
let obs = this.http.post<{message: string, order: Order}>
|
copyAddress() {
|
||||||
(this.beUrl+'api/orderx',
|
if (!navigator.clipboard) {
|
||||||
{payload: this.order},
|
// alert("Copy functionality not supported");
|
||||||
{ headers: this.reqHeaders }
|
this.notifierService
|
||||||
);
|
.showNotification(this.vE.pmtserviceCopyNotavail,
|
||||||
obs.subscribe((orderData) => {
|
this.vE.pmtserviceNotservClose,
|
||||||
// console.log('Order created');
|
"error",
|
||||||
|
this.vE.pmtserviceNotservError);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
navigator.clipboard.writeText(this.order.address);
|
||||||
|
} catch (err) {
|
||||||
|
this.notifierService
|
||||||
|
.showNotification(this.vE.pmtserviceCopyaddressError,
|
||||||
|
this.vE.pmtserviceNotservClose,
|
||||||
|
"error",
|
||||||
|
this.vE.pmtserviceNotservError);
|
||||||
|
// console.error("Error", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// console.log(orderData.order);
|
copyAmount() {
|
||||||
this.order = orderData.order
|
if (!navigator.clipboard) {
|
||||||
console.log('>> order -> ' + JSON.stringify(this.order));
|
// alert("Copy functionality not supported");
|
||||||
this.orderId = String(this.order._id);
|
this.notifierService
|
||||||
|
.showNotification(this.vE.pmtserviceCopyNotavail,
|
||||||
|
this.vE.pmtserviceNotservClose,
|
||||||
|
"error",
|
||||||
|
this.vE.pmtserviceNotservError);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
navigator.clipboard.writeText(this.order.totalZec.toString());
|
||||||
|
} catch (err) {
|
||||||
|
this.notifierService
|
||||||
|
.showNotification(this.vE.pmtserviceCopyamountError,
|
||||||
|
this.vE.pmtserviceNotservClose,
|
||||||
|
"error",
|
||||||
|
this.vE.pmtserviceNotservError);
|
||||||
|
// console.error("Error", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// console.log('Generating QRCode....')
|
copyMemo() {
|
||||||
|
if (!navigator.clipboard) {
|
||||||
|
// alert("Copy functionality not supported");
|
||||||
|
this.notifierService
|
||||||
|
.showNotification(this.vE.pmtserviceCopyNotavail,
|
||||||
|
this.vE.pmtserviceNotservClose,
|
||||||
|
"error",
|
||||||
|
this.vE.pmtserviceNotservError);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
navigator.clipboard.writeText("ZGo Order::" + this.orderId + " Invoice: " + this.order.externalInvoice);
|
||||||
|
} catch (err) {
|
||||||
|
this.notifierService
|
||||||
|
.showNotification(this.vE.pmtserviceCopymemoError,
|
||||||
|
this.vE.pmtserviceNotservClose,
|
||||||
|
"error",
|
||||||
|
this.vE.pmtserviceNotservError);
|
||||||
|
// console.error("Error", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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(orderData.order.externalInvoice)))}`;
|
chgUILanguage(){
|
||||||
|
console.log('PMTSERVICE.chgUILanguage Called ');
|
||||||
|
this.languageService.getViewElements('pmtservice').subscribe(
|
||||||
|
response => {
|
||||||
|
console.log('Received >> ', response );
|
||||||
|
console.log('Language Code : ', response.language);
|
||||||
|
console.log('Component Name : ',response.component);
|
||||||
|
console.log('Language data : ',response.data);
|
||||||
|
|
||||||
var qrcode = new QRCode(document.getElementById("payment-qr"), {
|
this.vE.pmtserviceInvalidOwnerid = response.data.pmtservice_invalid_ownerid;
|
||||||
text: this.codeString,
|
this.vE.pmtserviceNotservClose = response.data.pmtservice_notserv_close;
|
||||||
logo: "/assets/zcash.png",
|
this.vE.pmtserviceNotservError = response.data.pmtservice_notserv_error;
|
||||||
width: 180,
|
this.vE.pmtserviceCopyNotavail = response.data.pmtservice_copy_notavail;
|
||||||
height: 180,
|
this.vE.pmtserviceCopyaddressError = response.data.pmtservice_copyaddress_error;
|
||||||
logoWidth: 50,
|
this.vE.pmtserviceCopyamountError = response.data.pmtservice_copyamount_error;
|
||||||
logoHeight: 50,
|
this.vE.pmtserviceCopymemoError = response.data.pmtservice_copymemo_error;
|
||||||
correctLevel: QRCode.CorrectLevel.H
|
this.vE.pmtservicePaymentNotprocessed = response.data.pmtservice_payment_notprocessed;
|
||||||
});
|
this.vE.pmtservicePmtsrvNot = response.data.pmtservice_pmtsrv_not;
|
||||||
|
this.vE.pmtserviceEnabledFor = response.data.pmtservice_enabled_for;
|
||||||
|
this.vE.pmtserviceConnectoXero = response.data.pmtservice_connecto_xero;
|
||||||
|
this.vE.pmtserviceServerFailed = response.data.pmtservice_server_failed;
|
||||||
|
this.vE.pmtserviceInvoiceNum = response.data.pmtservice_invoice_num;
|
||||||
|
this.vE.pmtserviceInvoiceNotfound = response.data.pmtservice_invoice_notfound;
|
||||||
|
this.vE.pmtserviceInvoiceInvalid = response.data.pmtservice_invoice_invalid;
|
||||||
|
this.vE.pmtserviceInvoicePaid = response.data.pmtservice_invoice_paid;
|
||||||
|
this.vE.pmtserviceInvoiceCurrency = response.data.pmtservice_invoice_currency;
|
||||||
|
this.vE.pmtserviceCurrencyNotsup = response.data.pmtservice_currensy_notsup;
|
||||||
|
this.vE.pmtserviceAmountDoesnot = response.data.pmtservice_amount_doesnot;
|
||||||
|
this.vE.pmtserviceMatchValue = response.data.pmtservice_match_value;
|
||||||
|
this.vE.pmtserviceReportedByxero = response.data.pmtservice_reported_byxero;
|
||||||
|
this.vE.pmtserviceHdrTxt1 = response.data.pmtservice_hdr_txt1;
|
||||||
|
this.vE.pmtserviceHdrTxt2 = response.data.pmtservice_hdr_txt2;
|
||||||
|
this.vE.pmtserviceHdrTxt3 = response.data.pmtservice_hdr_txt3;
|
||||||
|
this.vE.pmtserviceZecdataPrice = response.data.pmtservice_zecdata_price;
|
||||||
|
this.vE.pmtserviceZecdataTotal = response.data.pmtservice_zecdata_total;
|
||||||
|
this.vE.pmtserviceInvoiceItem = response.data.pmtservice_invoice_item;
|
||||||
|
this.vE.pmtserviceInvoiceQty = response.data.pmtservice_invoice_qty;
|
||||||
|
this.vE.pmtserviceInvoicePrice = response.data.pmtservice_invoice_price;
|
||||||
|
this.vE.pmtserviceInvoiceTotal = response.data.pmtservice_invoice_total;
|
||||||
|
this.vE.pmtservicePaymentConfirmed = response.data.pmtservice_payment_confirmed;
|
||||||
|
this.vE.pmtservicePaymentPending = response.data.pmtservice_payment_pending;
|
||||||
|
this.vE.pmtserviceScanQrcode = response.data.pmtservice_scan_qrcode;
|
||||||
|
this.vE.pmtserviceCantScan = response.data.pmtservice_cant_scan;
|
||||||
|
this.vE.pmtserviceUseThis = response.data.pmtservice_use_this;
|
||||||
|
this.vE.pmtserviceWalletLink = response.data.pmtservice_wallet_link;
|
||||||
|
this.vE.pmtserviceCopyAddress = response.data.pmtservice_copy_address;
|
||||||
|
this.vE.pmtserviceCopyAmount = response.data.pmtservice_copy_amount;
|
||||||
|
this.vE.pmtserviceCopyMemo = response.data.pmtservice_copy_memo;
|
||||||
|
|
||||||
this.zcashUrl = this.sanitizer.bypassSecurityTrustUrl(this.codeString);
|
},
|
||||||
}, error => {
|
error => { console.log('Error >> ',error); }
|
||||||
console.log(error.message);
|
);
|
||||||
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getIconStyle(order : Order) {
|
|
||||||
if( order.paid )
|
|
||||||
return "font-size: 14px; color: #72cc50; margin-bottom: -2px;";
|
|
||||||
return "color: #FB4F14; margin-bottom: -2px; cursor: pointer;";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
getPrice(currency: string){
|
|
||||||
//var currency = 'usd';
|
|
||||||
const params = new HttpParams().append('currency', currency);
|
|
||||||
let obs = this.http.get<{message: string, price: any}>(this.beUrl+'api/price', { headers:this.reqHeaders, params: params, observe: 'response'});
|
|
||||||
obs.subscribe((PriceData) => {
|
|
||||||
if (PriceData.status == 200) {
|
|
||||||
this.zPrice = PriceData.body!.price.price;
|
|
||||||
console.log("price", this.zPrice);
|
|
||||||
} else {
|
|
||||||
console.log('No price found for currency', currency);
|
|
||||||
this.zPrice = 1.0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return obs;
|
|
||||||
}
|
|
||||||
|
|
||||||
copyAddress() {
|
|
||||||
if (!navigator.clipboard) {
|
|
||||||
// alert("Copy functionality not supported");
|
|
||||||
this.notifierService
|
|
||||||
.showNotification(this.vE.pmtserviceCopyNotavail,
|
|
||||||
this.vE.pmtserviceNotservClose,
|
|
||||||
"error",
|
|
||||||
this.vE.pmtserviceNotservError);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
navigator.clipboard.writeText(this.order.address);
|
|
||||||
} catch (err) {
|
|
||||||
this.notifierService
|
|
||||||
.showNotification(this.vE.pmtserviceCopyaddressError,
|
|
||||||
this.vE.pmtserviceNotservClose,
|
|
||||||
"error",
|
|
||||||
this.vE.pmtserviceNotservError);
|
|
||||||
// console.error("Error", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
copyAmount() {
|
|
||||||
if (!navigator.clipboard) {
|
|
||||||
// alert("Copy functionality not supported");
|
|
||||||
this.notifierService
|
|
||||||
.showNotification(this.vE.pmtserviceCopyNotavail,
|
|
||||||
this.vE.pmtserviceNotservClose,
|
|
||||||
"error",
|
|
||||||
this.vE.pmtserviceNotservError);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
navigator.clipboard.writeText(this.order.totalZec.toString());
|
|
||||||
} catch (err) {
|
|
||||||
this.notifierService
|
|
||||||
.showNotification(this.vE.pmtserviceCopyamountError,
|
|
||||||
this.vE.pmtserviceNotservClose,
|
|
||||||
"error",
|
|
||||||
this.vE.pmtserviceNotservError);
|
|
||||||
// console.error("Error", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
copyMemo() {
|
|
||||||
if (!navigator.clipboard) {
|
|
||||||
// alert("Copy functionality not supported");
|
|
||||||
this.notifierService
|
|
||||||
.showNotification(this.vE.pmtserviceCopyNotavail,
|
|
||||||
this.vE.pmtserviceNotservClose,
|
|
||||||
"error",
|
|
||||||
this.vE.pmtserviceNotservError);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
navigator.clipboard.writeText("ZGo Order::" + this.orderId + " Invoice: " + this.order.externalInvoice);
|
|
||||||
} catch (err) {
|
|
||||||
this.notifierService
|
|
||||||
.showNotification(this.vE.pmtserviceCopymemoError,
|
|
||||||
this.vE.pmtserviceNotservClose,
|
|
||||||
"error",
|
|
||||||
this.vE.pmtserviceNotservError);
|
|
||||||
// console.error("Error", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
chgUILanguage(){
|
|
||||||
console.log('PMTSERVICE.chgUILanguage Called ');
|
|
||||||
this.languageService.getViewElements('pmtservice').subscribe(
|
|
||||||
response => {
|
|
||||||
console.log('Received >> ', response );
|
|
||||||
console.log('Language Code : ', response.language);
|
|
||||||
console.log('Component Name : ',response.component);
|
|
||||||
console.log('Language data : ',response.data);
|
|
||||||
|
|
||||||
this.vE.pmtserviceInvalidOwnerid = response.data.pmtservice_invalid_ownerid;
|
|
||||||
this.vE.pmtserviceNotservClose = response.data.pmtservice_notserv_close;
|
|
||||||
this.vE.pmtserviceNotservError = response.data.pmtservice_notserv_error;
|
|
||||||
this.vE.pmtserviceCopyNotavail = response.data.pmtservice_copy_notavail;
|
|
||||||
this.vE.pmtserviceCopyaddressError = response.data.pmtservice_copyaddress_error;
|
|
||||||
this.vE.pmtserviceCopyamountError = response.data.pmtservice_copyamount_error;
|
|
||||||
this.vE.pmtserviceCopymemoError = response.data.pmtservice_copymemo_error;
|
|
||||||
this.vE.pmtservicePaymentNotprocessed = response.data.pmtservice_payment_notprocessed;
|
|
||||||
this.vE.pmtservicePmtsrvNot = response.data.pmtservice_pmtsrv_not;
|
|
||||||
this.vE.pmtserviceEnabledFor = response.data.pmtservice_enabled_for;
|
|
||||||
this.vE.pmtserviceConnectoXero = response.data.pmtservice_connecto_xero;
|
|
||||||
this.vE.pmtserviceServerFailed = response.data.pmtservice_server_failed;
|
|
||||||
this.vE.pmtserviceInvoiceNum = response.data.pmtservice_invoice_num;
|
|
||||||
this.vE.pmtserviceInvoiceNotfound = response.data.pmtservice_invoice_notfound;
|
|
||||||
this.vE.pmtserviceInvoiceInvalid = response.data.pmtservice_invoice_invalid;
|
|
||||||
this.vE.pmtserviceInvoicePaid = response.data.pmtservice_invoice_paid;
|
|
||||||
this.vE.pmtserviceInvoiceCurrency = response.data.pmtservice_invoice_currency;
|
|
||||||
this.vE.pmtserviceCurrencyNotsup = response.data.pmtservice_currensy_notsup;
|
|
||||||
this.vE.pmtserviceAmountDoesnot = response.data.pmtservice_amount_doesnot;
|
|
||||||
this.vE.pmtserviceMatchValue = response.data.pmtservice_match_value;
|
|
||||||
this.vE.pmtserviceReportedByxero = response.data.pmtservice_reported_byxero;
|
|
||||||
this.vE.pmtserviceHdrTxt1 = response.data.pmtservice_hdr_txt1;
|
|
||||||
this.vE.pmtserviceHdrTxt2 = response.data.pmtservice_hdr_txt2;
|
|
||||||
this.vE.pmtserviceHdrTxt3 = response.data.pmtservice_hdr_txt3;
|
|
||||||
this.vE.pmtserviceZecdataPrice = response.data.pmtservice_zecdata_price;
|
|
||||||
this.vE.pmtserviceZecdataTotal = response.data.pmtservice_zecdata_total;
|
|
||||||
this.vE.pmtserviceInvoiceItem = response.data.pmtservice_invoice_item;
|
|
||||||
this.vE.pmtserviceInvoiceQty = response.data.pmtservice_invoice_qty;
|
|
||||||
this.vE.pmtserviceInvoicePrice = response.data.pmtservice_invoice_price;
|
|
||||||
this.vE.pmtserviceInvoiceTotal = response.data.pmtservice_invoice_total;
|
|
||||||
this.vE.pmtservicePaymentConfirmed = response.data.pmtservice_payment_confirmed;
|
|
||||||
this.vE.pmtservicePaymentPending = response.data.pmtservice_payment_pending;
|
|
||||||
this.vE.pmtserviceScanQrcode = response.data.pmtservice_scan_qrcode;
|
|
||||||
this.vE.pmtserviceCantScan = response.data.pmtservice_cant_scan;
|
|
||||||
this.vE.pmtserviceUseThis = response.data.pmtservice_use_this;
|
|
||||||
this.vE.pmtserviceWalletLink = response.data.pmtservice_wallet_link;
|
|
||||||
this.vE.pmtserviceCopyAddress = response.data.pmtservice_copy_address;
|
|
||||||
this.vE.pmtserviceCopyAmount = response.data.pmtservice_copy_amount;
|
|
||||||
this.vE.pmtserviceCopyMemo = response.data.pmtservice_copy_memo;
|
|
||||||
|
|
||||||
},
|
|
||||||
error => { console.log('Error >> ',error); }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue