Radial JavaScript 3D Secure Helper Utilities
Introduction
In addition to 3D Secure and Tokenization, Radial hosted paymentsJavaScript provides two "helper" utilities to facilitate your integration:
-
Data Encryption, which enables you to encrypt payment data
-
Luhn Check, which validates credit card formats
The following sections describe these utilities and explain how to implement them for both iframe and non-iframe solutions.
Data Encryption Methods
Radial hosted payments Javascript provides utilities functions like encryption that can be used to encrypt data before sending it to the server; for example, encrypt payment information before sending it to the server. Radial decrypts the payment information to process further payment flows.
To use this encryption function, you must follow the prerequisite steps to initialize the Radial Object.
Encryption without Radial iframe
To encrypt a card number or any other value without using an iframe, use the following method.
Method
radial.getEncryptedNumber(anyString, jwt);
Parameters
-
anyNumber: The value you want to encrypt.
-
jwt (Optional): If not provided, the JWT present in the initialization. Used if previous authentication Token is not expired.
Response
The response contains an object with the encrypted value.
Success Response
{
"encryptedValue": "dJeTiNhXaiEUnMKRHxb9t9f4ZW5wx46qzZrikldGjYscHDYpPxWC3xBHfEtTm0Nk07cNpQ9NDSoFsTQEF0Ej4H1wj/7TJbln9fEZZsTeHASodTY9oGGVuLbI94stkXKG8W"
}
Failure Response
This response occurs if the JWT is expired.
{
"errorCode": "40001",
"errorMessage": "Invalid Authentication Error",
"errorDescription": "Provided JWT is either invalid or expired"
}
Encryption with Radial iframe
When using an Radial iframe, Radial JS fetches encrypted data from Radial Secure fields the contain end-user entered data, such as payment information. While using this secure forms, you can specify whether you are using savedWallet or asking the user to enter new payment data. Based on this choice, the response varies. See how to implement secure forms here before using this for data encryption.
Method
radial.getEncryptedPaymentData(isSavedWallet);
Parameter
isSavedWallet
-
true if you are saving a wallet (returns only the encrypted security code).
-
false if you are not saving a wallet (returns both the encrypted card number and the encrypted security code).
Responses
If true (Saving Wallet)
{
"success": true,
"cardDetails": {
"encryptedCardNumber": "7KNefgC+JdAgNHnJTgzhgMJ8=",
"encryptedSecurityCode": "o3KuKPRcTdiow2ecJKTxOqbU="
},
"tenderType": "VC"
}
If false (Not Saving Wallet):
{
"success": false,
"cardDetails": {
"encryptedSecurityCode": "EKVqjknq7HZM8nPO7XjJpC+c="
}
}
Failure Scenario
If an error occurs, the method passes success false.
{
"success": false,
"cardDetails": {}
}
Luhn Check
The Luhn algorithm performs a basic validation of credit card numbers. Note: The Luhn check is not used for card validation; rather, it ensures that card numbers meet the standard. To perform a Luhn check, use the following method.
Note: Be sure to complete the prerequisites for JS initialization.
Method
radial.isLuhnCheckValid(creditCardNumber);
Parameter
creditCardNumber: The card number you want to validate.
Response
-
Valid Card Number: Returns true
-
Invalid Card Number: Returns false