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;
 }
Example #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);
 }
 private function invalid_positive_number($fieldName, $max_length = 0)
 {
     return !PZ_Utils::is_valid_parameter($this->params[$fieldName], $max_length) || !(ctype_digit($this->params[$fieldName]) || is_int($this->params[$fieldName])) || $this->params[$fieldName] <= 0;
 }
Example #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;
 }