amount=xxx¤cy=xxx&extend=xxx&order_id=xxx&payment_id=xxx&status=xxx&status_code=xxx&status_detail=xxx×tamp=xxx&key=代收密钥 生成基于php格式的拼接代码
时间: 2023-07-23 15:39:46 浏览: 100
Extend_sometimeqkd_Extend_
以下是一个基于PHP的拼接代码:
```php
<?php
$amount = $_POST['amount'];
$currency = $_POST['currency'];
$extend = $_POST['extend'];
$order_id = $_POST['order_id'];
$payment_id = $_POST['payment_id'];
$status = $_POST['status'];
$status_code = $_POST['status_code'];
$status_detail = $_POST['status_detail'];
$timestamp = $_POST['timestamp'];
$key = 'your_collection_key'; //此处应为商户的代收密钥
$data = array(
'amount' => $amount,
'currency' => $currency,
'extend' => $extend,
'order_id' => $order_id,
'payment_id' => $payment_id,
'status' => $status,
'status_code' => $status_code,
'status_detail' => $status_detail,
'timestamp' => $timestamp
);
ksort($data); //按照key的字母顺序排序
$str = '';
foreach ($data as $k => $v) {
if ($v) {
$str .= $k . '=' . $v . '&';
}
}
$str .= 'key=' . $key; //将代收密钥加在最后
$sign = strtoupper(md5($str)); //将拼接好的字符串进行MD5加密,然后转换为大写字母
echo $sign;
```
其中,`$key`应该是商户自己的代收密钥。在拼接字符串时,需要按照参数名的字母顺序排序,并将代收密钥放在最后。然后将拼接好的字符串进行MD5加密,转换为大写字母,即可得到签名。最后将签名返回给平台即可。
阅读全文