public function validate()
 {
     $hash = PZ_Utils::generate_hash($this->get_response_params(), $this->secret_key);
     $hash_match = $hash == $this->get_hash() ? TRUE : FALSE;
     return $hash_match;
 }
示例#2
0
 public function refund()
 {
     $this->params = PZ_Utils::params_filter($this->params);
     $validate_result = (object) $this->validate();
     if ($validate_result->status == false) {
         throw new Exception("Invalid params : " . $validate_result->message);
     }
     $hash = PZ_Utils::generate_hash($this->params);
     $this->set_hash($hash);
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $this->refund_api_url);
     curl_setopt($curl, CURLOPT_POST, 1);
     curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($this->params));
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     // curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
     $response = curl_exec($curl);
     if (!$response) {
         throw new Exception('Curl error: ' . curl_error($curl));
     }
     curl_close($curl);
     return new RefundResponse($response);
 }
 public function charge()
 {
     $response = array("status" => "ERROR", "error_message" => "", "url" => "", "params" => "");
     $this->params = PZ_Utils::params_filter($this->params);
     $validate_result = $this->validate();
     if (empty($validate_result['status'])) {
         $response["error_message"] = $validate_result['message'];
         return $response;
     }
     // $this->set_timegmt();
     $hash = PZ_Utils::generate_hash($this->params, $this->secret_key);
     $this->set_hash($hash);
     switch ($this->params[PZ_Constants::PARAMETER_UI_MODE]) {
         case PZ_Constants::UI_MODE_IFRAME:
             $response["url"] = $this->get_charging_api_url() . "?" . http_build_query($this->params);
             break;
         case PZ_Constants::UI_MODE_REDIRECT:
             $response["url"] = $this->get_charging_api_url();
             $response["params"] = $this->params;
             break;
     }
     $response["status"] = "OK";
     return $response;
 }
示例#4
0
 private function get_query_url()
 {
     $this->params = PZ_Utils::params_filter($this->params);
     $validate_result = $this->validate();
     if (empty($validate_result["status"])) {
         throw new Exception("Invalid params : " . $validate_result["message"]);
     }
     $hash = PZ_Utils::generate_hash($this->params);
     $this->set_hash($hash);
     $url = $this->query_api_url . "?" . http_build_query($this->params);
     return $url;
 }