Encryption

This type of encryption only applies if you are using direct card charge.

When using our direct card charge API to charge a card directly, you will need to encrypt the payload containing the card details before making the request.

If you are using one of our backend SDKs , you do not need to worry about encryption. Pass your encryption key to the library, and it will automatically encrypt the payload before sending.

To encrypt the payload manually, you will need your encryption key (from the Settings > API section of your dashboard). You will use the 3DES algorithm to encrypt the payload.

Here is an example of an encryption function in different languages. In each case, the function takes the payload as a hash, converts it to JSON, encrypts it and encodes it in base64:

function encrypt(encryptionKey, payload) {
  const text = JSON.stringify(payload);
  const forge = require("node-forge");
  const cipher = forge.cipher.createCipher(
    "3DES-ECB",
    forge.util.createBuffer(encryptionKey)
  );
  cipher.start({iv: ""});
  cipher.update(forge.util.createBuffer(text, "utf-8"));
  cipher.finish();
  const encrypted = cipher.output;
  return forge.util.encode64(encrypted.getBytes());
}

Did you find this page helpful?