ゴマクレジットインタフェース

8020 ワード

class ZmxyController extends Controller {

  //        
        public $gatewayUrl = "https://zmopenapi.zmxy.com.cn/openapi.do";
        //      
        //      
        public $privateKeyFile = "rsa_private_key.pem";
        public $zmPublicKeyFile = "rsa_public_key.pem";

        //      
        public $charset = "UTF-8";
        //        appId
        public $appId = "xxx";

    public function index(){

    }
    //     SDK      sign    ,   urlEncode
    public function generateSign($cert_name,$cert_no,$certType='IDENTITY_CARD'){

        $client = new \ZmopClient($this->gatewayUrl, $this->appId, $this->charset, $this->privateKeyFile,$this->zmPublicKeyFile);
        $request = new \ZhimaAuthInfoAuthorizeRequest();
        $request->setScene("CQSB");
        //          appsdk
        $request->setChannel("appsdk");
        //        2         “  4        identity_type”
        $request->setIdentityType("2");
        //            ,  ,    ;“  4        identity_param”
        //$request->setIdentityParam("{\"certNo\":\"$certNo\",\"certType\":\"IDENTITY_CARD\", \"name\":\"$name\"}");
        $request->setIdentityParam("{\"identity_type\":\"CERT_INFO\",\"cert_type\":\"IDENTITY_CARD\",\"cert_name\":\"$cert_name\",\"cert_no\":\"$cert_no\"}");//      
        //           “  4        biz_params”
        $request->setBizParams("{\"auth_code\":\"M_APPSDK\"}");

        $params = $client->generateEncryptedParamWithUrlEncode($request);
        $sign = $client->generateSignWithUrlEncode($request);

        $data['gatewayUrl'] = $this->gatewayUrl;
        $data['appId'] = $this->appId;
        $data['charset'] = $this->charset;
        $data['params']=$params;
        $data['sign'] = $sign;
        $this->ajaxreturn(array("desc"=>"  ","code"=>1111,"data"=>$data));
    }


    public function test($cert_name,$cert_no){
         $client = new \ZmopClient($this->gatewayUrl,$this->appId,$this->charset,$this->privateKeyFile,$this->zmPublicKeyFile);

         $request = new \ZhimaCustomerCertificationInitializeRequest();
         $request->setChannel("apppc");
         $request->setPlatform("zmop");

            $request->setTransactionId("CQSB".time());//            
            //20161230w1010103000048620621(  )  
            $request->setProductCode("w1010103000048621629");//        

            $request->setBizCode("FACE");//              
            $request->setIdentityParam("{\"identity_type\":\"CERT_INFO\",\"cert_type\":\"IDENTITY_CARD\",\"cert_name\":\"$cert_name\",\"cert_no\":\"$cert_no\"}");//      
            $request->setExtBizParam("{}");//              
            $response = $client->execute($request);
            var_dump($response);die();
          echo json_encode($response);
    }

http://blog.csdn.net/cometo985/article/details/51280201“