Example #1
0
 /**
  * Post url update the order status
  *
  * @param SafetypayMethod $paymentMethod
  * @param Array           $postData
  */
 public function confirmPayment(SafetypayMethod $paymentMethod, $postData)
 {
     $this->paymentLogger->setPaymentBundle($paymentMethod->getPaymentName());
     $jsonData = json_encode($postData);
     $this->paymentLogger->log('Response: ' . $jsonData);
     $paymentMethod->setReference($postData['MerchantReferenceNo']);
     $paymentMethod->setRequestDateTime($postData['RequestDateTime']);
     $paymentMethod->setSignature($postData['Signature']);
     $paymentBridge = $this->paymentBridge;
     $signature = $this->getSignature($postData, 'RequestDateTime, MerchantReferenceNo', true);
     if ($postData['ApiKey'] !== '' || $postData['Signature'] !== '') {
         if ($this->key == $postData['ApiKey']) {
             if ($postData['Signature'] == $signature) {
                 $this->eventDispatcher->notifyPaymentOrderLoad($paymentBridge, $paymentMethod);
                 $this->eventDispatcher->notifyPaymentOrderSuccess($paymentBridge, $paymentMethod);
             }
         }
     }
 }
 /**
  * Builds form given success and fail urls
  *
  * @param  String                                                     $successRoute
  * @param  String                                                     $failRoute
  * @param  Integer                                                    $safetyPayTransaction
  * @param  SafetypayMethod                                            $paymentMethod
  * @throws \PaymentSuite\PaymentCoreBundle\Exception\PaymentException
  * @return FormBuilder
  */
 public function buildForm($successRoute, $failRoute, $safetyPayTransaction, SafetypayMethod $paymentMethod)
 {
     $formBuilder = $this->formFactory->createNamedBuilder(null);
     $elements = array('Apikey' => $this->key, 'RequestDateTime' => $this->safetyPayManager->getRequestDateTime(), 'CurrencyCode' => $this->paymentBridge->getCurrency(), 'Amount' => number_format($this->paymentBridge->getAmount() / 100, 2, '.', ''), 'MerchantReferenceNo' => $safetyPayTransaction, 'Language' => 'ES', 'TrackingCode' => '', 'ExpirationTime' => $this->expiration, 'FilterBy' => '', 'TransactionOkURL' => $successRoute, 'TransactionErrorURL' => $failRoute, 'ResponseFormat' => $this->safetyPayManager->getresponseFormat());
     $this->paymentLogger->setPaymentBundle($paymentMethod->getPaymentName());
     $jsonData = json_encode($elements);
     $this->paymentLogger->log('Request: ' . $jsonData);
     $elements['signature'] = $this->safetyPayManager->getSignature($elements, 'CurrencyCode, Amount, MerchantReferenceNo, Language,
         TrackingCode, ExpirationTime, TransactionOkURL,
         TransactionErrorURL');
     $paymentMethod->setRequestDateTime($elements['RequestDateTime']);
     $paymentMethod->setSignature($elements['signature']);
     $urlToken = $this->safetyPayManager->getUrlToken($elements, false);
     //Token no valid
     if (strpos($urlToken, 'Error') > 0) {
         throw new PaymentException();
     }
     $urlTokenExploded = explode('?', $urlToken);
     $urlTokenHost = $urlTokenExploded[0];
     $urlTokenParam = $urlTokenExploded[1];
     $urlTokenParamExploded = explode('=', $urlTokenParam);
     $formBuilder->setAction($urlTokenHost)->setMethod('POST')->add('TokenID', 'hidden', array('data' => $urlTokenParamExploded[1]));
     return $formBuilder;
 }