Esempio n. 1
0
 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;
     }
 }
 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;
     }
 }
Esempio n. 3
0
        $result['data'] = null;
        $result['msg'] = "failed";
        $result['success'] = true;
        $result['code'] = "501";
    }
    $response->write(json_encode($result));
    return $response;
});
/**
 * Create Merchant
 */
$app->post("/merchants/create/", function ($request, $response, $args) {
    try {
        $json = $request->getBody();
        $data = json_decode($json, true);
        $merchant = new \models\Merchant();
        //$ticketing = json_decode($args['ticketing']);
        if (!empty($data)) {
            foreach ($data as $key => $val) {
                $merchant->{$key} = $val;
            }
        }
        $merchant->created_at = date("Y-m-d H:i:s");
        $input['number'] = $data['phone'];
        $input['key_salt'] = "";
        $merchant->password = \system\library\Hashing\Shahash::make($data['password'], $input);
        $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")), $data);
        if ($v->execute() == true) {
            if ($merchant->create()) {
                if (isset($input['phone'])) {
                    $merchant->pinAction($merchant->id, $data);