public function processCheckoutForm($data) { $orderID = $data['order_id']; $amount = $data['amount']; $order = Order::getByID($orderID); // get or make user account $u = new User(); $userExists = $u->isLoggedIn(); if (!$userExists) { $ui = $this->addUserAccount($data); } else { $ui = UserInfo::getByID($u->getUserID()); } // save user field data foreach ($data['akID'] as $key => $value) { Field::update($key, $value['value'], 'user'); } // process payment $payment_type = $data['payment_type']; $payment_method = PaymentMethod::getByHandle($payment_type); $charge = $payment_method->process($order, $ui, $data); // record payment $typeReference = json_encode($charge); Payment::add($orderID, $payment_type, $amount, $typeReference); // update order status $order = Order::getByID($orderID); $order->updateStatus('checkout_complete'); // redirect user to finish page return true; }
public function save() { $page = Page::getByPath('/dashboard/razor/payment'); $this->set('page', $page); if (!$this->post()) { $this->redirect('/dashboard/razor/payment'); } $data = $this->post(); foreach ($this->fields as $field) { $value = $data['akID'][$field->id]; Field::update($field->id, $value['value'], 'collection', $page); } $this->redirect('/dashboard/razor/payment'); }
public function save() { $sp = Page::getByPath('/dashboard/razor/shipping'); $this->set('page', $sp); // save user field data if (!$this->post()) { $this->redirect('/dashboard/razor/shipping'); } $data = $this->post(); foreach ($this->fields as $field) { $value = $data['akID'][$field->id]; Field::update($field->id, $value['value'], 'collection', $sp); } $this->redirect('/dashboard/razor/shipping'); }