3-D Secure Module

❗️

Use of this module is now deprecated, and new integrations should use the Post-Response Action module.

This module automates the handling of 3-D Secure additional actions, as part of the [3-D Secure Payment Flow].

Add the 3-D Secure Module to your App

After you have set up the Comcarde JavaScript Client, you can add a three-d-secure module to your website source.

<script src="https://sandbox-assets.comcarde.com/web/v2/js/three-d-secure.min.js"></script>
<script src="https://assets.comcarde.com/web/v2/js/three-d-secure.min.js"></script>

Finally, add the module to your Comcarde JavaScript Client:

comcarde.client.create(
  {
    authorization: client - api - key, // your client API Key
  },
  function (clientErr, clientInstance) {
    // optionally configure other plugin modules...

    /*
     * Create a 3-D Secure Plugin Module Component.
     */
    comcarde.threeDSecure.create(
      {
        client: clientInstance,
      },
      function (err, threeDSecureInstance) {
        if (err) {
          console.log(err)
          return
        }

        var serverResponse // the full 2001 response received on your server

        threeDSecureInstance
          .threeDSecureChallenge(serverResponse)
          .then(function (response) {
            var message = response.message // text explanation of the outcome
            var paymentId = response.paymentId // unique id of the payment

            if (response.code === '2002') {
              // can be used to progress the payment via your server
              var nonce = response.nonce

              // Optional additional information to help you make an informed decision
              // whether to proceed with the payment
              if (response.threeDSecureInfo) {
                // status description returned by the PSP
                var pspStatus = response.threeDSecureInfo.pspStatus

                // e.g. "2"
                var threeDSecureVersion =
                  response.threeDSecureInfo.threeDSecureVersion

                if (response.threeDSecureInfo.liabilityShifted) {
                  /*
                   * 3-D Secure worked and authentication succeeded.
                   *
                   * This will also be true if the issuing bank does not support 3-D
                   * Secure, but the payment method does. In both cases, the liability
                   * for fraud has been shifted to the bank. You can now finalise the
                   * payment using response.nonce on your server.
                   */
                } else {
                  /*
                   * 3-D Secure authentication failed. It is still possible to finalise
                   * the payment using the payment.nonce via your server, but you will
                   * need to set 3-D secure required flag to false.
                   */

                  if (response.threeDSecureInfo.liabilityShiftPossible) {
                    // the payment instrument was eligible for 3-D Secure
                  } else {
                    // the payment instrument was not eligible for 3-D secure.
                  }
                }
              }
            } else if (response.code === 2004) {
              // an error occurred when attempting 3-D Secure authentication.
              // See response.message
            }
          })
          .catch(function (err) {
            console.log(
              'threeDSecureChallenge failed. err: ' + JSON.stringify(err)
            )
          })
      }
    )
  }
)