public function createAction() { $input = $this->_params; $transaction = new \models\Transaction(); $mCusData = explode(";", $input["merchData"]); var_dump($mCusData); //$d = []; $d = explode(":", $mCusData); echo "<br>"; var_dump($d); foreach ($mCusData as $cdata) { foreach (get_obkect_vars($transaction) as $name => $value) { if ($name == "trans_amount") { $input[$name] = preg_replace("/AMOUNT:?/", "", $cdata); } } echo $cdata . "<br>"; } $mMerchData = $input['merchData']; system\library\Database\DB::insert("transactions", array("trans_id" => $input["merchData"], "trans_type" => $input["cusData"], "narration" => $input["merchData"], "merch_app_id" => $input["merchData"])); $result = array(); $result['success'] = true; $result['msg'] = "Record Created"; $result['id'] = $result['code'] = "200"; return $result; exit; unset($input['controller']); unset($input['action']); foreach ($input as $key => $value) { $transaction->{$key} = $value; } $transaction->created_at = date("Y-m-d H:i:s"); // $transaction->verified = 0; //$merchant->verified = 0; $v = new system\library\Validator\Validator(array(new system\library\Validator\Validate\Required('trans_id', " is required"), new system\library\Validator\Validate\Required('merch_app_id', " is required"), new system\library\Validator\Validate\Required("cus_app_id", " is required"), new system\library\Validator\Validate\Required("trans_amount", " is required"), new system\library\Validator\Validate\Required('cus_bank_name', " is required"), new system\library\Validator\Validate\Required("merch_bank_acc", " is required"), new system\library\Validator\Validate\Required('cus_bank_acc', " is required"), new system\library\Validator\Validate\Required("merch_bank_acc", " is required"), new system\library\Validator\Validate\Required('cus_bank_acc', " is required"), new system\library\Validator\Validate\Required("merch_bank_code", " is required"), new system\library\Validator\Validate\Required('cus_bank_code', " is required")), $input); if ($v->execute() == true) { if ($transaction->create()) { $result = array(); $result['success'] = true; $result['msg'] = "Record Created"; $result['id'] = $transaction->id; $result['code'] = "200"; return $result; } else { $result = array(); $result['success'] = false; $result['errmsg'] = "Transaction could not be created"; $result['code'] = "501"; //throw new \Exception("Customer could not be created"); //return "error"; //unsuccessful return $result; } } else { $v_result = $v->getErrors(); $result = array(); $result['success'] = false; $result['errmsg'] = $v_result; $result['code'] = "501"; return $result; } }
public function createAction() { $input = $this->_params; $transaction = new \models\Transaction(); $mcypt = new \system\library\Hashing\MCrypt(); $cusData = explode(";", $input['cusData']); $merchData = explode(";", $input['merchData']); $input['trans_amount'] = $merchData[0]; $input['trans_id'] = $merchData[1]; $input['merch_app_id'] = $merchData[2]; //get merchant details $merchant = models\Merchant::findByAppId($merchData[3]); //print_r($merchant); $input['merch_bank_code'] = $merchData[3]; $input['merch_bank_acc'] = $merchData[4]; $input['cus_app_id'] = $cusData[0]; $input['cus_bank_acc'] = $cusData[2]; $input['cus_bank_name'] = $cusData[1]; $input['cus_bank_code'] = $cusData[3]; unset($input['controller']); unset($input['action']); unset($input['cusData']); unset($input['merchData']); foreach ($input as $key => $value) { $transaction->{$key} = $value; } $transaction->created_at = date("Y-m-d H:i:s"); // $transaction->verified = 0; //$merchant->verified = 0; $v = new system\library\Validator\Validator(array(new system\library\Validator\Validate\Required('trans_id', " is required"), new system\library\Validator\Validate\Required('merch_app_id', " is required"), new system\library\Validator\Validate\Required("cus_app_id", " is required"), new system\library\Validator\Validate\Required("trans_amount", " is required"), new system\library\Validator\Validate\Required('cus_bank_name', " is required"), new system\library\Validator\Validate\Required("merch_bank_acc", " is required"), new system\library\Validator\Validate\Required('cus_bank_acc', " is required"), new system\library\Validator\Validate\Required("merch_bank_acc", " is required"), new system\library\Validator\Validate\Required('cus_bank_acc', " is required"), new system\library\Validator\Validate\Required("merch_bank_code", " is required"), new system\library\Validator\Validate\Required('cus_bank_code', " is required")), $input); if ($v->execute() == true) { if ($transaction->create()) { $result = array(); $result['success'] = true; $result['msg'] = "Record Created"; $result['id'] = $transaction->id; $result['code'] = "200"; return $result; } else { $result = array(); $result['success'] = false; $result['errmsg'] = "Transaction could not be created"; $result['code'] = "501"; //throw new \Exception("Customer could not be created"); //return "error"; //unsuccessful return $result; } } else { $v_result = $v->getErrors(); $result = array(); $result['success'] = false; $result['errmsg'] = $v_result; $result['code'] = "501"; return $result; } }
public function createAction() { $input = $this->_params; unset($input['controller']); unset($input['action']); $merchant = new \models\Merchant(); foreach ($input as $key => $value) { $merchant->{$key} = $value; } $merchant->created_at = date("Y-m-d H:i:s"); $merchant->verified = 0; $input['number'] = $input['phone']; $input['key_salt'] = ""; $merchant->password = system\library\Hashing\Shahash::make($input['password'], $input); $merchant->verified = 0; $v = new system\library\Validator\Validator(array(new system\library\Validator\Validate\Unique("email", "is already existing", "merchants"), new system\library\Validator\Validate\Required('email', " is required"), new system\library\Validator\Validate\Unique("phone", "is already existing", "merchants"), new system\library\Validator\Validate\Unique("app_id", "is already existing", "merchants"), new system\library\Validator\Validate\Required('phone', " is required")), $input); if ($v->execute() == true) { if ($merchant->create()) { if (isset($input['phone'])) { $this->pinAction($merchant->id); } $result = array(); $result['success'] = true; $result['msg'] = "Record Created"; $result['id'] = $merchant->id; $result['code'] = "200"; return $result; } else { $result = array(); $result['success'] = false; $result['errmsg'] = "Merchant could not be created"; $result['code'] = "501"; //throw new \Exception("Customer could not be created"); //return "error"; //unsuccessful return $result; } } else { $v_result = $v->getErrors(); $result = array(); $result['success'] = false; $result['errmsg'] = $v_result; $result['code'] = "501"; return $result; } }
$result['code'] = "404"; if ($v->execute() == true) { if ($trip->create()) { $result['success'] = true; $result['msg'] = "Record Created"; $result['data'] = $trip; $result['code'] = "200"; } else { $result['success'] = false; $result['msg'] = "Route could not be created"; $result['data'] = $trip; $result['code'] = "501"; //throw new \Exception("Customer could not be created"); //return "error"; //unsuccessful } } else { $v_result = $v->getErrors(); $result['success'] = false; $result['msg'] = $v_result; $result['data'] = $trip; $result['code'] = "501"; } $response->write(json_encode($result)); return $response; }); $app->post('/triplog/batchsync', function ($request, $response, $args) { // $batchTickets = \models\Tickets::find_by_sql("SELECT * FROM tickets WHERE status=2 AND app_id ='".$args['appid']."'"); try { $json = $request->getBody(); $json = str_replace("\\", "", $json); $json = str_replace("\"[", "[", $json); $json = str_replace("]\"", "]", $json);