예제 #1
0
        $params = self::_underscoreKeys($params);
        $now = new DateTime('now', new DateTimeZone('UTC'));
        $trDataParams = array_merge($params, array('api_version' => Braintree_Configuration::API_VERSION, 'public_key' => Braintree_Configuration::publicKey(), 'time' => $now->format('YmdHis')));
        ksort($trDataParams);
        $trDataSegment = http_build_query($trDataParams, null, '&');
        $trDataHash = self::_hash($trDataSegment);
        return "{$trDataHash}|{$trDataSegment}";
    }
    private static function _underscoreKeys($array)
    {
        foreach ($array as $key => $value) {
            $newKey = Braintree_Util::camelCaseToDelimiter($key, '_');
            unset($array[$key]);
            if (is_array($value)) {
                $array[$newKey] = self::_underscoreKeys($value);
            } else {
                $array[$newKey] = $value;
            }
        }
        return $array;
    }
    /**
     * @ignore
     */
    private static function _hash($string)
    {
        return Braintree_Digest::hexDigest($string);
    }
}
Braintree_TransparentRedirect::init();