/**
  * @throws PaymentException
  * @return PaymentResponseDTO
  */
 public function findDetailsByTransaction(PaymentRequestDTO $paymentRequestDTO)
 {
     $giropayRequest = new GiropayTransactionStatusRequest();
     $additionalFields = $paymentRequestDTO->getAdditionalFields();
     if (!array_key_exists(GiropayConstants::GATEWAY_TRANSACTION_ID, $additionalFields)) {
         throw new InvalidArgumentException("Missing GATEWAY_TRANSACTION_ID parameter");
     }
     $giropayRequest->setReference($additionalFields[GiropayConstants::GATEWAY_TRANSACTION_ID]);
     try {
         $giropayResponse = $this->giropayPaymentService->process($giropayRequest);
         /** @var GiropayTransactionStatusResponse $giropayResponse */
         if (!GiropayResultType::$OK->equals($giropayResponse->getResult())) {
             throw new PaymentException($giropayResponse->getResult()->getType() . '(' . $giropayResponse->getResult()->getFriendlyType() . ')');
         }
     } catch (\Exception $e) {
         throw new PaymentException("Could not query status for payment: " . $e->getMessage(), 0, $e);
     }
     $responseDTO = new PaymentResponseDTO(PaymentType::$THIRD_PARTY_ACCOUNT, GiropayPaymentGatewayType::$GIROPAY);
     $responseDTO->successful(GiropayPaymentResultType::$TRANSACTION_SUCCESSFUL->equals($giropayResponse->getPaymentResult()));
     /* $responseDTO
        ->responseMap(GiropayConstants::HOSTED_REDIRECT_URL, $giropayResponse->getRedirect())
        ->responseMap(GiropayConstants::GATEWAY_TRANSACTION_ID, $giropayResponse->getReference()
        );*/
     return $responseDTO;
 }
 public function testTransactionStatusRequest()
 {
     $request = new GiropayTransactionStatusRequest();
     $request->setReference('1234567890');
     $httpRequest = $this->requestGenerator->buildRequest($this->client, $request);
     $this->assertEquals('POST', $httpRequest->getMethod());
     $this->assertEquals("https://payment.girosolution.de/girocheckout/api/v2/transaction/status", $httpRequest->getUrl());
     $this->assertEquals($httpRequest->getBody()->getField('hash'), "be3341a44020021c0d6b8de95f067e28");
 }
 /**
  * @param ClientInterface $client
  * @param GiropayTransactionStatusRequest $giropayRequest
  * @return RequestInterface
  */
 protected function buildTransactionStatusRequest(ClientInterface $client, GiropayTransactionStatusRequest $giropayRequest)
 {
     $requestArray = array();
     $requestArray['merchantId'] = $this->getMerchantId();
     $requestArray['projectId'] = $this->getProjectId();
     if ($giropayRequest->getReference() == "") {
         throw new InvalidArgumentException("Field reference is required");
     }
     $requestArray['reference'] = $giropayRequest->getReference();
     //this works because the hash list in PHP has a sort order (we get the values out in the order we added them)
     $sortedValuesString = implode('', array_values($requestArray));
     $requestArray['hash'] = $this->getHMACMD5Hash($this->getSecret(), $sortedValuesString);
     $request = $client->createRequest("POST", "https://payment.girosolution.de/girocheckout/api/v2/transaction/status", ['body' => $requestArray]);
     return $request;
 }