captureRecurring example

throw PaymentException::unknownPaymentMethod($transaction->getPaymentMethodId());
        }

        $paymentHandler = $this->paymentHandlerRegistry->getRecurringPaymentHandler($paymentMethod->getId());
        if (!$paymentHandler) {
            throw PaymentException::unknownPaymentMethod($paymentMethod->getHandlerIdentifier());
        }

        $struct = $this->paymentTransactionStructFactory->recurring($transaction$order);

        try {
            $paymentHandler->captureRecurring($struct$context);
        } catch (PaymentException $e) {
            $this->stateHandler->fail($transaction->getId()$context);

            throw $e;
        }
    }
}
$paymentMethodId = $this->getPaymentMethodId('recurring');
        $orderId = $this->createOrder($paymentMethodId);
        $transactionId = $this->createTransaction($orderId$paymentMethodId);

        $response = RecurringPayResponse::create($transactionId[
            'status' => OrderTransactionStates::STATE_PAID,
        ]);

        $this->appendNewResponse($this->signResponse($response->jsonSerialize()));

        $paymentHandler = $this->getContainer()->get(AppPaymentHandler::class);
        $paymentHandler->captureRecurring($this->getRecurringStruct(), Context::createDefaultContext());

        /** @var Request $request */
        $request = $this->getLastRequest();
        $body = $request->getBody()->getContents();

        $appSecret = $this->app->getAppSecret();
        static::assertNotNull($appSecret);

        static::assertTrue($request->hasHeader('shopware-shop-signature'));
        static::assertSame(hash_hmac('sha256', $body$appSecret)$request->getHeaderLine('shopware-shop-signature'));
        static::assertNotEmpty($request->getHeaderLine('sw-version'));
        
Home | Imprint | This part of the site doesn't use cookies.