예제 #1
0
 /**
  * Creates a seller.
  *
  * @return void
  */
 public function post_index()
 {
     $validator = \Validation_Seller::create();
     if (!$validator->run()) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $seller = \Service_Seller::create($data['name'], $data);
     if (!$seller) {
         throw new HttpServerErrorException();
     }
     $this->response($seller);
 }
예제 #2
0
 /**
  * Generates sellers.
  *
  * @return void
  */
 protected static function sellers()
 {
     $date = date("Y-m-d H:i:s", self::BEGIN_DATETIME);
     $companies = array('Stella Labs, Inc', 'Star Point Industries');
     foreach ($companies as $company) {
         $seller = \Service_Seller::create($company, array('contact' => array('company_name' => $company, 'email' => 'support@' . \Inflector::friendly_title($company) . '.com', 'address' => mt_rand(1, 5000) . ' Quail Springs Pkwy', 'city' => 'Oklahoma City', 'state' => 'Oklahoma', 'zip' => mt_rand(10000, 99999), 'country' => 'US'), 'created_at' => $date));
         if ($seller) {
             self::$sellers[] = $seller;
             // Link the seller to the gateway.
             \Service_Gateway::link(self::$gateway, $seller);
         }
     }
     \Cli::write('Seller Simulation Complete', 'green');
 }
예제 #3
0
 /**
  * POST Index action.
  *
  * @return void
  */
 public function post_index()
 {
     $this->get_index();
     $validator = Validation_Seller::create();
     if (!$validator->run()) {
         Session::set_alert('error', __('form.error'));
         $this->view->errors = $validator->error();
         return;
     }
     $data = $validator->validated();
     if (!($seller = Service_Seller::create($data['name'], $data))) {
         Session::set_alert('error', 'There was an error adding the seller.');
         return;
     }
     Response::redirect($seller->link('switch'));
 }