diff --git a/CHANGELOG.md b/CHANGELOG.md index 567a428..ab38f62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed - Parametrization of text elements +- Expanded Xero reference message to include ZEC amount ## [1.4.1] - 2023-01-09 @@ -76,15 +77,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Convenience buttons on checkout for wallets that are not ZIP-321-compliant - PmtService Component first alpha version ready for testing +- Add `crmToken` field to `owner.model.ts` +- Add `externalInvoice` field and `shortCode` field to `order.model.ts` ### Fixed - Memo for checkout orders -## Added - -- Add `crmToken` field to `owner.model.ts` -- Add `externalInvoice` field and `shortCode` field to `order.model.ts` ## [1.2.1] - 2022-08-01 diff --git a/src/app/invoice/invoice.component.ts b/src/app/invoice/invoice.component.ts index 96ae459..a3fffe4 100644 --- a/src/app/invoice/invoice.component.ts +++ b/src/app/invoice/invoice.component.ts @@ -31,50 +31,51 @@ export class InvoiceComponent implements OnInit { name: string = ''; error: boolean = false; codeString: string = 'Test'; - public isWCOrder : boolean = false; + invString: string = ''; + public isWCOrder : boolean = false; zcashUrl: SafeUrl = ''; externalURL: string = ''; order:Order = { - _id: '', - address: '', - session: '', - timestamp: '', - closed: false, - currency: '', - price: 0, - total: 0, - totalZec: 0, - paid: false, - externalInvoice: '', - shortCode: '', - lines: [ - { - qty: 1, - name: '', - cost:0 - } - ] - }; - // ------------------------------------- - // - // Language Support - // - vE = { - invoiceInvoiceLbl : '', - invoiceOrderId : '', - invoiceOrderDate : '', - invoiceZcashPrice : '', - invoiceQtyLbl : '', - invoiceOrderPrice : '', - invoiceInvoiceTotal : '', - invoicePaymentConfirmed : '', - invoicePaymentPending : '', - invoiceScanQrcode : '', - invoiceCantScan : '', - invoiceUseThis : '', - invoiceWalletLink : '', - invoiceDotOr : '', - invoiceCopyAddress : '', + _id: '', + address: '', + session: '', + timestamp: '', + closed: false, + currency: '', + price: 0, + total: 0, + totalZec: 0, + paid: false, + externalInvoice: '', + shortCode: '', + lines: [ + { + qty: 1, + name: '', + cost:0 + } + ] + }; + // ------------------------------------- + // + // Language Support + // + vE = { + invoiceInvoiceLbl : '', + invoiceOrderId : '', + invoiceOrderDate : '', + invoiceZcashPrice : '', + invoiceQtyLbl : '', + invoiceOrderPrice : '', + invoiceInvoiceTotal : '', + invoicePaymentConfirmed : '', + invoicePaymentPending : '', + invoiceScanQrcode : '', + invoiceCantScan : '', + invoiceUseThis : '', + invoiceWalletLink : '', + invoiceDotOr : '', + invoiceCopyAddress : '', invoiceCopyAmount : '', invoiceCopyMemo : '', invoiceReturnToshop : '', @@ -86,15 +87,15 @@ export class InvoiceComponent implements OnInit { invoiceCopymemoError : '', invoiceInvalidId : '', invoiceInfoNotavail : '' - }; - // + }; + // constructor( private _ActiveRoute:ActivatedRoute, private router: Router, - private sanitizer: DomSanitizer, + private sanitizer: DomSanitizer, public receiptService: ReceiptService, - private notifierService : NotifierService, - private languageService : LanguageService + private notifierService : NotifierService, + private languageService : LanguageService ) { this.orderId = this._ActiveRoute.snapshot.paramMap.get("orderId"); console.log('constructor - orderId -> ' + this.orderId); @@ -105,13 +106,13 @@ export class InvoiceComponent implements OnInit { this.error = false; this.codeString = `zcash:${response.body!.order.address}?amount=${response.body!.order.totalZec.toFixed(8)}&memo=${URLSafeBase64.encode(Buffer.from('ZGo Order::'.concat(this.orderId!)))}`; 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 + text: this.codeString, + logo: "/assets/zcash.png", + width: 180, + height: 180, + logoWidth: 50, + logoHeight: 50, + correctLevel: QRCode.CorrectLevel.H }); this.error = false; } else { @@ -124,8 +125,11 @@ export class InvoiceComponent implements OnInit { if ( order.session.substring(0,1) == 'W') { this.isWCOrder = true; } - 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); + if( order.session.substring(0,1) == 'X') { + this.invString = 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.invString)))}`; + this.zcashUrl = this.sanitizer.bypassSecurityTrustUrl(this.codeString); }); this.nameUpdate.subscribe(name => { this.name = name; @@ -133,23 +137,23 @@ export class InvoiceComponent implements OnInit { } ngOnInit(): void { - this.chgUILanguage(); - } + this.chgUILanguage(); + } backToShop() { if ( this.isWCOrder ) { -// console.log('External Invoice -> ' + this.order.externalInvoice ); + // console.log('External Invoice -> ' + this.order.externalInvoice ); const b64URL:string = this.order.externalInvoice.substring(0,this.order.externalInvoice.indexOf("-")); -// console.log('encodedURL -> ' + b64URL ); - const shopURL: string = Buffer.from(b64URL, 'base64').toString(); - const tmp_orderid = this.order.externalInvoice.substring(this.order.externalInvoice.indexOf('-')+1); - const wc_order_key = tmp_orderid.substring(tmp_orderid.indexOf('-')+1); - const wc_orderid = tmp_orderid.substring(0,tmp_orderid.indexOf('-')); -// console.log('wc_order_id -> ' + wc_orderid); -// console.log('wc_order_key -> ' + wc_order_key); -// console.log('new URL -> ' + shopURL + '/checkout/order-received/' + wc_orderid + '/?key=' + wc_order_key); + // console.log('encodedURL -> ' + b64URL ); + const shopURL: string = Buffer.from(b64URL, 'base64').toString(); + const tmp_orderid = this.order.externalInvoice.substring(this.order.externalInvoice.indexOf('-')+1); + const wc_order_key = tmp_orderid.substring(tmp_orderid.indexOf('-')+1); + const wc_orderid = tmp_orderid.substring(0,tmp_orderid.indexOf('-')); + // console.log('wc_order_id -> ' + wc_orderid); + // console.log('wc_order_key -> ' + wc_order_key); + // console.log('new URL -> ' + shopURL + '/checkout/order-received/' + wc_orderid + '/?key=' + wc_order_key); if ( shopURL ) { -// console.log('Opening URL....' + shopURL); + // console.log('Opening URL....' + shopURL); window.open( shopURL + '/checkout/order-received/' + wc_orderid + '/?key=' + wc_order_key,"_blank"); } } @@ -157,119 +161,119 @@ export class InvoiceComponent implements OnInit { getIconStyle(order : Order) { if( order.paid ) - return "font-size: 14px; color: #72cc50; margin-bottom: -2px;"; + return "font-size: 14px; color: #72cc50; margin-bottom: -2px;"; return "color: #FB4F14; margin-bottom: -2px; cursor: pointer;"; } - copyAddress() { - if (!navigator.clipboard) { -// alert("Copy functionality not supported"); - this.notifierService - .showNotification( - this.vE.invoiceCopyNotavail, - this.vE.invoiceNotservClose, - 'error', - this.vE.invoiceNotservError); - } - try { - navigator.clipboard.writeText(this.order.address); - } catch (err) { - this.notifierService - .showNotification( - this.vE.invoiceCopyaddressError, - this.vE.invoiceNotservClose, - 'error', - this.vE.invoiceNotservError); -// console.error("Error", err); - } - } + copyAddress() { + if (!navigator.clipboard) { + // alert("Copy functionality not supported"); + this.notifierService + .showNotification( + this.vE.invoiceCopyNotavail, + this.vE.invoiceNotservClose, + 'error', + this.vE.invoiceNotservError); + } + try { + navigator.clipboard.writeText(this.order.address); + } catch (err) { + this.notifierService + .showNotification( + this.vE.invoiceCopyaddressError, + this.vE.invoiceNotservClose, + 'error', + this.vE.invoiceNotservError); + // console.error("Error", err); + } + } - copyAmount() { - if (!navigator.clipboard) { -// alert("Copy functionality not supported"); - this.notifierService - .showNotification( - this.vE.invoiceCopyNotavail, - this.vE.invoiceNotservClose, - 'error', - this.vE.invoiceNotservError); - } - try { - navigator.clipboard.writeText(this.order.totalZec.toString()); - } catch (err) { - this.notifierService - .showNotification( - this.vE.invoiceCopyamountError, - this.vE.invoiceNotservClose, - 'error', - this.vE.invoiceNotservError); -// console.error("Error", err); - } - } + copyAmount() { + if (!navigator.clipboard) { + // alert("Copy functionality not supported"); + this.notifierService + .showNotification( + this.vE.invoiceCopyNotavail, + this.vE.invoiceNotservClose, + 'error', + this.vE.invoiceNotservError); + } + try { + navigator.clipboard.writeText(this.order.totalZec.toString()); + } catch (err) { + this.notifierService + .showNotification( + this.vE.invoiceCopyamountError, + this.vE.invoiceNotservClose, + 'error', + this.vE.invoiceNotservError); + // console.error("Error", err); + } + } - copyMemo() { - if (!navigator.clipboard) { -// alert("Copy functionality not supported"); - this.notifierService - .showNotification( - this.vE.invoiceCopyNotavail, - this.vE.invoiceNotservClose, - 'error', - this.vE.invoiceNotservError); - } - try { - navigator.clipboard.writeText("ZGo Order::" + this.order._id); - } catch (err) { - this.notifierService - .showNotification( - this.vE.invoiceCopymemoError, - this.vE.invoiceNotservClose, - 'error', - this.vE.invoiceNotservError); -// console.error("Error", err); - } - } + copyMemo() { + if (!navigator.clipboard) { + // alert("Copy functionality not supported"); + this.notifierService + .showNotification( + this.vE.invoiceCopyNotavail, + this.vE.invoiceNotservClose, + 'error', + this.vE.invoiceNotservError); + } + try { + navigator.clipboard.writeText("ZGo Order::" + this.order._id); + } catch (err) { + this.notifierService + .showNotification( + this.vE.invoiceCopymemoError, + this.vE.invoiceNotservClose, + 'error', + this.vE.invoiceNotservError); + // console.error("Error", err); + } + } - chgUILanguage(){ - console.log('INVOICE.chgUILanguage Called '); - this.languageService.getViewElements('invoice').subscribe( - response => { - console.log('Received >> ', response ); - console.log('Language Code : ', response.language); - console.log('Component Name : ',response.component); - console.log('Language data : ',response.data); + chgUILanguage(){ + console.log('INVOICE.chgUILanguage Called '); + this.languageService.getViewElements('invoice').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.invoiceInvoiceLbl = response.data.invoice_invoice_lbl; - this.vE.invoiceOrderId = response.data.invoice_order_id; - this.vE.invoiceOrderDate = response.data.invoice_order_date; - this.vE.invoiceZcashPrice = response.data.invoice_zcash_price; - this.vE.invoiceQtyLbl = response.data.invoice_qty_lbl; - this.vE.invoiceOrderPrice = response.data.invoice_order_price; - this.vE.invoiceInvoiceTotal = response.data.invoice_invoice_total; - this.vE.invoicePaymentConfirmed = response.data.invoice_payment_confirmed; - this.vE.invoicePaymentPending = response.data.invoice_payment_pending; - this.vE.invoiceScanQrcode = response.data.invoice_scan_qrcode; - this.vE.invoiceCantScan = response.data.invoice_cant_scan; - this.vE.invoiceUseThis = response.data.invoice_use_this; - this.vE.invoiceWalletLink = response.data.invoice_wallet_link; - this.vE.invoiceDotOr = response.data.invoice_dot_or; - this.vE.invoiceCopyAddress = response.data.invoice_copy_address; - this.vE.invoiceCopyAmount = response.data.invoice_copy_amount; - this.vE.invoiceCopyMemo = response.data.invoice_copy_memo; - this.vE.invoiceReturnToshop = response.data.invoice_return_toshop; - this.vE.invoiceCopyNotavail = response.data.invoice_copy_notavail; - this.vE.invoiceNotservClose = response.data.invoice_notserv_close; - this.vE.invoiceNotservError = response.data.invoice_notserv_error; - this.vE.invoiceCopyaddressError = response.data.invoice_copyaddress_error; - this.vE.invoiceCopyamountError = response.data.invoice_copyamount_error; - this.vE.invoiceCopymemoError = response.data.invoice_copymemo_error; - this.vE.invoiceInvalidId = response.data.invoice_invalid_id; - this.vE.invoiceInfoNotavail = response.data.invoice_info_notavail; + this.vE.invoiceInvoiceLbl = response.data.invoice_invoice_lbl; + this.vE.invoiceOrderId = response.data.invoice_order_id; + this.vE.invoiceOrderDate = response.data.invoice_order_date; + this.vE.invoiceZcashPrice = response.data.invoice_zcash_price; + this.vE.invoiceQtyLbl = response.data.invoice_qty_lbl; + this.vE.invoiceOrderPrice = response.data.invoice_order_price; + this.vE.invoiceInvoiceTotal = response.data.invoice_invoice_total; + this.vE.invoicePaymentConfirmed = response.data.invoice_payment_confirmed; + this.vE.invoicePaymentPending = response.data.invoice_payment_pending; + this.vE.invoiceScanQrcode = response.data.invoice_scan_qrcode; + this.vE.invoiceCantScan = response.data.invoice_cant_scan; + this.vE.invoiceUseThis = response.data.invoice_use_this; + this.vE.invoiceWalletLink = response.data.invoice_wallet_link; + this.vE.invoiceDotOr = response.data.invoice_dot_or; + this.vE.invoiceCopyAddress = response.data.invoice_copy_address; + this.vE.invoiceCopyAmount = response.data.invoice_copy_amount; + this.vE.invoiceCopyMemo = response.data.invoice_copy_memo; + this.vE.invoiceReturnToshop = response.data.invoice_return_toshop; + this.vE.invoiceCopyNotavail = response.data.invoice_copy_notavail; + this.vE.invoiceNotservClose = response.data.invoice_notserv_close; + this.vE.invoiceNotservError = response.data.invoice_notserv_error; + this.vE.invoiceCopyaddressError = response.data.invoice_copyaddress_error; + this.vE.invoiceCopyamountError = response.data.invoice_copyamount_error; + this.vE.invoiceCopymemoError = response.data.invoice_copymemo_error; + this.vE.invoiceInvalidId = response.data.invoice_invalid_id; + this.vE.invoiceInfoNotavail = response.data.invoice_info_notavail; - }, - error => { console.log('Error >> ',error); } - ); - } + }, + error => { console.log('Error >> ',error); } + ); + } }