Php Hash()函数在wordpress模板中不起作用
我正在尝试添加支付网关,但无法哈希字符串Php Hash()函数在wordpress模板中不起作用,php,wordpress,Php,Wordpress,我正在尝试添加支付网关,但无法哈希字符串 <?php /** * Template Name: Payment * * @link https://codex.wordpress.org/Template_Hierarchy * * @package Mitech * @since 1.0 */ get_header(); ?> <?php $email = $_GET['email']; $Price = $_GET['asdcsa']; /
<?php
/**
* Template Name: Payment
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package Mitech
* @since 1.0
*/
get_header();
?>
<?php
$email = $_GET['email'];
$Price = $_GET['asdcsa'];
// How to calculate request signature.
$shaString = '';
// array request
$arrData = array(
'command' =>'AUTHORIZATION',
'access_code' => 'WboNsNukQq6CpM5sFTb6',
'merchant_identifier' => 'oZCzyQtx',
'merchant_reference' => 'XYZ9239-yu898',
'amount' =>'10000',
'currency' =>'AED',
'language' =>'en',
'customer_email' =>'test@payfort.com',
'order_description' =>'iPhone 6-S',
);
// sort an array by key
ksort($arrData);
foreach ($arrData as $key => $value) {
$shaString .= "$key=$value";
}
// make sure to fill your sha request pass phrase.
$shaString = "$2y$10$XPu7h2ekY" . $shaString . "$2y$10$XPu7h2ekY";
$signature = hash("SHA-256", $shaString);
echo $signature;
使用“而不是”,否则它将尝试将字符串解析为变量,如
$shaString='$2y$10$XPu7h2ekY.$shaString'$2y$10$XPu7h2ekY';
此外,hash()
方法的正确参数是“sha256”
,而不是我在文档中看到的SHA-256
编辑:
此外,为了避免重复错误并使代码更具可读性,我建议为'$2y$10$XPu7h2ekY'