public function run() { $this->command->info('Running UserTableSeeder'); Eloquent::unguard(); $account = Account::create(['name' => 'Test Account', 'account_key' => str_random(16), 'timezone_id' => 1]); User::create(['email' => TEST_USERNAME, 'username' => TEST_USERNAME, 'account_id' => $account->id, 'password' => Hash::make(TEST_PASSWORD), 'registered' => true, 'confirmed' => true]); Affiliate::create(['affiliate_key' => SELF_HOST_AFFILIATE_KEY]); }
public function run() { $this->command->info('Running UserTableSeeder'); Eloquent::unguard(); $faker = Faker\Factory::create(); $company = Company::create(); $account = Account::create(['name' => $faker->name, 'address1' => $faker->streetAddress, 'address2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => Country::all()->random()->id, 'account_key' => str_random(RANDOM_KEY_LENGTH), 'invoice_terms' => $faker->text($faker->numberBetween(50, 300)), 'work_phone' => $faker->phoneNumber, 'work_email' => $faker->safeEmail, 'invoice_design_id' => min(InvoiceDesign::all()->random()->id, 10), 'header_font_id' => min(Font::all()->random()->id, 17), 'body_font_id' => min(Font::all()->random()->id, 17), 'primary_color' => $faker->hexcolor, 'timezone_id' => 1, 'company_id' => $company->id]); User::create(['email' => TEST_USERNAME, 'username' => TEST_USERNAME, 'account_id' => $account->id, 'password' => Hash::make(TEST_PASSWORD), 'registered' => true, 'confirmed' => true, 'notify_sent' => false, 'notify_paid' => false]); Affiliate::create(['affiliate_key' => SELF_HOST_AFFILIATE_KEY]); }
public function run() { $this->command->info('Running UserTableSeeder'); Eloquent::unguard(); $faker = Faker\Factory::create(); $company = Company::create(); $account = Account::create(['name' => $faker->name, 'address1' => $faker->streetAddress, 'address2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => Country::all()->random()->id, 'account_key' => str_random(RANDOM_KEY_LENGTH), 'invoice_terms' => $faker->text($faker->numberBetween(50, 300)), 'work_phone' => $faker->phoneNumber, 'work_email' => $faker->safeEmail, 'invoice_design_id' => InvoiceDesign::where('id', '<', CUSTOM_DESIGN)->get()->random()->id, 'header_font_id' => min(Font::all()->random()->id, 17), 'body_font_id' => min(Font::all()->random()->id, 17), 'primary_color' => $faker->hexcolor, 'timezone_id' => 1, 'company_id' => $company->id]); $user = User::create(['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => TEST_USERNAME, 'username' => TEST_USERNAME, 'account_id' => $account->id, 'password' => Hash::make(TEST_PASSWORD), 'registered' => true, 'confirmed' => true, 'notify_sent' => false, 'notify_paid' => false, 'is_admin' => 1]); $client = Client::create(['user_id' => $user->id, 'account_id' => $account->id, 'public_id' => 1, 'name' => $faker->name, 'address1' => $faker->streetAddress, 'address2' => $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => DEFAULT_COUNTRY, 'currency_id' => DEFAULT_CURRENCY]); Contact::create(['user_id' => $user->id, 'account_id' => $account->id, 'client_id' => $client->id, 'public_id' => 1, 'email' => env('TEST_EMAIL', TEST_USERNAME), 'is_primary' => true]); Product::create(['user_id' => $user->id, 'account_id' => $account->id, 'public_id' => 1, 'product_key' => 'ITEM', 'notes' => 'Something nice...', 'cost' => 10]); Affiliate::create(['affiliate_key' => SELF_HOST_AFFILIATE_KEY]); }
/** * @return mixed */ public function doRegister() { $affiliate = Affiliate::where('affiliate_key', '=', SELF_HOST_AFFILIATE_KEY)->first(); $email = trim(Input::get('email')); if (!$email || $email == TEST_USERNAME) { return RESULT_FAILURE; } $license = new License(); $license->first_name = Input::get('first_name'); $license->last_name = Input::get('last_name'); $license->email = $email; $license->transaction_reference = Request::getClientIp(); $license->license_key = Utils::generateLicense(); $license->affiliate_id = $affiliate->id; $license->product_id = PRODUCT_SELF_HOST; $license->is_claimed = 1; $license->save(); return RESULT_SUCCESS; }
public function do_license_payment() { $testMode = Session::get('test_mode') === 'true'; $rules = array('first_name' => 'required', 'last_name' => 'required', 'card_number' => 'required', 'expiration_month' => 'required', 'expiration_year' => 'required', 'cvv' => 'required', 'address1' => 'required', 'city' => 'required', 'state' => 'required', 'postal_code' => 'required', 'country_id' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('license')->withErrors($validator); } $account = $this->accountRepo->getNinjaAccount(); $account->load('account_gateways.gateway'); $accountGateway = $account->getGatewayByType(PAYMENT_TYPE_CREDIT_CARD); try { $affiliate = Affiliate::find(Session::get('affiliate_id')); if ($testMode) { $ref = 'TEST_MODE'; } else { $gateway = self::createGateway($accountGateway); $details = self::getLicensePaymentDetails(Input::all(), $affiliate); $response = $gateway->purchase($details)->send(); $ref = $response->getTransactionReference(); if (!$ref) { Session::flash('error', $response->getMessage()); return Redirect::to('license')->withInput(); } if (!$response->isSuccessful()) { Session::flash('error', $response->getMessage()); Utils::logError($response->getMessage()); return Redirect::to('license')->withInput(); } } $licenseKey = Utils::generateLicense(); $license = new License(); $license->first_name = Input::get('first_name'); $license->last_name = Input::get('last_name'); $license->email = Input::get('email'); $license->transaction_reference = $ref; $license->license_key = $licenseKey; $license->affiliate_id = Session::get('affiliate_id'); $license->product_id = Session::get('product_id'); $license->save(); $data = ['message' => $affiliate->payment_subtitle, 'license' => $licenseKey, 'hideHeader' => true]; $name = "{$license->first_name} {$license->last_name}"; $this->contactMailer->sendLicensePaymentConfirmation($name, $license->email, $affiliate->price, $license->license_key, $license->product_id); if (Session::has('return_url')) { return Redirect::away(Session::get('return_url') . "?license_key={$license->license_key}&product_id=" . Session::get('product_id')); } else { return View::make('public.license', $data); } } catch (\Exception $e) { $errorMessage = trans('texts.payment_error'); Session::flash('error', $errorMessage); Utils::logError(Utils::getErrorString($e)); return Redirect::to('license')->withInput(); } }
public function doRegister() { $affiliate = Affiliate::where('affiliate_key', '=', SELF_HOST_AFFILIATE_KEY)->first(); $license = new License(); $license->first_name = Input::get('first_name'); $license->last_name = Input::get('last_name'); $license->email = Input::get('email'); $license->transaction_reference = Request::getClientIp(); $license->license_key = Utils::generateLicense(); $license->affiliate_id = $affiliate->id; $license->product_id = PRODUCT_SELF_HOST; $license->is_claimed = 1; $license->save(); return ''; }
/** * @return \Illuminate\Contracts\View\View */ public function do_license_payment() { $testMode = Session::get('test_mode') === 'true'; $rules = ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required', 'card_number' => 'required', 'expiration_month' => 'required', 'expiration_year' => 'required', 'cvv' => 'required', 'address1' => 'required', 'city' => 'required', 'state' => 'required', 'postal_code' => 'required', 'country_id' => 'required']; $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return redirect()->to('license')->withErrors($validator)->withInput(); } $account = $this->accountRepo->getNinjaAccount(); $account->load('account_gateways.gateway'); $accountGateway = $account->getGatewayByType(GATEWAY_TYPE_CREDIT_CARD); try { $affiliate = Affiliate::find(Session::get('affiliate_id')); if ($testMode) { $ref = 'TEST_MODE'; } else { $details = self::getLicensePaymentDetails(Input::all(), $affiliate); $gateway = Omnipay::create($accountGateway->gateway->provider); $gateway->initialize((array) $accountGateway->getConfig()); $response = $gateway->purchase($details)->send(); $ref = $response->getTransactionReference(); if (!$response->isSuccessful() || !$ref) { $this->error('License', $response->getMessage(), $accountGateway); return redirect()->to('license')->withInput(); } } $licenseKey = Utils::generateLicense(); $license = new License(); $license->first_name = Input::get('first_name'); $license->last_name = Input::get('last_name'); $license->email = Input::get('email'); $license->transaction_reference = $ref; $license->license_key = $licenseKey; $license->affiliate_id = Session::get('affiliate_id'); $license->product_id = Session::get('product_id'); $license->save(); $data = ['message' => $affiliate->payment_subtitle, 'license' => $licenseKey, 'hideHeader' => true, 'productId' => $license->product_id, 'price' => $affiliate->price]; $name = "{$license->first_name} {$license->last_name}"; $this->contactMailer->sendLicensePaymentConfirmation($name, $license->email, $affiliate->price, $license->license_key, $license->product_id); if (Session::has('return_url')) { $data['redirectTo'] = Session::get('return_url') . "?license_key={$license->license_key}&product_id=" . Session::get('product_id'); $data['message'] = 'Redirecting to ' . Session::get('return_url'); } return View::make('public.license', $data); } catch (\Exception $e) { $this->error('License-Uncaught', false, $accountGateway, $e); return redirect()->to('license')->withInput(); } }