Beispiel #1
0
 /**
  * 向支付中心获取微信支付参数
  * @param $ac
  * @param $ack
  * @param $am
  * @param $body
  * @param $bg
  * @param $cityId
  * @param $or
  * @param $pn
  * @param $pt
  * @param $subject
  * @return array
  */
 public function requestAcenterWechatPayInitSerive($ac, $ack, $am, $body, $bg, $cityId, $or, $pn, $pt, $subject)
 {
     $params = array('ac' => $ac, 'ack' => $ack, 'am' => $am, 'body' => urlencode($body), 'bg' => urlencode($bg), 'cityid' => $cityId, 'or' => $or, 'pn' => urlencode($pn), 'pt' => urlencode($pt), '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::wechatpaySdkInit($configPayment, $params);
         if ($apiResult->isSucceeded()) {
             if ($apiResult['status'] == 'ok') {
                 $result['status'] = 'ok';
                 $result['url'] = !empty($apiResult['data']) ? $apiResult['data'] : '';
             } else {
                 $result['msg'] = $apiResult['message'];
             }
             break;
         } else {
             $result['msg'] = '链接失败';
             $count++;
         }
     }
     return $result;
 }