<?php
$publicKey = "-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCYmjf0jCuwBfmvwUMUA3PwEGfJ
0kML/21fecB+9PLehbJc4u+WI7ySZiGhxB15RueV7SnvFkPM+Ixkt5VoWg2p8RfD
ndgYFsZZeAXsXKWuCHCRXtgRlBSX31fZxCP3R4OkMZT9m5UKCNSrwmeSQQm0xbzw
iEEfBjUSJe9RF9/aDwIDAQAB
-----END PUBLIC KEY-----";
//$privateKey="-----BEGIN RSA PRIVATE KEY-----
//MIICWwIBAAKBgQCAoUufiIWkcYfn+sI3TPbVofRXmuEAsrpbIH78Fvy2mWqepHF2
//Py0hE2rw6ivphXN+cnrJudcLfdSqZbV0Ei+mMuZk3hkeaxIFpS5t2gntaItVfcvC
//o/xuGmURzHbQDUtZlaVruRTHedEOQwX3oWJTAs3xF3SzpLF7NRAwGlThWwIDAQAB
//AoGAR35fE/rDnRTlHxEHJcmHYFI2BwM0kDjGz6OOMPtt1ugKlMZ9seWHZdzvEZx2
//b8MW4G8sxDagyehUbak+Y5dAF+WfIVx/y0kZnoINAP+6ayCtigtuponfsg2VnPzR
//LCFeDzClOLH+fVa1vnT6oPNqYZAHZH0PNNeNxEYz01p9u0ECQQCL9z+3p51pXvLe
//F4IJli+1iirUAxg1+fE6mUQbwVyU0vUNPqRkkNqLVj3Qua27qnyAMfq3JJL9V4X2
//gy5b1X3rAkEA60RGVredwjsUuD/8LyoxzqlwUUFD+P4lINlgoKfk/wpCx5gI/aCl
//eh4QtHcsdseWdGDBXkbr8FNIW2gnxvOeUQJAEmuSvifYBpMRYXs0iPB0DO9HHane
//mNPxFGYxWXnEJm3xBDI3Tmjl6iqKbhrRq34PboulVE8C7UaEgeHXyww4ywJAQLbA
//DlxlhabQtTnMeYDGwIz0+zTTqKrntZh1rttf7xN4eQSF/JXyzpt0ht99GJMf/JUc
//u30Qq0ONVK9auawLcQJAMWufX8kLWUdfLsV5gdUGPDnTCDxU4zgqoCtNOBnItUqv
//SN4IlN5ig3cpf4OxSlDls0Yp4jUe2jMtmy/pxtnNGw==
//-----END RSA PRIVATE KEY-----";
$privateKey="-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAN/oDt1PSL843rNq
b/qfJ4j531yCNRDOR7djnmPXpALTf0NeEfN8s0N+lVxUW3LtOKwoXHNC6wCnuseh
/B7MwK5vbPBNS5+GR5ds6le/5TdhzXJb5tQtbgzzaqcihJEJkSKtEdm54rUwNEs0
KPrJQrZLRvPxlkkYo9KOTyJXV0zdAgMBAAECgYAWWqW5RKQfqz7YrMS3QdKBo2jA
ZKOFpQKV9ZUnpKzUN2daQ3cJVybSkz24NRfYNoTU80afn0u1CgnkynBQZuLJl7X5
Eqo5gSuT3Oikl+ezCz0Js3NH7Q8xCBjUqvD7Xz1uPZUO7OfdQZOMWhWoTgpYkJim
SGC0+gfuqfA9s+N3pQJBAPWlV9CgVIAUMOoO1rQaPfhSWFbGjSPWyoPi4hdabe+U
nVqyRUFzRfzYLMcMoy8HqNIQflLCpX0sfIKygiS4McsCQQDpWCJ/b3aORuxDYCjz
1iCKTd/mLaTPA9R7HfGT4kAz0TCTJ2ojREW1xhMEDsAUgy1I9lZHk52NlH8r7vXg
zYb3AkEAqT8Ma/+reLtwoDMtFtXl0IvbtZ4DbKf2zDusDu8NQ76fU/fz445qsDS5
VUONwz+Bv4oBnz/hCYd3Gg2nwWjvVQJANF096KEn1sfdr0T+C7IqvT66lxn5GSe/
4B0ZIFmulLJGF0/KBr4EcsVPcSKqQjAp0mzNceSTf7kqTL6kWN1mgwJAVCwL0ewi
QEFtz4H1koPr7PwXcqvqebR7+9hnXm1HLkMshNa02G7SE2tTsRieBI7GlC+My5QS
Uhjihv0MdPFKoA==
-----END PRIVATE KEY-----";
//////////////////请求代付/////////////////////////////////////
$orderNo="DAIFU_".time();// 订单号,不能重复,最长24位
$requestMoney="100";// 请求金额,单位(分)
$accountName="李雲竹";// 收款人
$accountNumber="6212264402079406793";// 收款帐号
$accountType="0";// 银行账户类别,0:对私账号 1:对公账号
$bankId="104651082615";// 12位银行编码(可在网上[https://www.hebbank.com/corporbank/otherBankQueryWeb.do]查询到)
$certificateType="0";// 证件类别, 0 为默认身份证,只有在对公打款的时候才需要用到以下三个数据,可空
$certificateNumber="510181198710086129";// 证件号码,与上面的结合使用,可空
$phone="13183895148";// 手机号码,可空
$identifyKey='3AB8CA20045DA9B7';
$secret_data="{'orderNo':'".$orderNo."','requestMoney':'".$requestMoney."','accountName':'".$accountName."','accountNumber':'".$accountNumber."','accountType':'".$accountType."','bankId':'".$bankId."','certificateType':'".$certificateType."','certificateNumber':'".$certificateNumber."','phone':'".$phone."','identifyKey':'".$identifyKey."'}";
//echo "加密前数据:".$secret_data."<br/>";
$pu_key=$publicKey;
$crypto = '';//分段加密
foreach (str_split($secret_data, 117) as $chunk) {
openssl_public_encrypt($chunk, $encryptData, $pu_key);
$crypto .= $encryptData;
}
$encryptedTemp = base64_encode($crypto);
//echo "加密结果:".$encryptedTemp."<br/>";
$data="identifyKey=".$identifyKey."&data=".$encryptedTemp;
//echo "签名前数据:".$data."<br/>";
$pi_key=$privateKey;
$verify = openssl_sign($data, $encrypted, $pi_key, OPENSSL_ALGO_MD5);
$encrypted = base64_encode($encrypted);
echo "签名结果:".$encrypted."<br/>";
$post_data = "identifyKey=".$identifyKey."&data=".urlencode($encryptedTemp)."&sign=".urlencode($encrypted);
echo "请求内容:".$post_data."<br/>";
$daifu_request_url='http://apay.spcode.cn/apay/';
$ch = curl_init($daifu_request_url);
$timeout = 5;
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
'Content-Length: ' . strlen($post_data)
));
$file_contents = curl_exec($ch);
curl_close($ch);
echo "返回结果".$file_contents."<br/>";
//////////////////请求代付/////////////////////////////////////
?>
网友评论