示例#1
0
 /**
  * 
  * @param Object $order the order to be sent in a transaction request
  * @param string $merchantId the identifier of merchant
  * @param string $key authentication key
  * @param string $algorithm the to use
  * @throws IllegalArgumentException
  * @return the signature built
  */
 static function buildSignature($order, $merchantId, $key, $algorithm)
 {
     $message = SignatureUtil::buildMessage($order, $merchantId, $key);
     if (SignatureUtil::MD5_ALGORITHM == $algorithm) {
         return md5($message);
     } else {
         if (SignatureUtil::SHA_ALGORITHM == $algorithm) {
             return sha1($message);
         } else {
             throw new InvalidArgumentException("Could not create signature. Invalid algoritm");
         }
     }
 }