getConfirmUrl example

    public function register(Request $request, RequestDataBag $data, SalesChannelContext $context): Response
    {
        if ($context->getCustomer()) {
            return $this->redirectToRoute('frontend.account.home.page');
        }

        try {
            if (!$data->has('differentShippingAddress')) {
                $data->remove('shippingAddress');
            }

            $data->set('storefrontUrl', $this->getConfirmUrl($context$request));

            $data = $this->prepareAffiliateTracking($data$request->getSession());

            if ($data->getBoolean('createCustomerAccount')) {
                $data->set('guest', false);
            } else {
                $data->set('guest', true);
            }

            $this->registerRoute->register(
                $data->toRequestDataBag(),
                
$session = $this->getSession();
        static::assertInstanceOf(Session::class$session);
        $success = $session->getFlashBag()->get('success');

        static::assertNotEmpty($success);
        static::assertEquals($container->get('translator')->trans('account.optInRegistrationAlert')$success[0]);

        static::assertNotEmpty($event);
        static::assertMailEvent(CustomerDoubleOptInRegistrationEvent::class$event$this->salesChannelContext);
        static::assertMailRecipientStructEvent($this->getMailRecipientStruct($data->all())$event);

        static::assertStringEndsWith('&redirectTo=frontend.checkout.confirm.page', $event->getConfirmUrl());
    }

    public function testRegisterWithDoubleOptInDomainChanged(): void
    {
        $container = $this->getContainer();

        /** @var EntityRepository $customerRepository */
        $customerRepository = $container->get('customer.repository');

        $systemConfigService = $this->getContainer()->get(SystemConfigService::class);
        $systemConfigService->set('core.loginRegistration.doubleOptInRegistration', true);
        
$systemConfig->set('core.loginRegistration.doubleOptInRegistration', true);
        $systemConfig->set('core.loginRegistration.confirmationUrl', '/confirm/custom/%%HASHEDEMAIL%%/%%SUBSCRIBEHASH%%');

        /** @var EventDispatcherInterface $dispatcher */
        $dispatcher = $this->getContainer()->get('event_dispatcher');

        $this->addEventListener(
            $dispatcher,
            CustomerConfirmRegisterUrlEvent::class,
            static function DCustomerConfirmRegisterUrlEvent $event): void {
                $event->setConfirmUrl($event->getConfirmUrl());
            }
        );

        $caughtEvent = null;
        $this->addEventListener(
            $dispatcher,
            CustomerDoubleOptInRegistrationEvent::class,
            static function DCustomerDoubleOptInRegistrationEvent $event) use (&$caughtEvent): void {
                $caughtEvent = $event;
            }
        );

        
$response->headers->set(PlatformRequest::HEADER_CONTEXT_TOKEN, $newToken);

        // We don't want to leak the hash in store-api         $customerEntity->setHash('');

        return $response;
    }

    private function getDoubleOptInEvent(CustomerEntity $customer, SalesChannelContext $context, string $url, ?string $redirectTo = null): Event
    {
        $url .= $this->getConfirmUrl($context$customer);

        if ($redirectTo) {
            $url .= '&redirectTo=' . $redirectTo;
        }

        if ($customer->getGuest()) {
            $event = new DoubleOptInGuestOrderEvent($customer$context$url);
        } else {
            $event = new CustomerDoubleOptInRegistrationEvent($customer$context$url);
        }

        


        Feature::triggerDeprecationOrThrow(
            'v6.6.0.0',
            Feature::deprecatedMethodMessage(self::class, __METHOD__, 'v6.6.0.0', 'Use ScalarValuesStorer instead')
        );

        if (!$event instanceof ConfirmUrlAware || isset($stored[ConfirmUrlAware::CONFIRM_URL])) {
            return $stored;
        }

        $stored[ConfirmUrlAware::CONFIRM_URL] = $event->getConfirmUrl();

        return $stored;
    }

    public function restore(StorableFlow $storable): void
    {
        if (Feature::isActive('v6.6.0.0')) {
            return;
        }

        Feature::triggerDeprecationOrThrow(
            
Home | Imprint | This part of the site doesn't use cookies.