1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| <?php $messageData = "{'accountname':'张晓','accountno':'6208293748','amount':'0.01','merchantcode':'app','bankcode':'102'}";
$messageKey = "r79h90m2AD9A4c6C";
$cert = "-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCpxURQsvBaJgPq+Z/12ZU/4Wdc75INS9H6rAyc Q545Zi7nc+zDCkxUrljWPTILD133+shqK8sTu0Xbp8en/wSpGCqbb5uiKOSYvjSzr2Ka6wDnSIMt k4+HWgDkydu+aznTXUd0RaZzcZnF4Kk6/GwqoeKwdR9Rr3J8NXyTtUtSywIDAQAB -----END PUBLIC KEY-----";
$key = openssl_pkey_get_public($cert); $crypted = "";
openssl_public_encrypt($messageKey, $crypted, $cert); $encryptkey = base64_encode($crypted);
$data = base64_encode(openssl_encrypt($messageData, 'aes-128-ecb', $messageKey, OPENSSL_PKCS1_PADDING));
$post_data = array( "data" =>$data, "encryptkey" => $encryptkey, "merchantcode" => "app" );
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://api.server.beta/api/v2/pay/');
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
$data = curl_exec($curl);
curl_close($curl);
print_r($data); ?>
|