SFCC Cartridge
...
Post-Auth Credit Card
Controllers
2 min
controllers post auth integration overview the fortervalidate controller is implemented with your payment gateway in the sample implementations, you can see the mapping for cybersource and authorize net you will need to customize the logic to fit your specific payment processor and gateway controllers code below is code from the authorize net controller which is triggered as part of the generic site genesis authorization flow you will need to map the authorization response within your payment gateway's controller to the forterorder ds which can be found via the path cartridges > int forter > cartridge > scripts > lib > forter > dto > forterorder ds note that the below code references the authorize net controller within the site genesis authorization flow and additional customizations should be made to your gateway controller based on the data you receive from your payment gateway (i e cybersource, adyen, braintree, paymenttech etc ) sample controllers code (authorize net) function authorize(args) { if (empty(session forms billing paymentmethods selectedpaymentmethodid value)) { return {error true}; } var orderno = args orderno, paymentinstrument = args paymentinstrument, paymentprocessor = paymentmgr getpaymentmethod(paymentinstrument getpaymentmethod()) getpaymentprocessor(); transaction wrap(function () { paymentinstrument paymenttransaction transactionid = orderno; paymentinstrument paymenttransaction paymentprocessor = paymentprocessor; }); var argccauth = { order args order, paymentinstrument paymentinstrument }, authresponse = doauth(argccauth); if (authresponse result == false) { var argordervalidate = { order args order, ordervalidateattemptinput 1 }, fortercontroller = require('int forter/cartridge/controllers/fortervalidate'), forterdecision = fortercontroller validateorder(argordervalidate); // in case if no response from forter, try to call one more time if (forterdecision result === false && forterdecision ordervalidateattemptinput == 2) { var argordervalidate = { order args order, ordervalidateattemptinput 2 }, fortercontroller = require('int forter/cartridge/controllers/fortervalidate'), forterdecision = fortercontroller validateorder(argordervalidate); } if (!empty(forterdecision placeordererror)) { return {error true, fortererrorcode forterdecision placeordererror}; } else { return {error true}; } return {error true}; } if (authresponse result == true) { var argordervalidate = { order args order, ordervalidateattemptinput 1 }, fortercontroller = require('int forter/cartridge/controllers/fortervalidate'), forterdecision = fortercontroller validateorder(argordervalidate); // in case if no response from forter, try to call one more time if (forterdecision result === false && forterdecision ordervalidateattemptinput == 2) { var argordervalidate = { order args order, ordervalidateattemptinput 2 }, fortercontroller = require('int forter/cartridge/controllers/fortervalidate'), forterdecision = fortercontroller validateorder(argordervalidate); } if (forterdecision jsonresponseoutput processoraction === 'skipcapture' || forterdecision jsonresponseoutput processoraction === 'notreviewed') { return {authorized true}; } else if (forterdecision jsonresponseoutput processoraction === 'disabled' || forterdecision jsonresponseoutput processoraction === 'internalerror' || forterdecision jsonresponseoutput processoraction === 'capture') { var argcccapture = { authorizenetresponse authresponse authorizenetresponse, order args order, paymentinstrument paymentinstrument }, captureresponse = docapture(argcccapture); if (captureresponse result == true) { return {authorized true}; } if (captureresponse result == false) { var argvoid = { authorizenetresponse authresponse authorizenetresponse, order args order, paymentinstrument paymentinstrument }, voidresponse = dovoid(argvoid); if (!empty(forterdecision placeordererror)) { return {error true, fortererrorcode forterdecision placeordererror}; } else { return {error true}; } } } else { var argvoid = { authorizenetresponse authresponse authorizenetresponse, order args order, paymentinstrument paymentinstrument }, voidresponse = dovoid(argvoid); if (!empty(forterdecision placeordererror)) { return {error true, fortererrorcode forterdecision placeordererror}; } else { return {error true}; } } } } function doauth(argccauth) { var authorizenetccauthrequest = require(' /cartridge/scripts/pipelets/authorizenetccauthrequest'), authresponse = authorizenetccauthrequest execute(argccauth); return authresponse; } function docapture(argcccapture) { var authorizenetcccapturerequest = require(' /cartridge/scripts/pipelets/authorizenetcccapturerequest'), captureresponse = authorizenetcccapturerequest execute(argcccapture); return captureresponse; } function dovoid(argvoid) { var authorizenetvoidrequest = require(' /cartridge/scripts/pipelets/authorizenetvoidrequest'), voidresponse = authorizenetvoidrequest execute(argvoid); return voidresponse; } //this is within the forterorder ds file response not stored on payment instrument if your implementation does not store the response on the payment instrument, you can pass the response object from your payment processor to the validateorder() function by using the fortervalidate js controller the path to the fortervalidate js controller is cartridges > int forter > cartridge > controllers > fortervalidate js when the fortervalidate js controller is used as an input, it is sent as a parameter to the forterorder ds file to generate the request object