In order to generate the Order Token and initialize a new order from Arrow you need to call the init API by following these steps

These are the instructions for setting up Arrow Checkout on a server.

Requirement : - PHP with openssl or Node.js

  1. Get the JSON data from client or the server, note that using the server is more secure.

  2. Add the arrowEncrypt function to your Javascript/PHP script as follows:

function arrowEncrypt($data, $key)
    {
        $method = 'AES-256-CBC';
        $length = openssl_cipher_iv_length($method);
        $iv = openssl_random_pseudo_bytes($length);
        $encrypted = openssl_encrypt($data, $method, $key, OPENSSL_RAW_DATA, $iv);
        if ($encrypted) {
            return base64_encode($encrypted) . '|' . base64_encode($iv);
        } else {
            return false;
        }
    };
    $json = <<<EOT
  {
           //your new order data including all passign parameters as mentioned in "Passing Information" docs
        }

EOT;
    $data = arrowEncrypt($json,"YOUR_ENCRYPTION_KEY");
 echo $data
var CryptoJS = require("crypto-js");
const {Base64} = require('js-base64');
var arrowBase64 = {


    // public method for encoding
    encode: function (input)
    {
        Base64.extendString();
        return input.toBase64();
    } // End Function encode


    // public method for decoding
    ,decode: function (input)
    {
        Base64.extendString();
        return input.fromBase64();
    } // End Function decode

}
function makeid(length) {
    var result           = '';
    var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    var charactersLength = characters.length;
    for ( var i = 0; i < length; i++ ) {
      result += characters.charAt(Math.floor(Math.random() * 
 charactersLength));
   }
   return result;
}
function utf8ToHex(str) {
    return Array.from(str).map(c =>
        c.charCodeAt(0) < 128 ? c.charCodeAt(0).toString(16) :
        encodeURIComponent(c).replace(/\%/g, '').toLowerCase()
    ).join('');
}
var arrowEncryptionKey = "YOUR_ENCRYPTION_KEY";
var json = {
    //your new order data including all passign parameters as mentioned in "Passing Information" docs
              }

function aesEncrypt(data) {
    var key = CryptoJS.enc.Utf8.parse(arrowEncryptionKey); //secret key
    var random = makeid(16);
    var iv = CryptoJS.enc.Utf8.parse(random);

    var encrypted = CryptoJS.AES.encrypt(data, key, { iv: iv });
    return utf8ToHex(encrypted.toString() + "|" + arrowBase64.encode(random));
}

var b64 = arrowBase64.encode(JSON.stringify(json));
var encrypted_data = aesEncrypt(b64);
console.log(encrypted_data)