API Integration Guide
Rewards integration
Flow
Detailed Step
{
"response_code": 1,
"response_message": "Insufficient balance in card account",
"payload": "Insufficient balance in card account"
}
APIs
API | Function |
---|---|
Get Card Account Details | This API is used for fetching a particular card account details. Like balance, account id |
Create And Allocate point | This API is used to create a reward card along with allocating points to the employee, as well as, it can be used to re-allocate points to an existing reward card user. |
SSO LOGIN | This API facilitates the generation of a sign-in token for reward card holders. This token allows users to bypass the usual login and OTP verification steps, enabling them to directly access the EnKash Redeem Rewards Page. |
Get Transaction details | This API is used for fetching a List of transaction details and fetch the status of transaction |
Search Enkash Card | This API is used for fetching a card details of a user |
Bulk Create Card / Allocate Points | This is used to create users and allocate reward points as well to the users in BULK |
How to integrate the SSO with Enkash?
1.
2.
URL - https://invoice-uat.enkash.in/sso/{access_token}/employee_rewards/{partner}
{access_token) - represents the token which has been generated by the partner for a user.
{partner} - The integrating partner name (Eg - HRMS)
Example URL : https://invoice-uat.enkash.in/sso/aF5V6hPScEd9mCowJmbZFKk5Xg/employee_rewards/hrms
This URL will redirect the user to Enkash Rewards Platform .
3.
URL - https://invoice-uat.enkash.in/sso/{access_token}/reward_account/{partner}
For HR admin also, kindly pass the enkash card ID for HR / company admin which is generated upon client onboarding
4.
HTTP CODES
Code | Message | Description |
---|---|---|
200 | Success | The API has been successfully executed |
400 | BAD_REQUEST | Indicates the request is invalid or a mandatory parameter must have been missing. |
422 | UNPROCESSABLE_ENTITY | Indicates that the api couldn't be processed given the request conditions. |
404 | NOT_FOUND | Indicates somewhere in the code, API couldn’t fetch the required entity from the database. (returned null) |
500 | Internal Server Error | Indicates an error occurred on Enkash Server |
Encryption of Request
Make an encryption class and follow the below steps.
Import the required libraries in Java:
import java.security.MessageDigest;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;
Create an Encryption Function:
try {
if (CommonUtil.isEmpty(strToEncrypt))
return "";
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
} catch (Exception e) {
LOGGER.error("Error while encrypting: " + e.getMessage());
}
return null;
}
Generate a SecretKeySpec
byte[] key = secretKey.getBytes(StandardCharsets.UTF_8);
MessageDigest sha = MessageDigest.getInstance("SHA-256");
key = sha.digest(key);
key = Arrays.copyOf(key, 16); // Use only the first 128 bits for AES-128
return new SecretKeySpec(key, "AES");
}
Call the encrypt function to get the encrypted data
String secretKey = "YourSecretKey123";
Now pass the above encryptedData in the API request, It will return an encrypted Response. To Decrypt the response, make a method for decrypt logic like this:-
try {
if (CommonUtil.isEmpty(strToDecrypt))
return "";
SecretKeySpec secretKeySpec = getKeySpec(secret);
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
return new String(cipher.doFinal(Base64.getDecoder().decode(strToDecrypt)));
LOGGER.error("Error while decrypting: " + e.getMessage());
}
return null;
}
To get the decrypted response, execute the below operation.
String secretKey = "YourSecretKey123";
Modified at 2025-01-08 08:01:04