2015-05-18 43 views
0

我試圖實現JSMPayment和EtsPaymentOgoneBundle沒有成功。jsmPayment etsPaymentOgone給我一個錯誤控制器必須返回一個響應

我得到錯誤:「控制器必須返回響應」。我同意這一點,但它是如此寫在文檔中。所以我錯了,或者它是文檔中的錯誤/錯誤。

該錯誤可能是這一點,但它是這麼寫的文檔...

return array(
      'form' => $form->createView() 
     ); 

現在,如果我改變這一行並返回到樹枝模板,我只得到一個單選按鈕。爲什麼?

任何幫助都會幫助我,因爲我真的迷路了。

我的所有控制器

/** 
* 
*/ 
class PaymentController extends Controller 
{ 
    /** @DI\Inject */ 
    private $request; 

    /** @DI\Inject */ 
    private $router; 

    /** @DI\Inject("doctrine.orm.entity_manager") */ 
    private $em; 

    /** @DI\Inject("payment.plugin_controller") */ 
    private $ppc; 


    /** 
    * 
    * @param \CTC\Bundle\OrderBundle\Controller\Order $order 
    * @return RedirectResponse 
    */ 
    public function detailsAction(Order $order, Request $request) 
    { 

     $form = $this->getFormFactory()->create('jms_choose_payment_method', null, array(
      'amount' => $order->getPackage()->getAmount(), 
      'currency' => 'EUR', 
      'default_method' => 'ogone_gateway', // Optional 
      'predefined_data' => array(
       'ogone_gateway' => array(
        'tp' => '',   // Optional 
        'PM' => $pm,           // Optional - Example value: "CreditCard" - Note: You can consult the list of PM values on Ogone documentation 
        'BRAND' => $brand,          // Optional - Example value: "VISA" - Note: If you send the BRAND field without sending a value in the PM field (‘CreditCard’ or ‘Purchasing Card’), the BRAND value will not be taken into account. 
        'CN' => $billingAddress->getFullName(),     // Optional 
        'EMAIL' => $this->getUser()->getEmail(),   // Optional 
        'OWNERZIP' => $billingAddress->getPostalCode(),   // Optional 
        'OWNERADDRESS' => $billingAddress->getStreetLine(),  // Optional 
        'OWNERCTY' => $billingAddress->getCountry()->getName(), // Optional 
        'OWNERTOWN' => $billingAddress->getCity(),    // Optional 
        'OWNERTELNO' => $billingAddress->getPhoneNumber(),  // Optional 
        'lang'  => $request->getLocale(),     // 5 characters maximum, for e.g: fr_FR 
        'ORDERID' => '123456',        // Optional, 30 characters maximum 
       ), 
      ), 
     )); 

     if ('POST' === $this->request->getMethod()) { 
      $form->bindRequest($this->request); 

      if ($form->isValid()) { 
       $this->ppc->createPaymentInstruction($instruction = $form->getData()); 

       $order->setPaymentInstruction($instruction); 
       $this->em->persist($order); 
       $this->em->flush($order); 

       return new RedirectResponse($this->router->generate('payment_complete', array(
        'orderNumber' => $order->getOrderNumber(), 
       ))); 
      } 
     } 

     return array(
      'form' => $form->createView() 
     ); 
    } 

    /** 
    * 
    */ 
    public function completeAction(Order $order) 
    { 
     $instruction = $order->getPaymentInstruction(); 
     if (null === $pendingTransaction = $instruction->getPendingTransaction()) { 
      $payment = $this->ppc->createPayment($instruction->getId(), $instruction->getAmount() - $instruction->getDepositedAmount()); 
     } else { 
      $payment = $pendingTransaction->getPayment(); 
     } 

     $result = $this->ppc->approveAndDeposit($payment->getId(), $payment->getTargetAmount()); 
     if (Result::STATUS_PENDING === $result->getStatus()) { 
      $ex = $result->getPluginException(); 

      if ($ex instanceof ActionRequiredException) { 
       $action = $ex->getAction(); 

       if ($action instanceof VisitUrl) { 
        return new RedirectResponse($action->getUrl()); 
       } 

       throw $ex; 
      } 
     } else if (Result::STATUS_SUCCESS !== $result->getStatus()) { 
      throw new \RuntimeException('Transaction was not successful: '.$result->getReasonCode()); 
     } 

     // payment was successful, do something interesting with the order 
    } 

    public function cancelAction(Order $order) 
    { 
     die('cancel the payment'); 
    } 

    /** @DI\LookupMethod("form.factory") */ 
    protected function getFormFactory() { } 
} 

回答

0

如果使用

return array(
    'form' => $form->createView() 
); 

在控制器,那麼你應該@Template標註添加到控制器動作

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; 

class PaymentController extends Controller 
{ 
... 
     /** 
     * 
     * @param \CTC\Bundle\OrderBundle\Controller\Order $order 
     * @Template() 
     * @return RedirectResponse 
     */ 
     public function detailsAction(Order $order, Request $request) 

,或者你應該返回用模板「渲染」

return $this->render('MyAppSomeBundle:Payment:details.html.twig', array('form' => $form->createView()); 
+0

我不知道。 symfo中的新增內容我謝謝你 ! –

相關問題