|
@@ -1,11 +1,50 @@
|
|
|
<?php
|
|
|
|
|
|
namespace mapi;
|
|
|
-
|
|
|
+use mapi\config\config;
|
|
|
class CTCard implements IOpenCard
|
|
|
{
|
|
|
- public function fraud_check() : bool
|
|
|
+ private function create_guid() : string
|
|
|
+ {
|
|
|
+ $str = md5(uniqid(mt_rand(), true));
|
|
|
+ $uuid = substr($str,0,8);
|
|
|
+ $uuid .= substr($str,8,4);
|
|
|
+ $uuid .= substr($str,12,4);
|
|
|
+ $uuid .= substr($str,16,4);
|
|
|
+ $uuid .= substr($str,20,12);
|
|
|
+ return $uuid;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function generate_packet_sequence_number() : string
|
|
|
+ {
|
|
|
+ return config::SYS_CODE.config::APP_CODE.date("ymdhm", time()).$this->create_guid();
|
|
|
+ }
|
|
|
+
|
|
|
+ private function sign() : string
|
|
|
+ {
|
|
|
+ return md5($this->generate_packet_sequence_number().config::KEY);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function createHeader($method) : array
|
|
|
+ {
|
|
|
+ return [
|
|
|
+ "sysCode" => config::SYS_CODE,
|
|
|
+ "appCode" => config::APP_CODE,
|
|
|
+ "transactionId" => $this->generate_packet_sequence_number(),
|
|
|
+ "reqTime" => date("Y-m-d H:i:s", time()),
|
|
|
+ "method" => $method,
|
|
|
+ "version" => 1,
|
|
|
+ "attach" => "fraud_check",
|
|
|
+ "sign" => $this->sign()
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function fraud_check($params, $net_errno) : bool
|
|
|
{
|
|
|
+ $head = $this->createHeader("fraudCheck");
|
|
|
+ $biz = json_encode($params);
|
|
|
+ $resp = http_post_data(config::test_env['DCN'], $biz , $head, $net_errno);
|
|
|
return false;
|
|
|
}
|
|
|
}
|