コード例 #1
0
 /**
  * Builds form given return, success and fail urls.
  *
  * @return FormView
  */
 public function buildForm()
 {
     $orderId = $this->paymentBridge->getOrderId();
     $extraData = $this->paymentBridge->getExtraData();
     $formBuilder = $this->formFactory->createNamedBuilder(null);
     if (array_key_exists('transaction_type', $extraData)) {
         $Ds_Merchant_TransactionType = $extraData['transaction_type'];
     } else {
         $Ds_Merchant_TransactionType = '0';
     }
     /**
      * Creates the return route for Redsys.
      */
     $Ds_Merchant_MerchantURL = $this->urlFactory->getReturnRedsysUrl();
     /**
      * Creates the return route, when coming back
      * from Redsys web checkout and proccess is Ok.
      */
     $Ds_Merchant_UrlOK = $this->urlFactory->getReturnUrlOkForOrderId($orderId);
     /**
      * Creates the cancel payment route, when coming back
      * from Redsys web checkout and proccess is error.
      */
     $Ds_Merchant_UrlKO = $this->urlFactory->getReturnUrlKoForOrderId($orderId);
     /**
      * Creates the merchant signature.
      */
     $Ds_Merchant_Amount = $this->paymentBridge->getAmount();
     $Ds_Merchant_Order = $this->formatOrderNumber($this->paymentBridge->getOrderNumber());
     $Ds_Merchant_MerchantCode = $this->merchantCode;
     $Ds_Merchant_Currency = $this->getCurrencyCodeByIso($this->paymentBridge->getCurrency());
     $Ds_Merchant_MerchantSignature = $this->shopSignature($Ds_Merchant_Amount, $Ds_Merchant_Order, $Ds_Merchant_MerchantCode, $Ds_Merchant_Currency, $Ds_Merchant_TransactionType, $Ds_Merchant_MerchantURL, $this->secretKey);
     $Ds_Merchant_Terminal = $extraData['terminal'];
     $formBuilder->setAction($this->url)->setMethod('POST')->add('Ds_Merchant_Amount', 'hidden', ['data' => $Ds_Merchant_Amount])->add('Ds_Merchant_MerchantSignature', 'hidden', ['data' => $Ds_Merchant_MerchantSignature])->add('Ds_Merchant_MerchantCode', 'hidden', ['data' => $this->merchantCode])->add('Ds_Merchant_Currency', 'hidden', ['data' => $Ds_Merchant_Currency])->add('Ds_Merchant_Terminal', 'hidden', ['data' => $Ds_Merchant_Terminal])->add('Ds_Merchant_Order', 'hidden', ['data' => $Ds_Merchant_Order])->add('Ds_Merchant_MerchantURL', 'hidden', ['data' => $Ds_Merchant_MerchantURL])->add('Ds_Merchant_UrlOK', 'hidden', ['data' => $Ds_Merchant_UrlOK])->add('Ds_Merchant_UrlKO', 'hidden', ['data' => $Ds_Merchant_UrlKO]);
     /**
      * Optional form fields.
      */
     if (array_key_exists('transaction_type', $extraData)) {
         $formBuilder->add('Ds_Merchant_TransactionType', 'hidden', ['data' => $Ds_Merchant_TransactionType]);
     }
     if (array_key_exists('product_description', $extraData)) {
         $formBuilder->add('Ds_Merchant_ProductDescription', 'hidden', ['data' => $extraData['product_description']]);
     }
     if (array_key_exists('merchant_titular', $extraData)) {
         $formBuilder->add('Ds_Merchant_Titular', 'hidden', ['data' => $extraData['merchant_titular']]);
     }
     if (array_key_exists('merchant_name', $extraData)) {
         $formBuilder->add('Ds_Merchant_MerchantName', 'hidden', ['data' => $extraData['merchant_name']]);
     }
     if (array_key_exists('merchant_data', $extraData)) {
         $formBuilder->add('Ds_Merchant_MerchantData', 'hidden', ['data' => $extraData['merchant_data']]);
     }
     return $formBuilder->getForm()->createView();
 }
コード例 #2
0
 /**
  * Builds form given return, success and fail urls
  *
  * @return \Symfony\Component\Form\FormView
  */
 public function buildForm()
 {
     $orderId = $this->paymentBridge->getOrderId();
     $extraData = $this->paymentBridge->getExtraData();
     $formBuilder = $this->formFactory->createNamedBuilder(null);
     if (array_key_exists('transaction_type', $extraData)) {
         $Ds_Merchant_TransactionType = $extraData['transaction_type'];
     } else {
         $Ds_Merchant_TransactionType = '0';
     }
     /*
      * Creates the return route for Redsys
      */
     $Ds_Merchant_MerchantURL = $this->urlFactory->getReturnRedsysUrl($orderId);
     /*
      * Creates the return route, when coming back
      * from Redsys web checkout and proccess is Ok
      */
     $Ds_Merchant_UrlOK = $this->urlFactory->getReturnUrlOkForOrderId($orderId);
     /*
      * Creates the cancel payment route, when coming back
      * from Redsys web checkout and proccess is error
      */
     $Ds_Merchant_UrlKO = $this->urlFactory->getReturnUrlKoForOrderId($orderId);
     $Ds_Merchant_Amount = $this->paymentBridge->getAmount();
     $Ds_Merchant_Order = $this->formatOrderNumber($this->paymentBridge->getOrderNumber());
     $Ds_Merchant_MerchantCode = $this->merchantCode;
     $Ds_Merchant_Currency = $this->currencyTranslation($this->paymentBridge->getCurrency());
     $Ds_Merchant_Terminal = $extraData['terminal'];
     $merchantParameters = [];
     $merchantParameters['DS_MERCHANT_AMOUNT'] = $Ds_Merchant_Amount;
     $merchantParameters['DS_MERCHANT_MERCHANTCODE'] = $Ds_Merchant_MerchantCode;
     $merchantParameters['DS_MERCHANT_CURRENCY'] = $Ds_Merchant_Currency;
     $merchantParameters['DS_MERCHANT_TERMINAL'] = $Ds_Merchant_Terminal;
     $merchantParameters['DS_MERCHANT_ORDER'] = $Ds_Merchant_Order;
     $merchantParameters['DS_MERCHANT_MERCHANTURL'] = $Ds_Merchant_MerchantURL;
     $merchantParameters['DS_MERCHANT_URLOK'] = $Ds_Merchant_UrlOK;
     $merchantParameters['DS_MERCHANT_URLKO'] = $Ds_Merchant_UrlKO;
     $merchantParameters['DS_MERCHANT_TRANSACTIONTYPE'] = $Ds_Merchant_TransactionType;
     if (array_key_exists('product_description', $extraData)) {
         $merchantParameters['DS_MERCHANT_PRODUCTDESCRIPTION'] = $extraData['product_description'];
     }
     if (array_key_exists('merchant_titular', $extraData)) {
         $merchantParameters['DS_MERCHANT_TITULAR'] = $extraData['merchant_titular'];
     }
     if (array_key_exists('merchant_name', $extraData)) {
         $merchantParameters['DS_MERCHANT_MERCHANTNAME'] = $extraData['merchant_name'];
     }
     if (array_key_exists('merchant_data', $extraData)) {
         $merchantParameters['DS_MERCHANT_MERCHANTDATA'] = $extraData['merchant_data'];
     }
     $merchantParameters = base64_encode(json_encode($merchantParameters));
     $Ds_Merchant_MerchantSignature = $this->redsysSignature->sign($Ds_Merchant_Order, $this->secretKey, $merchantParameters);
     $formBuilder->setAction($this->url)->setMethod('POST')->add('DS_MERCHANTPARAMETERS', 'hidden', array('data' => $merchantParameters))->add('DS_SIGNATUREVERSION', 'hidden', array('data' => $this->redsysSignature->getSignatureVersion()))->add('DS_SIGNATURE', 'hidden', array('data' => $Ds_Merchant_MerchantSignature));
     return $formBuilder->getForm()->createView();
 }
コード例 #3
0
 /**
  * Builds form given return, success and fail urls
  *
  * @return \Symfony\Component\Form\FormView
  */
 public function buildForm()
 {
     $orderId = $this->paymentBridge->getOrderId();
     $extraData = $this->paymentBridge->getExtraData();
     $formBuilder = $this->formFactory->createNamedBuilder(null);
     if (array_key_exists('transaction_type', $extraData)) {
         $Ds_Merchant_TransactionType = $extraData['transaction_type'];
     } else {
         $Ds_Merchant_TransactionType = '0';
     }
     /*
      * Creates the return route for Redsys
      */
     $Ds_Merchant_MerchantURL = $this->urlFactory->getReturnRedsysUrl();
     /*
      * Creates the return route, when coming back
      * from Redsys web checkout and proccess is Ok
      */
     $Ds_Merchant_UrlOK = $this->urlFactory->getReturnUrlOkForOrderId($orderId);
     /*
      * Creates the cancel payment route, when coming back
      * from Redsys web checkout and proccess is error
      */
     $Ds_Merchant_UrlKO = $this->urlFactory->getReturnUrlKoForOrderId($orderId);
     $Ds_Merchant_Amount = $this->paymentBridge->getAmount();
     $Ds_Merchant_Order = $this->formatOrderNumber($this->paymentBridge->getOrderNumber());
     $Ds_Merchant_MerchantCode = $this->merchantCode;
     $Ds_Merchant_Terminal = $this->merchantTerminal;
     $Ds_Merchant_Currency = $this->currencyTranslation($this->paymentBridge->getCurrency());
     $Ds_Signature_version = "HMAC_SHA256_V1";
     $this->setParameter("DS_MERCHANT_AMOUNT", $Ds_Merchant_Amount);
     $this->setParameter("DS_MERCHANT_ORDER", $Ds_Merchant_Order);
     $this->setParameter("DS_MERCHANT_MERCHANTCODE", $Ds_Merchant_MerchantCode);
     $this->setParameter("DS_MERCHANT_CURRENCY", $Ds_Merchant_Currency);
     $this->setParameter("DS_MERCHANT_TERMINAL", $Ds_Merchant_Terminal);
     $this->setParameter("DS_MERCHANT_TRANSACTIONTYPE", $Ds_Merchant_TransactionType);
     if (array_key_exists('product_description', $extraData)) {
         $this->setParameter("Ds_Merchant_ProductDescription", $extraData['product_description']);
     }
     if (array_key_exists('merchant_titular', $extraData)) {
         $this->setParameter("Ds_Merchant_Titular", $extraData['merchant_titular']);
     }
     if (array_key_exists('merchant_name', $extraData)) {
         $this->setParameter("Ds_Merchant_MerchantName", $extraData['merchant_name']);
     }
     $this->setParameter("DS_MERCHANT_MERCHANTURL", $Ds_Merchant_MerchantURL);
     $this->setParameter("DS_MERCHANT_URLOK", $Ds_Merchant_UrlOK);
     $this->setParameter("DS_MERCHANT_URLKO", $Ds_Merchant_UrlKO);
     $Ds_Merchant_MerchantSignature = $this->shopSignature($Ds_Merchant_Order, $this->secretKey);
     $formBuilder->setAction($this->url)->setMethod('POST')->add('Ds_SignatureVersion', 'hidden', array("data" => $Ds_Signature_version))->add('Ds_MerchantParameters', 'hidden', array("data" => $this->merchantParams()))->add('Ds_Signature', 'hidden', array("data" => $Ds_Merchant_MerchantSignature));
     return $formBuilder->getForm()->createView();
 }