/** * 向支付中心获取支付宝参数 * @param $ac * @param $ack * @param $am * @param $body * @param $bg * @param $cityId * @param $paymentType * @param $or * @param $pn * @param $pt * @param $showUrl * @param $subject * @return array */ public function requestAcenterApliPayInitSerive($ac, $ack, $am, $body, $bg, $cityId, $paymentType, $or, $pn, $pt, $showUrl, $subject) { $params = array('ac' => $ac, 'ack' => $ack, 'am' => $am, 'body' => urlencode($body), 'bg' => urlencode($bg), 'cityid' => $cityId, 'payment_type' => $paymentType, 'or' => $or, 'pn' => urlencode($pn), 'pt' => urlencode($pt), 'show_url' => urlencode($showUrl), 'subject' => urlencode($subject), '_input_charset' => 'utf-8'); $result = array('status' => 'error', 'url' => '', 'msg' => ''); // 校验参数是否为空 foreach ($params as $val) { if (empty($val)) { $result['msg'] = '参数不正确'; return $result; } } $count = 0; while (true) { if ($count >= 3) { break; } $configPayment = Const_PaymentApp::CUSTOMER; $apiResult = Bll_Service_Payment::alipaySdkInit($configPayment, $params); if ($apiResult->isSucceeded()) { if ($apiResult['status'] == 'ok') { $result['status'] = 'ok'; $result['url'] = !empty($apiResult['data']) ? $apiResult['data']['url'] : ''; } else { $result['msg'] = $apiResult['message']; } break; } else { $result['msg'] = '链接失败'; $count++; } } return $result; }