Ejemplo n.º 1
0
 /**
  * Generates a unique invoice number
  *
  * @return string
  */
 private function generateInvoiceNumber()
 {
     $invoice_no = 'INV' . mt_rand(100000, 999999);
     $order = Order::where(['invoice_no' => $invoice_no])->get(['invoice_no']);
     if (count($order)) {
         $this->generateInvoiceNumber();
     }
     return $invoice_no;
 }
Ejemplo n.º 2
0
 /**
  * @param Request $request
  * @param Writer  $logger
  * @param         $payFastData
  */
 protected function updateOrderStatus(Request $request, Writer $logger, $payFastData)
 {
     $order = Order::where('invoice_no', $request->input('m_payment_id'))->first();
     switch ($payFastData['payment_status']) {
         case self::STATUS_COMPLETE:
             $logger->debug(self::PAYMENT_STATUS_COMPLETE);
             $order->status = strtolower(self::STATUS_COMPLETE);
             break;
         case self::STATUS_FAILED:
             $logger->error(self::PAYMENT_STATUS_FAILED);
             $order->status = strtolower(self::STATUS_FAILED);
             break;
         case self::STATUS_PENDING:
             $logger->debug(self::PAYMENT_STATUS_PENDING);
             $order->status = strtolower(self::STATUS_PENDING);
             break;
         default:
             $logger->error(self::PAYMENT_STATUS_DEFAULT);
             $order->status = self::ERROR;
             break;
     }
     $order->save();
 }