function callback($in, &$paymentId, &$money, &$message, &$tradeno) { $txCode = trim($in['txCode']); //商家ID $merchantId = trim($in['merchantId']); //商家ID $transDate = trim($in['transDate']); //交易日期 $transFlow = trim($in['transFlow']); //交易号 $orderId = trim($in['orderId']); //交易号 $curCode = trim($in['curCode']); //交易金额 $amount = trim($in['amount']); //交易金额 $orderInfo = trim($in['orderInfo']); //交易金额 $whtFlow = trim($in['whtFlow']); //交易金额 $success = trim($in['success']); //交易结果,"Y"表示成功,"N"表示失败 $errorType = trim($in['errorType']); //交易结果,"Y"表示成功,"N"表示失败 $comment = trim($in['comment']); $sign = trim($in['sign']); $paymentId = $orderId; $money = $amount / 100; $tradeno = $in['whtFlow']; $msg = "txCode=" . $txCode . "&merchantId=" . $merchantId . "&transDate=" . $transDate . "&transFlow=" . $transFlow . "&orderId=" . $orderId . "&curCode=" . $curCode . "&amount=" . $amount . "&orderInfo=" . $orderInfo . "&comment=" . $comment . "&whtFlow=" . $whtFlow . "&success=" . $success . "&errorType=" . $errorType; if (!($keyfile = $this->getConf($orderId, 'udpay'))) { $message = "read key file error!"; return PAY_FAILED; } if (file_exists(dirname(__FILE__) . "/../../home/upload/udpay/" . $keyfile)) { $arr_key = file(dirname(__FILE__) . "/../../home/upload/udpay/" . $keyfile); } elseif (file_exists(dirname(__FILE__) . "/../../cert/udpay/" . $keyfile)) { $arr_key = file(dirname(__FILE__) . "/../../cert/udpay/" . $keyfile); } preg_match("/=([^=]*)/", trim($arr_key[2]), $private); $privateModulus = $private[1]; preg_match("/=([^=]*)/", trim($arr_key[3]), $private); $privateExponent = $private[1]; preg_match("/=([^=]*)/", trim($arr_key[5]), $public); $publicModulus = $public[1]; preg_match("/=([^=]*)/", trim($arr_key[6]), $public); $publicExponent = $public[1]; $verifySigature = verifySigature($msg, $sign, $publicExponent, $publicModulus); if ($verifySigature) { switch ($success) { //成功支付 case "Y": $message = "支付成功!"; return PAY_SUCCESS; break; //支付失败 //支付失败 case "N": $message = '支付失败,请立即与商店管理员联系'; return PAY_FAILED; break; } } else { $message = '签名认证失败,请立即与商店管理员联系'; return PAY_ERROR; } }
function pay_udpay_callback($in, &$paymentId, &$money, &$message, &$tradeno) { $txCode = trim($in['txCode']); //商家ID $merchantId = trim($in['merchantId']); //商家ID $transDate = trim($in['transDate']); //交易日期 $tradeno = $transFlow = trim($in['transFlow']); //交易号 $orderId = trim($in['orderId']); //交易号 $curCode = trim($in['curCode']); //交易金额 $money = $amount = trim($in['amount']); //交易金额 $orderInfo = trim($in['orderInfo']); //交易金额 $whtFlow = trim($in['whtFlow']); //交易金额 $success = trim($in['success']); //交易结果,"Y"表示成功,"N"表示失败 $errorType = trim($in['errorType']); //交易结果,"Y"表示成功,"N"表示失败 $sign = trim($in['sign']); $comment = trim($in['comment']); $money = $amount / 100; $paymentId = $orderId; $tradeno = $in['whtFlow']; $key = $this->getConf($orderId, 'PrivateKey'); $msg = "txCode=" . $txCode . "&merchantId=" . $merchantId . "&transDate=" . $transDate . "&transFlow=" . $transFlow . "&orderId=" . $orderId . "&curCode=" . $curCode . "&amount=" . $amount . "&orderInfo=" . $orderInfo . "&comment=" . $comment . "&whtFlow=" . $whtFlow . "&success=" . $success . "&errorType=" . $errorType; if (!$this->getConf($orderId, 'udpay')) { echo "read key file error!"; exit; } if (file_exists(dirname(__FILE__) . "/../../home/upload/udpay/" . $keyfile)) { $arr_key = file(dirname(__FILE__) . "/../../home/upload/udpay/" . $keyfile); } elseif (file_exists(dirname(__FILE__) . "/../../cert/udpay/" . $keyfile)) { $arr_key = file(dirname(__FILE__) . "/../../cert/udpay/" . $keyfile); } $privateModulus = substr(trim($arr_key[2]), 23); $privateExponent = substr(trim($arr_key[3]), 24); $publicModulus = substr(trim($arr_key[5]), 17); $publicExponent = substr(trim($arr_key[6]), 18); $verifySigature = verifySigature($msg, $sign, $privateExponent, $privateModulus); if ($sign == $testRsaDecrypt && $verifySigature) { switch ($success) { //成功支付 case "Y": echo "chenggong"; return PAY_SUCCESS; break; //支付失败 //支付失败 case "N": echo "shibai"; return PAY_ERROR; break; } } else { echo "Error"; return PAY_FAILED; } }