/**
  * This function sends auth data to the EndPointUrl OpenPayU
  * @access public
  * @param string $doc
  * @param integer $merchantPosId
  * @param string $signatureKey
  * @param string $algorithm
  * @return string $response
  */
 public static function sendOpenPayuDocumentAuth($doc, $merchantPosId, $signatureKey, $algorithm = 'MD5')
 {
     if (empty(OpenPayUNetwork::$openPayuEndPointUrl)) {
         throw new Exception('OpenPayUNetwork::$openPayuEndPointUrl is empty');
     }
     if (empty($signatureKey)) {
         throw new Exception('Merchant Signature Key should not be null or empty.');
     }
     if (empty($merchantPosId)) {
         throw new Exception('MerchantPosId should not be null or empty.');
     }
     $tosigndata = $doc . $signatureKey;
     $xml = urlencode($doc);
     $signature = '';
     if ($algorithm == 'MD5') {
         $signature = md5($tosigndata);
     } else {
         if ($algorithm == 'SHA') {
             $signature = sha1($tosigndata);
         } else {
             if ($algorithm == 'SHA-256' || $algorithm == 'SHA256' || $algorithm == 'SHA_256') {
                 $signature = hash('sha256', $tosigndata);
             }
         }
     }
     $authData = 'sender=' . $merchantPosId . ';signature=' . $signature . ';algorithm=' . $algorithm . ';content=DOCUMENT';
     $response = '';
     if (OpenPayUNetwork::isCurlInstalled()) {
         $response = OpenPayU::sendDataAuth(OpenPayUNetwork::$openPayuEndPointUrl, 'DOCUMENT=' . $xml, $authData);
     } else {
         throw new Exception('curl is not available');
     }
     return $response;
 }