/** * {@inheritDoc} */ public function createToken($gatewayName, $model, $targetPath, array $targetParameters = [], $afterPath = null, array $afterParameters = []) { /** @var TokenInterface $token */ $token = $this->tokenStorage->create(); $token->setHash($token->getHash() ?: Random::generateToken()); $targetParameters = array_replace(['payum_token' => $token->getHash()], $targetParameters); $token->setGatewayName($gatewayName); if ($model instanceof IdentityInterface) { $token->setDetails($model); } elseif (null !== $model) { $token->setDetails($this->storageRegistry->getStorage($model)->identify($model)); } if (0 === strpos($targetPath, 'http')) { $targetUri = HttpUri::createFromString($targetPath); $targetUri = $this->addQueryToUri($targetUri, $targetParameters); $token->setTargetUrl((string) $targetUri); } else { $token->setTargetUrl($this->generateUrl($targetPath, $targetParameters)); } if ($afterPath && 0 === strpos($afterPath, 'http')) { $afterUri = HttpUri::createFromString($afterPath); $afterUri = $this->addQueryToUri($afterUri, $afterParameters); $token->setAfterUrl((string) $afterUri); } elseif ($afterPath) { $token->setAfterUrl($this->generateUrl($afterPath, $afterParameters)); } $this->tokenStorage->update($token); return $token; }