getError() 공개 메소드

public getError ( )
 /**
  * Behaviour can be overwritten by creating a processPaymentResponse method
  * on the controller owning this form. It takes a Symfony\Component\HttpFoundation\Response argument,
  * and expects an SS_HTTPResponse in return.
  */
 public function submitpayment($data, $form)
 {
     $data = $form->getData();
     if ($this->getSuccessLink()) {
         $data['returnUrl'] = $this->getSuccessLink();
     }
     $data['cancelUrl'] = $this->getFailureLink() ? $this->getFailureLink() : $this->controller->Link();
     $order = $this->config->getOrder();
     // final recalculation, before making payment
     $order->calculate();
     // handle cases where order total is 0. Note that the order will appear
     // as "paid", but without a Payment record attached.
     if ($order->GrandTotal() == 0 && Order::config()->allow_zero_order_total) {
         if (!$this->orderProcessor->placeOrder()) {
             $form->sessionMessage($this->orderProcessor->getError());
             return $this->controller->redirectBack();
         }
         return $this->controller->redirect($this->getSuccessLink());
     }
     // try to place order before payment, if configured
     if (Order::config()->place_before_payment) {
         if (!$this->orderProcessor->placeOrder()) {
             $form->sessionMessage($this->orderProcessor->getError());
             return $this->controller->redirectBack();
         }
         $data['cancelUrl'] = $this->orderProcessor->getReturnUrl();
     }
     // if we got here from checkoutSubmit and there's a namespaced OnsitePaymentCheckoutComponent
     // in there, we need to strip the inputs down to only the checkout component.
     $components = $this->config->getComponents();
     if ($components->first() instanceof CheckoutComponent_Namespaced) {
         foreach ($components as $component) {
             if ($component->Proxy() instanceof OnsitePaymentCheckoutComponent) {
                 $data = $component->unnamespaceData($data);
             }
         }
     }
     // This is where the payment is actually attempted
     $paymentResponse = $this->orderProcessor->makePayment(Checkout::get($order)->getSelectedPaymentMethod(false), $data);
     $response = null;
     if ($paymentResponse) {
         if ($this->controller->hasMethod('processPaymentResponse')) {
             $response = $this->controller->processPaymentResponse($paymentResponse, $form);
         } else {
             if ($paymentResponse->isRedirect() || $paymentResponse->isSuccessful()) {
                 $response = $paymentResponse->redirect();
             } else {
                 $form->sessionMessage($paymentResponse->getMessage(), 'bad');
                 $response = $this->controller->redirectBack();
             }
         }
     } else {
         $form->sessionMessage($this->orderProcessor->getError(), 'bad');
         $response = $this->controller->redirectBack();
     }
     return $response;
 }
예제 #2
0
 /**
  * Behaviour can be overwritten by creating a processPaymentResponse method
  * on the controller owning this form. It takes a Symfony\Component\HttpFoundation\Response argument,
  * and expects an SS_HTTPResponse in return.
  */
 public function submitpayment($data, $form)
 {
     $data = $form->getData();
     if ($this->getSuccessLink()) {
         $data['returnUrl'] = $this->getSuccessLink();
     }
     $data['cancelUrl'] = $this->getFailureLink() ? $this->getFailureLink() : $this->controller->Link();
     $order = $this->config->getOrder();
     //final recalculation, before making payment
     $order->calculate();
     //handle cases where order total is 0. Note that the order will appear
     //as "paid", but without a Payment record attached.
     if ($order->GrandTotal() == 0 && Order::config()->allow_zero_order_total) {
         if (!$this->orderProcessor->placeOrder()) {
             $form->sessionMessage($this->orderProcessor->getError());
             return $this->controller->redirectBack();
         }
         return $this->controller->redirect($this->getSuccessLink());
     }
     //try to place order before payment, if configured
     if (Order::config()->place_before_payment) {
         if (!$this->orderProcessor->placeOrder()) {
             $form->sessionMessage($this->orderProcessor->getError());
             return $this->controller->redirectBack();
         }
         $data['cancelUrl'] = $this->orderProcessor->getReturnUrl();
     }
     $paymentResponse = $this->orderProcessor->makePayment(Checkout::get($order)->getSelectedPaymentMethod(false), $data);
     $response = null;
     if ($paymentResponse) {
         if ($this->controller->hasMethod('processPaymentResponse')) {
             $response = $this->controller->processPaymentResponse($paymentResponse, $form);
         } else {
             if ($paymentResponse->isRedirect() || $paymentResponse->isSuccessful()) {
                 $response = $paymentResponse->redirect();
             } else {
                 $form->sessionMessage($paymentResponse->getMessage(), 'bad');
                 $response = $this->controller->redirectBack();
             }
         }
     } else {
         $form->sessionMessage($this->orderProcessor->getError(), 'bad');
         $response = $this->controller->redirectBack();
     }
     return $response;
 }