コード例 #1
0
ファイル: gateways.php プロジェクト: mehulsbhatt/volcano
 /**
  * POST Create action.
  *
  * @return void
  */
 public function post_create()
 {
     $this->get_create();
     $data = Input::post();
     $data['meta'] = array();
     foreach (Input::post('meta') as $meta) {
         if ($name = Arr::get($meta, 'name')) {
             $data['meta'][$name] = Arr::get($meta, 'value');
         }
     }
     $validator = Validation_Gateway::create();
     if (!$validator->run($data)) {
         Session::set_alert('error', __('form.error'));
         $this->view->errors = $validator->error();
         return;
     }
     $data = $validator->validated();
     if ($gateway = Service_Gateway::create($data['type'], $data['processor'], $data)) {
         if (Service_Gateway::link($gateway, Seller::active())) {
             Session::set_alert('success', 'The gateway has been added.');
         } else {
             Session::set_alert('error', 'There was an error adding the gateway.');
         }
     } else {
         Session::set_alert('error', 'There was an error adding the gateway.');
     }
     Response::redirect('settings/gateways');
 }
コード例 #2
0
ファイル: gateways.php プロジェクト: mehulsbhatt/volcano
 /**
  * Creates a gateway.
  *
  * @param int $seller_id Seller ID.
  *
  * @return void
  */
 public function post_index($seller_id = null)
 {
     $validator = \Validation_Gateway::create();
     if (!$validator->run()) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $gateway = \Service_Gateway::create($data['type'], $data['processor'], $data);
     if (!$gateway) {
         throw new HttpServerErrorException();
     }
     if (!\Service_Gateway::link($gateway, \Seller::active())) {
         throw new HttpServerErrorException();
     }
     $this->response($gateway);
 }