function sendForBilling() { $response = new Response(); try { $projectId = $this->input->post("project-id"); $amount = $this->input->post("project-bill-amount"); $billDoc = $this->input->post("bill-doc"); $project = $this->findById("Project", $projectId); if ($project == null) { throw new RuntimeException("Invalid Project..!"); } $project->setStatus(Project::PROJECT_BILL); $project->getWorkOrder()->setStatus(Workorder::STATUS_COMPLETED); $project->getWorkOrder()->setApprovedBy($this->getLoggedInUser()); $bill = new Bill(); $bill->setAmount($amount); $bill->setProject($project); $bill->setCreated(new DateTime()); $bill->setStatus(Bill::STATUS_PENDING); if ($billDoc != null && $billDoc != "") { foreach ($billDoc as $file) { $doc = new Document(); $doc->setName($file); $doc->setCreated(new DateTime()); $bill->getBillDoc()->add($doc); } } $this->save($bill); $response->setData(Project::PROJECT_BILL); } catch (Exception $e) { $response->setStatus(false); $response->setErrorMessage($e->getMessage()); } $this->output->set_content_type('application/json')->set_output(json_encode($response)); }
public function testHash() { // test_token|sale_id_1|optional|user defined|http://txn_completed|http://server_side_notification_url|INR|5.00 // test_token|sale_id_1|optional|user defined|http://txn_completed|http://server_side_notification_url|INR|5.00 $bill = new Bill(); $bill->setAccessToken("test_token"); $bill->setCommand("debit"); $bill->setUniqueId("sale_id_1"); $bill->setComments("optional"); $bill->setUdf("user defined"); $bill->setReturnUrl("http://txn_completed"); $bill->setNotificationUrl("http://server_side_notification_url"); $bill->setAmount("5.00"); $bill->setCurrency("INR"); $hash = $bill->getHash("merchant_salt"); echo "Hash String [" . $bill . "]\n"; if (0 != strcmp($hash, "7a97febb1ee0fd596936be066b1617ded7ac558248985a22f7dcc770ad399874f16ad5ff3e2168326582a96d68445ed297540b8a64affc36938a11e0cd1d64e7")) { echo "Hash Mismatch : " . $hash; throw new \Exception(); } else { echo "Hash : " . $hash; } }