This is called from admin/orders#create
 This is intended for use as an admin action only
 It skips any address or bad user validations
 It's basically the same as save! on a new order, except it might send the payment request to buyer
338413
def pending!
      self.state = EffectiveOrders::PENDING
      self.addresses.clear if addresses.any? { |address| address.valid? == false }
      save!

      send_payment_request_to_buyer! if send_payment_request_to_buyer?
      true
    end
969484
def create
      @admin_redeem_code = DealRedemptions::RedeemCode.new(redeem_code_params)

      if @existing_code.count > 0
        flash[:notice] = 'Redemption code already exists.'
        render :new
      else
        if @admin_redeem_code.save
          redirect_to admin_redeem_codes_path, notice: 'Redeem code was successfully created.'
        else
          render :new
        end
      end
    end
544152
protected function beforeValidate() 
	{
		if(parent::beforeValidate()) {
			if($this->isNewRecord) {
				if($this->actived == 1)
					$this->orders = count(self::getPlugin(1, null, 'data')) + 1;
				else
					$this->orders = 0;
				
				$this->creation_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
			} else
				$this->modified_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
		}
		return true;
	}
586186
public function postAdminCreate()
    {
        $this->validationRulesAdmin['email'] = "required|email|unique:User";
        $this->validationRulesAdmin['username'] = "required|min:3|unique:User|max:25";
        $this->validationRulesAdmin['birthday'] = "required|date_format:d/m/Y|before:now";

        // Create a new validator instance from our validation rules
        $validator = Validator::make(Input::all(), $this->validationRulesAdmin);

        // If validation fails, we'll exit the operation now.
        if ($validator->fails()) {
            // Ooops.. something went wrong
            return Redirect::back()->withInput()->withErrors($validator);
        }

        //check whether use should be activated by default or not
        $activate = Input::get('status') != null && Input::get('status') != 0 ? true : false;

        try {
            $birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday'));

            // Register the user
            $user = Sentinel::register(array(
                'gender'   => Input::get('gender'),
                'first_name' => Input::get('first_name'),
                'last_name'  => Input::get('last_name'),
                'username'  => Input::get('username'),
                'birthday'   => $birthday,
                'email'      => Input::get('email'),
                'password'   => Input::get('password'),
                'status'   => Input::get('status'),
                //'pic'   => isset($safeName)?$safeName:'',
            ), $activate);

            $user->password = Hash::make(Input::get('password'));
            $user->description = Input::get('description');

            if (Input::get('force_new_password'))
                $user->force_new_password = 1;
            else
                $user->force_new_password = 0;

            // is new image uploaded?
            if ($file = Input::file('pic'))
            {
                $fileName        = $file->getClientOriginalName();
                $extension       = $file->getClientOriginalExtension() ?: 'png';

                if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif')
                {
                    $folderName      = '/uploads/users/';
                    $destinationPath = public_path() . $folderName;
                    $safeName        = str_random(10).'.'.$extension;
                    $file->move($destinationPath, $safeName);

                    //delete old pic if exists
                    if(File::exists(public_path() . $folderName . $user->pic))
                        File::delete(public_path() . $folderName . $user->pic);

                    //save new file path into db
                    $user->pic   = $safeName;
                }
            }

            $user->save();

            Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was created by an admin. ', $user->id);

            if (Input::get('send_new_password_email'))
            {
                if ($activate)
                {
                    Mail::queue('emails.account.account-created-by-admin', [ 'user' => $user, 'new_password' => Input::get('password') ], function ($m) use ($user) {
                        $m->to($user->email, $user->first_name . ' ' . $user->last_name);
                        $m->subject(Lang::get('base.mails.account_created'));
                    });
                }
                else
                {
                    Mail::queue('emails.account.account-created-by-admin-inactive', [ 'user' => $user, 'new_password' => Input::get('password') ], function ($m2) use ($user) {
                        $m2->to($user->email, $user->first_name . ' ' . $user->last_name);
                        $m2->subject(Lang::get('base.mails.account_created'));
                    });

                    $activation = Activation::create($user);

                    // Data to be used on the email view
                    $data = array(
                        'user'          => $user,
                        'activationUrl' => URL::route('activate', [$user->id, $activation->code]),
                    );

                    // Send the activation code through email
                    Mail::queue('emails.auth.register-activate', $data, function ($m) use ($user) {
                        $m->to($user->email, $user->first_name . ' ' . $user->last_name);
                        $m->subject(Lang::get('base.mails.welcome') . ' ' . $user->first_name);
                    });

                }
            }

            //add user to 'User' group
            /*$role = Sentinel::findRoleById(Input::get('group'));
            $role->users()->attach($user);

            //check for activation and send activation mail if not activated by default
            if(!Input::get('activate')) {
                // Data to be used on the email view
                $data = array(
                    'user'          => $user,
                    'activationUrl' => URL::route('activate', $user->id, Activation::create($user)->code),
                );

                // Send the activation code through email
                Mail::send('emails.register-activate', $data, function ($m) use ($user) {
                    $m->to($user->email, $user->first_name . ' ' . $user->last_name);
                    $m->subject('Welcome ' . $user->first_name);
                });
            }*/

            // Redirect to the home page with success menu
            return Redirect::route("users")->with('success', Lang::get('base.auth.account.created'));

        } catch (Exception $e) {
        }
        $error = Lang::get('base.base.error');

        // Redirect to the user creation page
        return Redirect::back()->withInput()->with('error', $error);
    }
945444
def create_request(payment_transaction)
      validate_payment_transaction payment_transaction

      request = payment_transaction_to_request payment_transaction

      request.api_method  = @api_method
      request.end_point   = payment_transaction.query_config.end_point
      request.gateway_url = payment_transaction.query_config.gateway_url
      request.signature   = create_signature payment_transaction

      request
    rescue Exception => error
      payment_transaction.add_error error
      payment_transaction.status = PaymentTransaction::STATUS_ERROR

      raise error
    end
772039
public function createAction()
    {
        $this->checkAuth();

        $addressCreate = $this->createForm(FrontForm::ADDRESS_CREATE);

        try {
            /** @var Customer $customer */
            $customer = $this->getSecurityContext()->getCustomerUser();

            $form = $this->validateForm($addressCreate, "post");
            $event = $this->createAddressEvent($form);
            $event->setCustomer($customer);

            $this->dispatch(TheliaEvents::ADDRESS_CREATE, $event);

            return $this->generateSuccessRedirect($addressCreate);
        } catch (FormValidationException $e) {
            $message = $this->getTranslator()->trans("Please check your input: %s", ['%s' => $e->getMessage()], Front::MESSAGE_DOMAIN);
        } catch (\Exception $e) {
            $message = $this->getTranslator()->trans("Sorry, an error occured: %s", ['%s' => $e->getMessage()], Front::MESSAGE_DOMAIN);
        }

        Tlog::getInstance()->error(sprintf("Error during address creation process : %s", $message));

        $addressCreate->setErrorMessage($message);

        $this->getParserContext()
            ->addForm($addressCreate)
            ->setGeneralError($message)
        ;

        // Redirect to error URL if defined
        if ($addressCreate->hasErrorUrl()) {
            return $this->generateErrorRedirect($addressCreate);
        }
    }
1134298
def payment_transaction_to_request(payment_transaction)
      request_fields = {}

      request_fields_definition.each do |field_name, property_path, _|
        field_value = PropertyAccessor.get_value payment_transaction, property_path

        if field_value
          request_fields[field_name] = field_value
        end
      end

      Request.new request_fields
    end
1369249
def create
      myparams = authorized_for_params.merge(authority_params)
      if @authorizable.present?
        @authority = @authorizable.authorities.new(myparams)
      else
        @authority = Authority.new(myparams)
      end

      @authority.save
      respond_with(@authority, location: location)
    end
637538
def create_new_sale(self, amount, purpose, payment_reference=None, order_id=None, channel_id=None, capture=True):
        
        request_data = {
            "amount": self.base.convert_decimal_to_hundreds(amount),
            "currency": self.currency,
            "purpose": purpose,
            "capture": capture
        }

        if payment_reference:
            request_data['paymentreference'] = payment_reference

        if order_id:
            request_data['orderid'] = order_id

        if channel_id:
            request_data['channelid'] = channel_id

        url = "%s%s" % (self.api_endpoint, constants.NEW_SALE_ENDPOINT)

        username = self.base.get_username()
        password = self.base.get_password(username=username, request_url=url)

        response = requests.post(url, json=request_data, auth=HTTPBasicAuth(username=username, password=password))

        if not self.base.verify_response(response.json()):
            raise SignatureValidationException('Server signature verification has failed')

        response_json = response.json()

        return response_json.get('transactionid'), response_json.get('paymenttokennumber'), response_json.get('status')
497478
public function process()
	{
		$context = $this->getContext();

		try
		{
			$type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
			$addresses = \Aimeos\Controller\Frontend::create( $context, 'basket' )->get()->getAddress( $type );

			if( $context->getUserId() == null && ( $address = current( $addresses ) ) !== false )
			{
				$create = (bool) $this->getView()->param( 'cs_option_account' );
				$userId = $this->getCustomerId( $address, $create );
				$context->setUserId( $userId );
			}
		}
		catch( \Exception $e )
		{
			$msg = sprintf( 'Unable to create an account: %1$s', $e->getMessage() );
			$context->getLogger()->log( $msg, \Aimeos\MW\Logger\Base::NOTICE );
		}

		parent::process();
	}
563902
def create_payment(self, request, amount, description=''):
        
        err = request.POST.get("error", False)
        if err:
            raise PaymentError("Dummy error requested")

        return 'fake_transaction_id'
764799
def admin_update
      return if !user_is_allowed('variants', 'edit')
      
      resp = Caboose::StdClass.new({'attributes' => {}})
      v = Variant.find(params[:id])    
      
      save = true    
      params.each do |name,value|
        case name        
          when 'alternate_id'
            v.alternate_id = value
          when 'sku'
            v.sku = value
          when 'barcode'
            v.barcode = value
          when 'price'
            v.price = value
          when 'quantity_in_stock'
            v.quantity_in_stock = value
          when 'ignore_quantity'
            v.ignore_quantity = value
          when 'allow_backorder'
            v.allow_backorder = value
          when 'status'
            v.status = value
          when 'weight'
            v.weight = value
          when 'length'
            v.length = value
          when 'width'
            v.width = value
          when 'height'
            v.height = value
          when 'option1'
            v.option1 = value
          when 'option2'
            v.option2 = value
          when 'option3'
            v.option3 = value
          when 'requires_shipping'
            v.requires_shipping = value
          when 'taxable'
            v.taxable = value
        end
      end
      resp.success = save && v.save
      render :json => resp
    end
734843
def admin_delete
      return if !user_is_allowed('orders', 'delete')
      Order.find(params[:id]).destroy
      render :json => Caboose::StdClass.new({
        :redirect => '/admin/orders'
      })
    end
627553
public function create(): void
    {
        if (!userHasPermission('admin:auth:accounts:create')) {
            unauthorised();
        }

        // --------------------------------------------------------------------------

        //  Page Title
        $this->data['page']->title = lang('accounts_create_title');

        // --------------------------------------------------------------------------

        //  Attempt to create the new user account
        $oInput = Factory::service('Input');
        if ($oInput->post()) {

            $oFormValidation = Factory::service('FormValidation');

            //  Set rules
            $oFormValidation->set_rules('group_id', '', 'required|is_natural_no_zero');
            $oFormValidation->set_rules('first_name', '', 'required');
            $oFormValidation->set_rules('last_name', '', 'required');

            $aEmailRules = [
                'required',
                'valid_email',
                'is_unique[' . NAILS_DB_PREFIX . 'user_email.email]',
            ];

            if (APP_NATIVE_LOGIN_USING == 'EMAIL') {

                $oFormValidation->set_rules('email', '', implode('|', $aEmailRules));

            } elseif (APP_NATIVE_LOGIN_USING == 'USERNAME') {

                $oFormValidation->set_rules('username', '', 'required');
                if ($oInput->post('email')) {
                    $oFormValidation->set_rules('email', '', implode('|', $aEmailRules));
                }

            } else {
                $oFormValidation->set_rules('email', '', implode('|', $aEmailRules));
                $oFormValidation->set_rules('username', '', 'required');
            }

            //  Set messages
            $oFormValidation->set_message('required', lang('fv_required'));
            $oFormValidation->set_message('min_length', lang('fv_min_length'));
            $oFormValidation->set_message('alpha_dash_period', lang('fv_alpha_dash_period'));
            $oFormValidation->set_message('is_natural_no_zero', lang('fv_required'));
            $oFormValidation->set_message('valid_email', lang('fv_valid_email'));
            $oFormValidation->set_message('is_unique', lang('fv_email_already_registered'));

            //  Execute
            if ($oFormValidation->run()) {

                //  Success
                $aData = [
                    'group_id' => (int) $this->input->post('group_id', true),
                    'password' => trim($this->input->post('password', true)),
                ];

                if (!$aData['password']) {
                    //  Password isn't set, generate one
                    $oUserPasswordModel = Factory::model('UserPassword', 'nails/module-auth');
                    $aData['password']  = $oUserPasswordModel->generate($aData['group_id']);
                }

                if ($oInput->post('email')) {
                    $aData['email'] = $oInput->post('email', true);
                }

                if ($oInput->post('username')) {
                    $aData['username'] = $oInput->post('username', true);
                }

                $aData['first_name']     = $oInput->post('first_name', true);
                $aData['last_name']      = $oInput->post('last_name', true);
                $aData['temp_pw']        = stringToBoolean($oInput->post('temp_pw', true));
                $aData['inform_user_pw'] = true;

                $oUserModel = Factory::model('User', 'nails/module-auth');
                $new_user   = $oUserModel->create($aData, stringToBoolean($oInput->post('send_activation', true)));

                if ($new_user) {

                    /**
                     * Any errors happen? While the user can be created successfully other problems
                     * might happen along the way
                     */

                    $oSession = Factory::service('Session', 'nails/module-auth');

                    if ($oUserModel->getErrors()) {

                        $sMessage = '<strong>Please Note,</strong> while the user was created successfully, the ';
                        $sMessage .= 'following issues were encountered:';
                        $sMessage .= '<ul><li>' . implode('</li><li>', $oUserModel->getErrors()) . '</li></ul>';

                        $oSession->setFlashData('message', $sMessage);
                    }

                    // --------------------------------------------------------------------------

                    //  Add item to admin changelog
                    $name = '#' . number_format($new_user->id);

                    if ($new_user->first_name) {
                        $name .= ' ' . $new_user->first_name;
                    }

                    if ($new_user->last_name) {
                        $name .= ' ' . $new_user->last_name;
                    }

                    $this->oChangeLogModel->add(
                        'created',
                        'a',
                        'user',
                        $new_user->id,
                        $name,
                        'admin/auth/accounts/edit/' . $new_user->id
                    );

                    // --------------------------------------------------------------------------

                    $sStatus  = 'success';
                    $sMessage = 'A user account was created for <strong>';
                    $sMessage .= $new_user->first_name . '</strong>, update their details now.';
                    $oSession->setFlashData($sStatus, $sMessage);

                    redirect('admin/auth/accounts/edit/' . $new_user->id);

                } else {
                    $this->data['error'] = 'There was an error when creating the user ';
                    $this->data['error'] .= 'account:<br />&rsaquo; ';
                    $this->data['error'] .= implode('<br />&rsaquo; ', $oUserModel->getErrors());
                }

            } else {
                $this->data['error'] = lang('fv_there_were_errors');
            }
        }

        // --------------------------------------------------------------------------

        //  Get data for the view
        $oUserGroupModel             = Factory::model('UserGroup', 'nails/module-auth');
        $oUserPasswordModel          = Factory::model('UserPassword', 'nails/module-auth');
        $this->data['groups']        = $oUserGroupModel->getAll();
        $this->data['passwordRules'] = [];

        foreach ($this->data['groups'] as $oGroup) {
            $this->data['passwordRules'][$oGroup->id] = $oUserPasswordModel->getRulesAsString($oGroup->id);
        }

        // --------------------------------------------------------------------------

        //  Load views
        Helper::loadView('create');
    }
717938
def admin_update
      return if !user_is_allowed('orders', 'edit')
      
      resp = Caboose::StdClass.new({'attributes' => {}})
      order = Order.find(params[:id])    
      
      save = true    
      params.each do |name,value|
        case name
          when 'tax'
            order.tax = value          
          when 'shipping'
            order.shipping = value
          when 'handling'
            order.handling = value
          when 'discount'
            order.discount = value        
          when 'status'
            order.status = value
            resp.attributes['status'] = {'text' => value}
        end
      end
      order.calculate_total    
      resp.success = save && order.save
      render :json => resp
    end
1143584
def create
      @admin = Admin.new(administrator_params)
      respond_to do |format|

        if @admin.save

          profile_images(params, @admin)
          Emailer.profile(@admin).deliver

          format.html { redirect_to admin_administrators_path, notice: I18n.t("controllers.admin.administrators.create.flash.success") }

        else
          format.html {
            # add breadcrumb and set title
            add_breadcrumb I18n.t("generic.add_new_user")
            @action = 'create'
            flash[:error] = I18n.t('generic.validation.no_passed')

            render action: "new"
          }
        end

      end
    end
132271
function _doRefund($oID, $amount = 0) {
    global $db, $messageStack;
    $new_order_status = (int)MODULE_PAYMENT_AUTHORIZENET_AIM_REFUNDED_ORDER_STATUS_ID;
    if ($new_order_status == 0) $new_order_status = 1;
    $proceedToRefund = true;
    $refundNote = strip_tags(zen_db_input($_POST['refnote']));
    if (isset($_POST['refconfirm']) && $_POST['refconfirm'] != 'on') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_REFUND_CONFIRM_ERROR, 'error');
      $proceedToRefund = false;
    }
    if (isset($_POST['buttonrefund']) && $_POST['buttonrefund'] == MODULE_PAYMENT_AUTHORIZENET_AIM_ENTRY_REFUND_BUTTON_TEXT) {
      $refundAmt = (float)$_POST['refamt'];
      $new_order_status = (int)MODULE_PAYMENT_AUTHORIZENET_AIM_REFUNDED_ORDER_STATUS_ID;
      if ($refundAmt == 0) {
        $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_INVALID_REFUND_AMOUNT, 'error');
        $proceedToRefund = false;
      }
    }
    if (isset($_POST['cc_number']) && trim($_POST['cc_number']) == '') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CC_NUM_REQUIRED_ERROR, 'error');
    }
    if (isset($_POST['trans_id']) && trim($_POST['trans_id']) == '') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_TRANS_ID_REQUIRED_ERROR, 'error');
      $proceedToRefund = false;
    }

    /**
     * Submit refund request to gateway
     */
    if ($proceedToRefund) {
      $submit_data = array('x_type' => 'CREDIT',
                           'x_card_num' => trim($_POST['cc_number']),
                           'x_amount' => number_format($refundAmt, 2),
                           'x_trans_id' => trim($_POST['trans_id'])
                           );
      unset($response);
      $response = $this->_sendRequest($submit_data);
      $response_code = $response[0];
      $response_text = $response[3];
      $response_alert = $response_text . ($this->commError == '' ? '' : ' Communications Error - Please notify webmaster.');
      $this->reportable_submit_data['Note'] = $refundNote;
      $this->_debugActions($response);

      if ($response_code != '1') {
        $messageStack->add_session($response_alert, 'error');
      } else {
        // Success, so save the results
        $sql_data_array = array('orders_id' => $oID,
                                'orders_status_id' => (int)$new_order_status,
                                'date_added' => 'now()',
                                'comments' => 'REFUND INITIATED. Trans ID:' . $response[6] . ' ' . $response[4]. "\n" . ' Gross Refund Amt: ' . $response[9] . "\n" . $refundNote,
                                'customer_notified' => 0
                             );
        zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
        $db->Execute("update " . TABLE_ORDERS  . "
                      set orders_status = '" . (int)$new_order_status . "'
                      where orders_id = '" . (int)$oID . "'");
        $messageStack->add_session(sprintf(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_REFUND_INITIATED, $response[9], $response[6]), 'success');
        return true;
      }
    }
    return false;
  }