private function createPayment() { $paymentData = new Registry(['invoice_id' => $this->invoice->id, 'method' => $this->state->get('payment_method'), 'amount' => $this->order->total, 'status' => 'pending', 'customer_payment_information' => $this->order->paymentinfos]); /** @var Sp4kAppsPaymentItem payment */ $this->payment = Sp4kAppsPaymentApp::getInstance($paymentData)->getItem(); $this->process_payment_result = $this->payment->charge(); //$this->ref_id = time(); }
public function execute() { $cartSession = JFactory::getSession(); $cart = ($cart = $cartSession->get('sp4k_cart')) ? $cart : []; $cartTotal = 0; if (count($cart) > 0) { //foreach cart item build the line item for display; $cartApp = Sp4kAppsCartApp::getInstance(new Registry($cart)); $cart_items = $cartApp->getItems(); foreach ($cart_items as $item) { $cartTotal += $item->total; } } $orderData = new stdClass(); $orderData->total = 0; $orderData->created = time(); $orderData->createdby = JFactory::getUser()->id; foreach ($cart_items as $type => $cart_item) { $orderItem = new stdClass(); $orderItem->type = $type; $orderItem->mainline = $cart_item->mainline; $orderItem->sublines = $cart_item->sublines; $orderItem->total = $cart_item->total; $orderData->total += $orderItem->total; $orderData->cart[$type][] = $orderItem; } $orderData->cart = json_encode($orderData->cart); $order = Sp4kAppsOrderApp::getInstance(new Registry($orderData))->getItem()->update(); $this->state->set('order_id', $order->id); $paymentData = new stdClass(); $paymentData->amount = $cartTotal; /** @var Sp4kAppsPaymentItem $payment */ $payment = Sp4kAppsPaymentApp::getInstance(new Registry($this->state->toObject()))->getItem()->charge(); if ($this->error = $payment->getError()) { $order->status = 0; } else { $order->status = '1'; $order->payment_id = $payment->id; } $order->update(); return $this; }
public function getItems() { /** @var Sp4kAppsPaymentApp $app */ $app = Sp4kAppsPaymentApp::getInstance(new Registry($this->state->toObject())); return $app->getItems(); }
private function createPayment() { $paymentData = new Registry(['invoice_id' => $this->invoice->id, 'method' => $this->payment_method, 'amount' => $this->order->due_now]); $this->payment = Sp4kAppsPaymentApp::getInstance($paymentData)->getItem(); }