乌鸦支付交易状态中的“缺少哈希字段”

时间:2018-06-20 10:00:02

标签: transactions payment-gateway

我们遵循了本文档http://www.corvuspay.hr/download/CorvusPay-Integration-and-Message-Protocol.pdf的交易状态[第33页]

我们需要获取具有交易状态的卡信息。但是我们无法得到它。我们发现以下错误消息:

<?xml version="1.0" encoding="UTF-8"?>
<errors>
  <msg>Missing hash field</msg>
  <code>1802</code>
</errors>

这是我们的代码:

$url = "https://testcps.corvus.hr/status";
$cert_file = 'Corvus.crt.pem';
$key_file = 'Corvus.key.pem';
$cert_password = 'PASSWORD_HERE';
$store_id = '5519';
$order_number = 'ORDER_NUMBER_HERE';
$account_id = '627100';
$secret_key = 'SECREAT_CODE_REPLACE_HERE';
$currency_code = 191;
$timestamp = date('YmdHis');
$hash = sha1($secret_key . $order_number . $store_id . $currency_code . $timestamp);
$post_params = array(
    'store_id' => urlencode($store_id),
    'order_number' => urlencode($order_number),
    'account_id' => urlencode($account_id),
    'currency_code' => $currency_code,
    'timestamp' => $timestamp,
    'hash' => urlencode($hash),
);
$post_params_string = '';
foreach ($post_params as $key => $value) {
    $post_params_string .= $key . '=' . $value . '&';
}
rtrim($post_params_string, '&');
$ch = curl_init();
$options = array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_SSL_VERIFYHOST => false,
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_POST => 1,
    CURLOPT_POSTFIELDS => $post_params,
    CURLOPT_URL => $url,
    CURLOPT_SSLCERT => $cert_file,
    CURLOPT_SSLKEY => $key_file,
    CURLOPT_SSLCERTPASSWD => $cert_password,
    CURLOPT_HTTPHEADER => "Content-Type: application/x-www-form-urlencoded",
);
curl_setopt_array($ch, $options);
$output = curl_exec($ch);
if (!$output) {
    echo "Curl Error : " . curl_error($ch);
} else {
    echo '<pre>' . htmlentities($output) . '</pre>';
}

请帮助我们

1 个答案:

答案 0 :(得分:0)

两个错误,第一个:

rtrim($post_params_string, '&');

必须是:

$post_params_string = rtrim($post_params_string, '&');

第二个:

CURLOPT_POSTFIELDS => $post_params,

必须是:

CURLOPT_POSTFIELDS => $post_params_string,