/** * Complete the order after the customer is brought back from the payment provider */ public function FinishOrder() { // Orders are still incomplete, so we need to validate them if($this->pendingData['status'] == ORDER_STATUS_INCOMPLETE) { // Verify the pending order $newStatus = VerifyPendingOrder($this->orderToken); // Order was declined and we're rejecting all declined payments if($newStatus == ORDER_STATUS_DECLINED) { $Msg = sprintf(GetLang('ErroOrderDeclined'), GetConfig('OrderEmail'), GetConfig('OrderEmail')); $this->BadOrder(GetLang('YourPaymentWasDeclined'), $Msg); } // This order is valid elseif($newStatus !== false) { $prodOrdered = array(); $items = getCustomerQuote()->getItems(); foreach($items as $item) { $productId = $item->getProductId(); if($productId > 0) { $prodOrdered[] = $productId; } $_SESSION['ProductJustOrdered'] = implode(',',$prodOrdered); } if(CompletePendingOrder($this->orderToken, $newStatus)) { // Order was saved. Show the confirmation screen and email an invoice to the customer $this->ThanksForYourOrder(); return; } } // If we're still here, either the order didnt complete or the order was invalid $this->BadOrder(); } // Order is already complete - there's a good chance the customer has refreshed the page, // or they've come back from somewhere like PayPal who in the mean time has already sent // us a ping back to validate and begin processing the order - show the thank you page else if($this->pendingData['status'] == ORDER_STATUS_DECLINED) { $Msg = sprintf(GetLang('ErroOrderDeclined'), GetConfig('OrderEmail'), GetConfig('OrderEmail')); $this->BadOrder(GetLang('YourPaymentWasDeclined'), $Msg); } else { $this->ThanksForYourOrder(); return; } }
/** * Complete the order after the customer is brought back from the payment provider */ public function FinishOrder() { $queries = array(); // Orders are still incomplete, so we need to validate them if ($this->pendingData['status'] == 0) { // Verify the pending order $newStatus = VerifyPendingOrder($this->orderToken); // This order is not valid if ($newStatus !== false) { if (CompletePendingOrder($this->orderToken, $newStatus)) { /* $cdate = strtotime(date('Y-m-d')); $edate = strtotime('2010-12-15'); if($cdate <= $edate) {*/ # This condition should be checked dynamically, For static its hardcoded -- Baskaran $this->AddSweepstakes($this->orderToken); // } // Order was saved. Show the confirmation screen and email an invoice to the customer $this->ThanksForYourOrder(); return; } } // If we're still here, something bad has happened to the order // Order was declined and we're rejecting all declined payments if ($newStatus == ORDER_STATUS_DECLINED) { $Msg = sprintf(GetLang('ErroOrderDeclined'), GetConfig('OrderEmail'), GetConfig('OrderEmail')); $this->BadOrder(GetLang('YourPaymentWasDeclined'), $Msg); } else { $this->BadOrder(); } } else { if ($this->pendingData['status'] == ORDER_STATUS_DECLINED) { $Msg = sprintf(GetLang('ErroOrderDeclined'), GetConfig('OrderEmail'), GetConfig('OrderEmail')); $this->BadOrder(GetLang('YourPaymentWasDeclined'), $Msg); } else { $this->ThanksForYourOrder(); return; } } }