1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
| <?php namespace Home\Service;
class ZmopService {
function __construct() { $zmopConfig = array( 'appId' => '*********', 'privateKeyFile' => __ROOT__ . '/Pem/rsa_private_key.pem', 'zmPublicKeyFile' => __ROOT__ . '/Pem/rsazfb_public_key.pem', 'charset' => 'UTF-8', 'method' => 'zhima.auth.info.authorize', 'version' => '1.0', 'platform' => 'zmop', 'gatewayUrl' => 'https://zmopenapi.zmxy.com.cn/openapi.do', 'zmop_log_txt' => __ROOT__ . '/Public/zmop_log_bef74b0ac451f8e6e5301453f9474p99.txt', ); import("Org.Util.File"); $file = new\File(); $zmopConfig['privateKeyFile'] = $file->getRealFile($zmopConfig['privateKeyFile']); $zmopConfig['zmPublicKeyFile'] = $file->getRealFile($zmopConfig['zmPublicKeyFile']); $this->zmopConfig = $zmopConfig; }
public function getConfig() { return $this->zmopConfig; }
public function getZmopUrl($data) { Vendor('zmxy.zmop.ZmopClient'); Vendor('zmxy.zmop.request.ZhimaAuthInfoAuthorizeRequest'); $zmopConfig = $this->getConfig(); $client = new \ZmopClient($zmopConfig['gatewayUrl'], $zmopConfig['appId'], $zmopConfig['charset'], $zmopConfig['privateKeyFile'], $zmopConfig['zmPublicKeyFile']); $request = new \ZhimaAuthInfoAuthorizeRequest(); $request->setChannel("apppc"); $request->setPlatform($zmopConfig['platform']); $request->setIdentityType("2"); $request->setIdentityParam("{\"name\":\"" . $data['name'] . "\",\"certType\":\"IDENTITY_CARD\",\"certNo\":\"" . $data['certno'] . "\"}"); $request->setBizParams("{\"auth_code\":\"M_H5\",\"channelType\":\"app\",\"state\":\"" . $data['state'] . "\"}"); $url = $client->generatePageRedirectInvokeUrl($request); return $url; }
public function getResult($data) { $zmopConfig = $this->getConfig(); Vendor('zmxy.zmop.ZmopClient'); $params = $data['params']; $sign = $data['sign']; $params = strstr($params, '%') ? urldecode($params) : $params; $sign = strstr($sign, '%') ? urldecode($sign) : $sign;
$client = new \ZmopClient ($zmopConfig['gatewayUrl'], $zmopConfig['appId'], $zmopConfig['charset'], $zmopConfig['privateKeyFile'], $zmopConfig['zmPublicKeyFile']); $result = $client->decryptAndVerifySign($params, $sign); $resultArr = explode('&', $result); $arr = array(); if (is_array($resultArr) && $resultArr[0]) { foreach ($resultArr as $k => $v) { $parr = explode('=', $v); $arr[$parr[0]] = $parr[1]; } } return array( 'result' => $result, 'arr' => $arr, ); }
public function getScore($data) { $zmopConfig = $this->getConfig(); Vendor('zmxy.zmop.ZmopClient'); Vendor('zmxy.zmop.request.ZhimaCreditScoreGetRequest'); $client = new \ZmopClient($zmopConfig['gatewayUrl'], $zmopConfig['appId'], $zmopConfig['charset'], $zmopConfig['privateKeyFile'], $zmopConfig['zmPublicKeyFile']); $request = new \ZhimaCreditScoreGetRequest(); $request->setChannel("apppc"); $request->setPlatform($zmopConfig['platform']); $request->setTransactionId($data['transaction_id']); $request->setProductCode($data['product_code']); $request->setOpenId($data['open_id']); $response = $client->execute($request); return json_decode(json_encode($response), true); }
public function setLog($data) { $config = $this->payConfig; $str = serialize($data); import("Org.Util.File"); $file = new \File($config['zmop_log_txt']); $realfiel = $file->getRealFile(); file_put_contents($realfiel, $str, FILE_APPEND); }
public function getTransactionId($id) { if (strlen($id) < 13) { $str = ''; $cz = 13 - strlen($id); for ($i = 0; $i < $cz; $i++) { $str .= '0'; } $id = $str . $id; } else { $id = substr($id, 0, 13); } return $id; } }
|