url=$CampURL."/payment-receive.php"; } public function getLastError() { return $this->lastError; } public function sendPaymentToDanceCamps($BookingID, $APIToken, $Secret, $Result, $Amount, $Fee, $Currency, $TxnID, $Notes, $EmailNotes) { // Get the token $token=\TOTP::getOTP($Secret); if (isset($token['error'])){ $this->setLastError("The secret is not valid"); return false; } if (!isset($token['otp'])) { $this->setLastError("An error occurred getting the TOTP token"); return false; } else $token=$token['otp']; // Set the post data $this->postdata["BookingID"]=$BookingID; $this->postdata["APIToken"]=$APIToken; $this->postdata["Token"]=$token; $this->postdata["Status"]=$Result; $this->postdata["Amount"]=$Amount; $this->postdata["Currency"]=$Currency; $this->postdata["TxnID"]=$TxnID; $this->postdata["FeeAmount"]=$Fee; $this->postdata["Notes"]=$Notes; $this->postdata["EmailNotes"]=$EmailNotes; // Send return $this->sendWithCURL(); } public function getResponse() { return $this->response; } private function sendWithCURL() { $ch = curl_init(); //curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_URL,$this->url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($this->postdata)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $this->response = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close ($ch); if ($httpcode!=200) return false; else { $arr=json_decode($this->response, true); if (isset($arr['status']) && $arr['status']==="success") return true; else return false; } } private function setLastError($msg) { $this->lastError=$msg; } } ?>