syncProcessInterrupted example

use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
use Shopware\Core\System\SalesChannel\SalesChannelContext;

/** * @internal */
#[Package('checkout')] class SyncTestFailedPaymentHandler implements SynchronousPaymentHandlerInterface
{
    public function pay(SyncPaymentTransactionStruct $transaction, RequestDataBag $dataBag, SalesChannelContext $salesChannelContext): void
    {
        throw PaymentException::syncProcessInterrupted($transaction->getOrderTransaction()->getId(), 'This is a TestPaymentHandler which will always fail');
    }
}
public function pay(SyncPaymentTransactionStruct $transaction, RequestDataBag $dataBag, SalesChannelContext $salesChannelContext): void
    {
        $payUrl = $this->getAppPaymentMethod($transaction->getOrderTransaction())->getPayUrl();
        if (empty($payUrl)) {
            return;
        }

        $payload = $this->buildPayload($transaction$dataBag->all());

        $app = $this->getAppPaymentMethod($transaction->getOrderTransaction())->getApp();
        if ($app === null) {
            throw PaymentException::syncProcessInterrupted($transaction->getOrderTransaction()->getId(), 'App not defined');
        }

        try {
            $response = $this->payloadService->request($payUrl$payload$app, SyncPayResponse::class$salesChannelContext->getContext());
        } catch (ClientExceptionInterface $exception) {
            throw PaymentException::asyncProcessInterrupted($transaction->getOrderTransaction()->getId()sprintf('App error: %s', $exception->getMessage()));
        }

        if (!$response instanceof SyncPayResponse) {
            throw PaymentException::syncProcessInterrupted($transaction->getOrderTransaction()->getId(), 'Invalid app response');
        }

        
Home | Imprint | This part of the site doesn't use cookies.