Beispiel #1
0
 /**
  * {@inheritDoc}
  *
  * @param $request Notify
  */
 public function execute($request)
 {
     if (!$this->supports($request)) {
         throw RequestNotSupportedException::createActionNotSupported($this, $request);
     }
     $this->payment->execute($httpRequest = new GetHttpRequest());
     $details = $httpRequest->query;
     if (!$this->api->verifyHash($details)) {
         throw new BadRequestHttpException('Hash cannot be verified.');
     }
     if (empty($details['ORDERID'])) {
         throw new BadRequestHttpException('Order id cannot be guessed');
     }
     $payment = $this->paymentRepository->findOneBy(array($this->identifier => $details['ORDERID']));
     if (null === $payment) {
         throw new BadRequestHttpException('Payment cannot be retrieved.');
     }
     if ((int) $details['AMOUNT'] !== $payment->getAmount()) {
         throw new BadRequestHttpException('Request amount cannot be verified against payment amount.');
     }
     // Actually update payment details
     $details = array_merge($payment->getDetails(), $details);
     $payment->setDetails($details);
     $status = new GetStatus($payment);
     $this->payment->execute($status);
     $nextState = $status->getValue();
     $this->updatePaymentState($payment, $nextState);
     $this->objectManager->flush();
     throw new HttpResponse(new Response('OK', 200));
 }
Beispiel #2
0
 /**
  * {@inheritDoc}
  *
  * @param $request Notify
  */
 public function execute($request)
 {
     RequestNotSupportedException::assertSupports($this, $request);
     $details = ArrayObject::ensureArrayObject($request->getModel());
     $this->gateway->execute($httpRequest = new GetHttpRequest());
     if (false == $this->api->verifyHash($httpRequest->query)) {
         throw new HttpResponse('The notification is invalid. Code 1', 400);
     }
     if ($details['AMOUNT'] != $httpRequest->query['AMOUNT']) {
         throw new HttpResponse('The notification is invalid. Code 2', 400);
     }
     $details->replace($httpRequest->query);
     throw new HttpResponse('OK', 200);
 }
Beispiel #3
0
 /**
  * @test
  */
 public function shouldReturnTrueIfHashesMatched()
 {
     $params = array('foo' => 'fooVal', 'bar' => 'barVal');
     $api = new Api(array('identifier' => 'anId', 'password' => 'aPass', 'sandbox' => true), $this->createHttpClientMock(), $this->createHttpMessageFactory());
     $params['HASH'] = $api->calculateHash($params);
     $this->assertTrue($api->verifyHash($params));
 }