Adapter/PlentymarketsAdapter/ServiceBus/CommandHandler/Payment/HandlePaymentCommandHandler.php
private function findOrCreatePlentyPayment(Payment $payment)
    {
        $plentyPayments = $this->fetchPlentyPayments($payment);

        if ($plentyPayments) {
            $paymentResult = $plentyPayments[0];
            $this->logger->debug('payment with the same transaction id "' . $paymentResult['id'] . '" already exists.');
        } else {
            $paymentResult = $this->createPlentyPayment($payment);
        }

        $this->identityService->insert(
            $payment->getIdentifier(),
            Payment::TYPE,
            (string) $paymentResult['id'],
            PlentymarketsAdapter::NAME
        );

        return $paymentResult;
    }
private function findOrCreatePlentyPayment(Payment $payment)
    {
        $plentyPayments = $this->fetchPlentyPayments($payment);

        if ($plentyPayments) {
            $paymentResult = $plentyPayments[0];
            $this->logger->debug('payment with the same transaction id "' . $paymentResult['id'] . '" already exists.');
        } else {
            $paymentResult = $this->createPlentyPayment($payment);
        }

        $this->identityService->insert(
            $payment->getIdentifier(),
            Payment::TYPE,
            (string) $paymentResult['id'],
            PlentymarketsAdapter::NAME
        );

        return $paymentResult;
    }
@param Payment $payment

@return array