The following guide explain how integrate Cardinal Consumer Authentication in your site, in the other hand we have an interactive tutorial to generate the javascript code necessary for the integration.

Cardinal Commerce Integration Wizard

In order to generate a valid Consumer Authentication Token you need create firstly a JWT to sign in Cardinal Commerce and start the Consumer Authentication process.

In order to generate a new JWT for cardinal must send a mutation like:

mutation ($amount: Int!, $orderNumber: String!) {
    consumerAuthentication {
        cardinalJWT(amount: $amount, orderNumber: $orderNumber)
    }
}
{
  "amount": 4000,
  "orderNumber": "12345"
}
{
  "data": {
    "consumerAuthentication": {
      "cardinalJWT": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI0MEU2REY2RS0xQkM2LTRCQzAtQUYzMC02MDdEOTFGQUU0MkEiLCJpYXQiOjE1NDgwMTk2MjgsImlzcyI6IjU4MmUwYTIwMzNmYWRkMTI2MGY5OTBmNiIsIk9yZ1VuaXRJZCI6IjU4MmJlOWRlZGE1MjkzMmE5NDZjNDVjNCIsIlBheWxvYWQiOnsiT3JkZXJEZXRhaWxzIjp7Ik9yZGVyTnVtYmVyIjoiMTIzNDUiLCJBbW91bnQiOjQwNTUsIkN1cnJlbmN5Q29kZSI6Ijg0MCJ9fX0.BAirSo33noMJBVWu7RErD3qQC9nwf8Ac7GLXAzp3sMw"
    }
  }
}
  • amount: is the order amount in cents to charge to the customer, including all fees and discounts.
  • orderNumber: unique client side order number, can use a timestamp or your order number for cross reference.

Once you have the JWT you must setup Cardinal Cruise using the following guide.

Example of Cardinal JWT setup:


Cardinal.setup("init", {
    jwt: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI0...."
});

Once your payment has been completed you must have a valid Consumer Authorization Token to send inside credit card payment information using the field consumerAuthToken.

Example of cardinal payments validated:

Cardinal.on("payments.validated", function (data, jwt) {
    switch(data.ActionCode){
      case "SUCCESS":
      // Handle successful transaction, send jwt inside `consumerAuthToken` with your payment
      break;
     
      case "NOACTION":
      // Handle no actionable outcome
      break;
     
      case "FAILURE":
      // Handle failed transaction attempt
      break;
     
      case "ERROR":
      // Handle service level error
      break;
  }
});

A full valid Consumer Authorization Token must looks like:

eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI1YzgxN2M1YTc5MWVlZjMxZTgxNGU2NmYiLCJpYXQiO
jE1NjAyODA0MDQsImV4cCI6MTU2MDI4NzYwNCwianRpIjoiNWMwNjQzNWQtYTcyOS00ZjMzLWI
xNWItNzg2YzIwN2NhZGZmIiwiQ29uc3VtZXJTZXNzaW9uSWQiOiIwXzVmMzZmMTEwLWFmYmYtND
BmNy05ZDUyLTBkZTZlNWMyZDQ1NiIsIlJlZmVyZW5jZUlkIjoiMF81ZjM2ZjExMC1hZmJmLTQwZj
ctOWQ1Mi0wZGU2ZTVjMmQ0NTYiLCJhdWQiOiI1YjQyMzI4MC0zYzM1LTQ2MmQtYTA2OS0zN2Q5ZT
Q5YjM1MzEiLCJQYXlsb2FkIjp7IlZhbGlkYXRlZCI6dHJ1ZSwiUGF5bWVudCI6eyJUeXBlIjoiQ
0NBIiwiUHJvY2Vzc29yVHJhbnNhY3Rpb25JZCI6IllqRk93eldPeXA3VHA2cFhES3cwIiwiRXh0Z
W5kZWREYXRhIjp7IkNBVlYiOiJoaVVSbmpJUFdpUWtDQUVBQUNWcEFBTUFBQUFcdTAwM2QiLCJFQ
0lGbGFnIjoiMDEiLCJYSUQiOiJXV3BHVDNkNlYwOTVjRGRVY0Rad1dFUkxkekFcdTAwM2QiLCJVQ
0FGSW5kaWNhdG9yIjoiMSIsIkVucm9sbGVkIjoiWSIsIlBBUmVzU3RhdHVzIjoiQSIsIlNpZ25hd
HVyZVZlcmlmaWNhdGlvbiI6IlkifX0sIkFjdGlvbkNvZGUiOiJTVUNDRVNTIiwiRXJyb3JOdW1iZ
XIiOjAsIkVycm9yRGVzY3JpcHRpb24iOiJTdWNjZXNzIn19.znJxSttVTSXxNwl3z_sS4rqfBZxg
T3l3Gceqnl1TNq0

Decoded token payload:

{
  "iss": "5c817c5a791eef31e814e66f",
  "iat": 1560280404,
  "exp": 1560287604,
  "jti": "5c06435d-a729-4f33-b15b-786c207cadff",
  "ConsumerSessionId": "0_5f36f110-afbf-40f7-9d52-0de6e5c2d456",
  "ReferenceId": "0_5f36f110-afbf-40f7-9d52-0de6e5c2d456",
  "aud": "5b423280-3c35-462d-a069-37d9e49b3531",
  "Payload": {
    "Validated": true,
    "Payment": {
      "Type": "CCA",
      "ProcessorTransactionId": "YjFOwzWOyp7Tp6pXDKw0",
      "ExtendedData": {
        "CAVV": "hiURnjIPWiQkCAEAACVpAAMAAAA=",
        "ECIFlag": "01",
        "XID": "WWpGT3d6V095cDdUcDZwWERLdzA=",
        "UCAFIndicator": "1",
        "Enrolled": "Y",
        "PAResStatus": "A",
        "SignatureVerification": "Y"
      }
    },
    "ActionCode": "SUCCESS",
    "ErrorNumber": 0,
    "ErrorDescription": "Success"
  }
}

In case the consumer authentication fails or customer is not enrolled in 3D secure can use the Credit Card Verification as security step to verify the payment method. The store may need a verified credit card using 3D secure or another method to accept payments.