Пример #1
0
 /**
  * Creates form view for Redsys payment
  *
  * @return \Symfony\Component\Form\FormView
  *
  * @throws PaymentOrderNotFoundException
  */
 public function processPayment()
 {
     $redsysMethod = new RedsysMethod();
     /**
      * At this point, order must be created given a cart, and placed in PaymentBridge
      *
      * So, $this->paymentBridge->getOrder() must return an object
      */
     $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $redsysMethod);
     /**
      * Order Not found Exception must be thrown just here
      */
     if (!$this->paymentBridge->getOrder()) {
         throw new PaymentOrderNotFoundException();
     }
     /**
      * Order exists right here
      */
     $this->paymentEventDispatcher->notifyPaymentOrderCreated($this->paymentBridge, $redsysMethod);
     $formView = $this->redsysFormTypeWrapper->buildForm();
     return $formView;
 }
 /**
  * Test form creation
  */
 public function testFormCreation()
 {
     $amount = 100;
     $formData = array('Ds_Merchant_Amount' => $amount, 'Ds_Merchant_MerchantSignature' => 'CB43B12351A9826D9640CC285CBDFD8CA6A5994C', 'Ds_Merchant_MerchantCode' => $this::merchantCode, 'Ds_Merchant_Currency' => '978', 'Ds_Merchant_Terminal' => $this::terminal, 'Ds_Merchant_Order' => '342', 'Ds_Merchant_MerchantURL' => '/payment/redsys/result', 'Ds_Merchant_UrlOK' => '/payment/redsys/checkout/ok', 'Ds_Merchant_UrlKO' => '/payment/redsys/checkout/ko', 'Ds_Merchant_TransactionType' => $this::transactionType, 'Ds_Merchant_ProductDescription' => $this::prodDesc, 'Ds_Merchant_Titular' => $this::titular, 'Ds_Merchant_MerchantName' => $this::name);
     $this->paymentBridge->expects($this->once())->method('getExtraData')->will($this->returnValue(array('terminal' => $this::terminal, 'transaction_type' => $this::transactionType, 'product_description' => $this::prodDesc, 'merchant_titular' => $this::titular, 'merchant_name' => $this::name)));
     $this->paymentBridge->expects($this->once())->method('getAmount')->will($this->returnValue($amount));
     $this->paymentBridge->expects($this->once())->method('getOrderNumber')->will($this->returnValue('342'));
     $this->paymentBridge->expects($this->once())->method('getCurrency')->will($this->returnValue('EUR'));
     $this->urlFactory->expects($this->once())->method('getReturnUrlOkForOrderId')->will($this->returnValue('/payment/redsys/checkout/ok'));
     $this->urlFactory->expects($this->once())->method('getReturnUrlKoForOrderId')->will($this->returnValue('/payment/redsys/checkout/ko'));
     $this->urlFactory->expects($this->once())->method('getReturnRedsysUrl')->will($this->returnValue('/payment/redsys/result'));
     $formView = $this->redsysFormTypeWrapper->buildForm();
     $children = $formView->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
         $message = $formData[$key] . ':::' . $children[$key]->vars['value'];
         $this->assertEquals($formData[$key], $children[$key]->vars['value'], $message);
     }
 }