@@ -56,6 +56,7 @@ module.exports = baseVw.extend({
5656 'click .js-buyWizardCloseSummary' : 'closeWizard' ,
5757 'click input[name="radioPaymentType"]' : 'changePaymentType' ,
5858 'blur .js-buyWizardPostalInput' : 'updateMap' ,
59+ 'click #BuyWizardQRDetailsInput' : 'toggleQRDetails' ,
5960 'blur input' : 'validateInput'
6061 } ,
6162
@@ -73,6 +74,7 @@ module.exports = baseVw.extend({
7374 this . orderID = "" ;
7475 this . model . set ( 'selectedModerator' , "" ) ;
7576 this . model . updateAttributes ( ) ;
77+ this . cachePayData = "" ;
7678
7779 //create the country select list
7880 this . countryList = countries . get ( 'countries' ) ;
@@ -197,6 +199,9 @@ module.exports = baseVw.extend({
197199 $ ( ".js-BuyWizardWallets" ) . randomize ( ) ;
198200 }
199201
202+ //set the QR details checkbox
203+ var QRtoggleVal = localStorage . getItem ( 'AdditionalPaymentData' ) != "false" ? true : false ;
204+ self . $ ( '#BuyWizardQRDetailsInput' ) . prop ( 'checked' , QRtoggleVal ) ;
200205 } ) ;
201206 return this ;
202207 } ,
@@ -485,6 +490,7 @@ module.exports = baseVw.extend({
485490 success : function ( data ) {
486491 if ( data . success == true ) {
487492 self . showPayAddress ( data ) ;
493+ self . cachePayData = data ; //cache the data for the QR Details toggle
488494 } else {
489495 messageModal . show ( window . polyglot . t ( 'errorMessages.contractError' ) , window . polyglot . t ( 'errorMessages.sellerError' ) + " " +
490496 window . polyglot . t ( 'errorMessages.checkPurchaseData' ) + "\n\n Reason: " + data . reason ) ;
@@ -499,8 +505,21 @@ module.exports = baseVw.extend({
499505 } ) ;
500506 } ,
501507
508+ toggleQRDetails : function ( ) {
509+ var toggleInput = this . $ ( '#BuyWizardQRDetailsInput' ) ,
510+ toggleVal = toggleInput . prop ( 'checked' ) ;
511+ localStorage . setItem ( 'AdditionalPaymentData' , toggleVal ) ;
512+ this . showPayAddress ( ) ;
513+ } ,
514+
502515 showPayAddress : function ( data ) {
503- "use strict" ;
516+ data = data || this . cachePayData ;
517+
518+ if ( ! data ) {
519+ throw new Error ( 'Data must be provided to the showPayAddress function' ) ;
520+ return ;
521+ }
522+
504523 var totalBTCPrice = 0 ,
505524 storeName = encodeURI ( this . model . get ( 'page' ) . profile . name ) ,
506525 message = encodeURI ( this . model . get ( 'vendor_offer' ) . listing . item . title . substring ( 0 , 20 ) + " " + data . order_id ) ,
@@ -515,7 +534,7 @@ module.exports = baseVw.extend({
515534 payHREF = "bitcoin://" + data . payment_address + "?amount=" + totalBTCPrice ;
516535 if ( localStorage . getItem ( 'AdditionalPaymentData' ) != "false" ) {
517536 payHREF += "&label=" + storeName + "&message=" + message ;
518- }
537+ }
519538
520539 this . hideMaps ( ) ;
521540 this . $el . find ( '.js-buyWizardPay' ) . removeClass ( 'hide' ) ;
0 commit comments