Adapter/ShopwareAdapter/ResponseParser/Payment/PaymentResponseParser.php
public function parse(array $element)
    {
        $paymentIdentifier = $this->identityService->findOneOrCreate(
            (string) $element['id'],
            ShopwareAdapter::NAME,
            Payment::TYPE
        );

        $isMappedPaymentIdentity = $this->identityService->isMappedIdentity(
            $paymentIdentifier->getObjectIdentifier(),
            $paymentIdentifier->getObjectType(),
            $paymentIdentifier->getAdapterName()
        );

        if ($isMappedPaymentIdentity) {
            $this->logger->notice('paymentidentity' . $paymentIdentifier->getObjectIdentifier() . ' ist not mapped');

            return [];
        }

        if (empty($element['paymentStatus'])) {
            return [];
        }

        if (Status::PAYMENT_STATE_COMPLETELY_PAID !== $element['paymentStatus']['id']) {
            return [];
        }

        if (empty($element['transactionId'])) {
            $element['transactionId'] = $paymentIdentifier->getObjectIdentifier();
        }

        $shopIdentity = $this->identityService->findOneOrThrow(
            (string) $element['shopId'],
            ShopwareAdapter::NAME,
            Shop::TYPE
        );

        $isMappedShopIdentity = $this->identityService->isMappedIdentity(
            $shopIdentity->getObjectIdentifier(),
            $shopIdentity->getObjectType(),
            $shopIdentity->getAdapterName()
        );

        if (!$isMappedShopIdentity) {
            $this->logger->warning('shopidentity' . $shopIdentity->getObjectIdentifier() . ' ist not mapped');

            return [];
        }

        $shopwareCurrencyIdentifier = $this->currencyDataProvider->getCurrencyIdentifierByCode($element['currency']);
        $currencyIdentifier = $this->getConnectorIdentifier($shopwareCurrencyIdentifier, Currency::TYPE);

        $payment = new Payment();
        $payment->setIdentifier($paymentIdentifier->getObjectIdentifier());
        $payment->setShopIdentifier($shopIdentity->getObjectIdentifier());
        $payment->setOrderIdentifer($this->getConnectorIdentifier($element['id'], Order::TYPE));
        $payment->setAmount($element['invoiceAmount']);
        $payment->setAccountHolder($this->getAccountHolder($element));
        $payment->setCurrencyIdentifier($currencyIdentifier);
        $payment->setPaymentMethodIdentifier($this->getConnectorIdentifier($element['paymentId'], PaymentMethod::TYPE));
        $payment->setTransactionReference($element['transactionId']);

        return [$payment];
    }
public function parse(array $element)
    {
        $paymentIdentifier = $this->identityService->findOneOrCreate(
            (string) $element['id'],
            ShopwareAdapter::NAME,
            Payment::TYPE
        );

        $isMappedPaymentIdentity = $this->identityService->isMappedIdentity(
            $paymentIdentifier->getObjectIdentifier(),
            $paymentIdentifier->getObjectType(),
            $paymentIdentifier->getAdapterName()
        );

        if ($isMappedPaymentIdentity) {
            $this->logger->notice('paymentidentity' . $paymentIdentifier->getObjectIdentifier() . ' ist not mapped');

            return [];
        }

        if (empty($element['paymentStatus'])) {
            return [];
        }

        if (Status::PAYMENT_STATE_COMPLETELY_PAID !== $element['paymentStatus']['id']) {
            return [];
        }

        if (empty($element['transactionId'])) {
            $element['transactionId'] = $paymentIdentifier->getObjectIdentifier();
        }

        $shopIdentity = $this->identityService->findOneOrThrow(
            (string) $element['shopId'],
            ShopwareAdapter::NAME,
            Shop::TYPE
        );

        $isMappedShopIdentity = $this->identityService->isMappedIdentity(
            $shopIdentity->getObjectIdentifier(),
            $shopIdentity->getObjectType(),
            $shopIdentity->getAdapterName()
        );

        if (!$isMappedShopIdentity) {
            $this->logger->warning('shopidentity' . $shopIdentity->getObjectIdentifier() . ' ist not mapped');

            return [];
        }

        $shopwareCurrencyIdentifier = $this->currencyDataProvider->getCurrencyIdentifierByCode($element['currency']);
        $currencyIdentifier = $this->getConnectorIdentifier($shopwareCurrencyIdentifier, Currency::TYPE);

        $payment = new Payment();
        $payment->setIdentifier($paymentIdentifier->getObjectIdentifier());
        $payment->setShopIdentifier($shopIdentity->getObjectIdentifier());
        $payment->setOrderIdentifer($this->getConnectorIdentifier($element['id'], Order::TYPE));
        $payment->setAmount($element['invoiceAmount']);
        $payment->setAccountHolder($this->getAccountHolder($element));
        $payment->setCurrencyIdentifier($currencyIdentifier);
        $payment->setPaymentMethodIdentifier($this->getConnectorIdentifier($element['paymentId'], PaymentMethod::TYPE));
        $payment->setTransactionReference($element['transactionId']);

        return [$payment];
    }
{@inheritdoc}