@@ -9,7 +9,7 @@ const { createEnvelopeWithPayment } = require('../examples/collectPayment');
99const validator = require ( 'validator' ) ;
1010const { getExampleByNumber } = require ( "../../manifestService" ) ;
1111const dsConfig = require ( '../../../config/index.js' ) . config ;
12- const { formatString } = require ( '../../utils.js' ) ;
12+ const { formatString, isCFR } = require ( '../../utils.js' ) ;
1313
1414const eg014CollectPayment = exports ;
1515const exampleNumber = 14 ;
@@ -85,7 +85,7 @@ eg014CollectPayment.createController = async (req, res) => {
8585/**
8686 * Form page for this application
8787 */
88- eg014CollectPayment . getController = ( req , res ) => {
88+ eg014CollectPayment . getController = async ( req , res ) => {
8989 // Check that the authentication token is ok with a long buffer time.
9090 // If needed, now is the best time to ask the user to authenticate
9191 // since they have not yet entered any information into the form.
@@ -96,15 +96,26 @@ eg014CollectPayment.getController = (req, res) => {
9696 return res . redirect ( mustAuthenticate ) ;
9797 }
9898
99+ let enableCFR = await isCFR ( req . user . accessToken , req . session . accountId , req . session . basePath ) ;
100+ if ( enableCFR == "enabled" ) {
101+ res . locals . statusCFR = "enabled" ;
102+ }
103+
99104 const example = getExampleByNumber ( res . locals . manifest , exampleNumber ) ;
100105 const sourceFile = ( path . basename ( __filename ) ) [ 5 ] . toLowerCase ( ) + ( path . basename ( __filename ) ) . substr ( 6 ) ;
101- res . render ( 'pages/examples/eg014CollectPayment' , {
102- eg : eg , csrfToken : req . csrfToken ( ) ,
103- example : example ,
104- gatewayOk : dsConfig . gatewayAccountId && dsConfig . gatewayAccountId . length > 25 ,
105- sourceFile : sourceFile ,
106- sourceUrl : dsConfig . githubExampleUrl + 'eSignature/examples/' + sourceFile ,
107- documentation : dsConfig . documentation + eg ,
108- showDoc : dsConfig . documentation
109- } ) ;
106+ if ( res . locals . statusCFR == "enabled" ) {
107+ res . render ( 'pages/invalid_with_cfr' , {
108+ title : "Not CFR Part 11 compatible"
109+ } ) ;
110+ } else {
111+ res . render ( 'pages/examples/eg014CollectPayment' , {
112+ eg : eg , csrfToken : req . csrfToken ( ) ,
113+ example : example ,
114+ gatewayOk : dsConfig . gatewayAccountId && dsConfig . gatewayAccountId . length > 25 ,
115+ sourceFile : sourceFile ,
116+ sourceUrl : dsConfig . githubExampleUrl + 'eSignature/examples/' + sourceFile ,
117+ documentation : dsConfig . documentation + eg ,
118+ showDoc : dsConfig . documentation
119+ } ) ;
120+ }
110121}
0 commit comments