我的 PHP 脚本需要帮助。我需要以加密方式发布某些字段,如 invoiceid、名字、电子邮件等。校验和的公式是
sha512 (key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||<SALT>)
我需要通过 sha512 发布上述变量。我无法做到这一点。请帮助解决这个问题。我是一个学习者,我不擅长 PHP。
这是代码。我仍然收到校验和错误。
<?php
function xxx_config() {
$configarray = array(
"FriendlyName" => array("Type" => "System", "Value"=>"XXX"),
"alias" => array("FriendlyName" => "Merchant ID", "Type" => "text", "Size" => "20", ),
"salt" => array("FriendlyName" => "SALT", "Type" => "text", "Size" => "20",),
"mode" => array("FriendlyName" => "MODE", "Type" => "text", "Description" => "TEST or LIVE", ),
);
return $configarray;
}
function xxx_link($params) {
# Gateway Specific Variables
$key = $params['alias'];
$gatewaymode = $params['mode'];
$salt = $params['salt'];
# Invoice Variables
$txnid = $params['invoiceid'];
$productinfo = $params["description"];
$amount = $params['amount']; # Format: ##.##
$currency = $params['currency']; # Currency Code
# Client Variables
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];
# System Variables
$companyname = 'XXX';
$systemurl = $params['systemurl'];
$currency = $params['currency'];
# Enter your code submit to the gateway...
$hashdata = ($key."|".$txnid."|".$amount."|".$productinfo."|".$firstname."|".$email."|"."|"."|"."|"."|"."|".$salt);
$hash = hash("sha512", $hashdata);
$code = '<form method="post" action="https://secure.xxx.xxx" name="frmTransaction" id="frmTransaction" onSubmit="return validate()">
<input type="hidden" name="key" value="'.$key.'" />
<input type="hidden" name="mode" value="'.$gatewaymode.'" />
<input type="hidden" name="productinfo" value="'.$productinfo.'" />
<input type="hidden" name="txnid" value="'.$txnid.'" />
<input type="hidden" name="salt" value="'.$salt.'" />
<input type="hidden" name="name" value="'.$firstname.'" />
<input type="hidden" name="address" value="'.$address1.'" />
<input type="hidden" name="city" value="'.$city.'" />
<input type="hidden" name="state" value="'.$state.'" />
<input type="hidden" name="country" value="'.$country.'" />
<input type="hidden" name="postal_code" value="'.$postcode.'" />
<input type="hidden" name="ship_name" value="'.$firstname.'" />
<input type="hidden" name="ship_address" value="'.$address1.'" />
<input type="hidden" name="ship_city" value="'.$city.'" />
<input type="hidden" name="ship_state" value="'.$state.'" />
<input type="hidden" name="ship_country" value="'.$country.'" />
<input type="hidden" name="ship_postal_code" value="'.$postcode.'" />
<input type="hidden" name="ship_phone" value="'.$phone.'" />
<input type="hidden" name="email" value="'.$email.'" />
<input type="hidden" name="phone" value="'.$phone.'" />
<input type="hidden" name="amount" value="'.$amount.'" />
<input type="hidden" name="surl" value="https://xxx.xx/xxxx.php" />
<input type="hidden" name="furl" value="https://xxx.xx/xxx.php" />
<input type="hidden" name="Hash" value="'.$hash.'"/>
<input type="submit" value="Pay Now" />
</form>';
return $code;
}
?>