/** * 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'); }
/** * Creates a payment method. * * @param int $customer_id Customer ID. * * @return void */ public function post_index($customer_id = null) { $customer = $this->get_customer($customer_id); $gateway_args = array('seller' => \Seller::active()); if ($seller_gateway_id = \Input::post('seller_gateway_id')) { $gateway_args['id'] = $seller_gateway_id; } $gateway = \Service_Gateway::find_one($gateway_args); $validator = \Validation_Customer_Paymentmethod::create($gateway); if (!$validator->run()) { throw new HttpBadRequestException($validator->errors()); } $data = $validator->validated(); $payment_method = \Service_Customer_Paymentmethod::create($customer, $gateway, $data); if (!$payment_method) { throw new HttpServerErrorException(); } $this->response($payment_method); }
/** * Attempts to get a seller's primary gateway. * * @return Model_Gateway */ public function get_gateway() { $gateway = Service_Gateway::find_one(array('seller' => Seller::active())); if (!$gateway) { throw new HttpNotFoundException(); } return $gateway; }
/** * Attempts to get a gateway from a given ID. * * @param int $id Gateway ID. * * @return \Model_Gateway */ protected function get_gateway($id) { if (!$id) { throw new HttpNotFoundException(); } $gateway = \Service_Gateway::find_one(array('id' => $id, 'seller' => \Seller::active())); if (!$gateway) { throw new HttpNotFoundException(); } return $gateway; }