Created
July 1, 2014 05:21
-
-
Save hit1205/28e91afbdff2da8ef4ea to your computer and use it in GitHub Desktop.
歐付寶的 All in one 串接欄位處理,超麻煩 der ~ =皿=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function http_build_query_without_urlencode($ary = array()){ | |
$newArray = array(); | |
foreach($ary as $key => $val){ | |
$newArray[] = $key . '=' . $val; | |
} | |
return implode('&', $newArray); | |
} | |
$paymentFields = array(); | |
$prdListForAllPay = array('ItemName_1', 'ItemName_2', 'ItemName_3'); | |
$paymentFields['MerchantTradeNo'] = '...'; | |
$paymentFields['MerchantTradeDate'] = date('Y/m/d H:i:s'); | |
$paymentFields['TotalAmount'] = '123'; | |
$paymentFields['TradeDesc'] = '...'; | |
$paymentFields['ItemName'] = mb_substr(implode('#', $prdListForAllPay), 0, 200); | |
$paymentFields['ReturnURL'] = '...'; | |
$paymentFields['ClientBackURL'] = '...'; | |
$paymentFields['PaymentInfoURL'] = '...'; | |
ksort($paymentFields); | |
$preCheck = array_merge(array( | |
'HashKey' => '...', | |
), $paymentFields, array( | |
'HashIV' => '...', | |
)); | |
$check = urlencode(http_build_query_without_urlencode($preCheck)); | |
$check = str_replace(array( | |
'%21', | |
'%2A', | |
'%28', | |
'%29', | |
), array( | |
'!', | |
'*', | |
'(', | |
')', | |
), $check); | |
$paymentFields['CheckMacValue'] = strtoupper(md5(strtolower($check))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment