withClaim example

$expiration = new \DateTimeImmutable('+10 minutes');
        $shopId = $this->shopIdProvider->getShopId();
        $builder = $configuration
            ->builder()
            ->issuedBy($shopId)
            ->issuedAt(new \DateTimeImmutable())
            ->canOnlyBeUsedAfter(new \DateTimeImmutable())
            ->expiresAt($expiration);

        if (\in_array('sales_channel:read', $privileges, true)) {
            $builder->withClaim('salesChannelId', $context->getSalesChannel()->getId());
        }

        if (\in_array('customer:read', $privileges, true)) {
            $builder->withClaim('customerId', $context->getCustomer()->getId());
        }

        if (\in_array('currency:read', $privileges, true)) {
            $builder->withClaim('currencyId', $context->getCurrency()->getId());
        }

        if (\in_array('language:read', $privileges, true)) {
            
$expires = $expires->modify(
                sprintf('-%d seconds', abs($tokenStruct->getExpires()))
            );
        }

        $jwtToken = $this->configuration->builder()
            ->identifiedBy(Uuid::randomHex())
            ->issuedAt(new \DateTimeImmutable('@' . time()))
            ->canOnlyBeUsedAfter(new \DateTimeImmutable('@' . time()))
            ->expiresAt($expires)
            ->relatedTo($tokenStruct->getTransactionId() ?? '')
            ->withClaim('pmi', $tokenStruct->getPaymentMethodId())
            ->withClaim('ful', $tokenStruct->getFinishUrl())
            ->withClaim('eul', $tokenStruct->getErrorUrl())
            ->getToken($this->configuration->signer()$this->configuration->signingKey());

        $this->write($jwtToken->toString()$expires);

        return $jwtToken->toString();
    }

    public function parseToken(string $token): TokenStruct
    {
        
Home | Imprint | This part of the site doesn't use cookies.