/**
  * {@inheritDoc}
  */
 public function createToken($paymentName, $model, $targetPath, array $targetParameters = array(), $afterPath = null, array $afterParameters = array())
 {
     /** @var TokenInterface $token */
     $token = $this->tokenStorage->createModel();
     $token->setPaymentName($paymentName);
     if (null !== $model) {
         $token->setDetails($this->storageRegistry->getStorage($model)->getIdentificator($model));
     }
     $targetParameters = array_replace($targetParameters, array('payum_token' => $token->getHash()));
     if (0 === strpos($targetPath, 'http')) {
         if (false !== strpos($targetPath, '?')) {
             $targetPath .= '&' . http_build_query($targetParameters);
         } else {
             $targetPath .= '?' . http_build_query($targetParameters);
         }
         $token->setTargetUrl($targetPath);
     } else {
         $token->setTargetUrl($this->generateUrl($targetPath, $targetParameters));
     }
     if ($afterPath && 0 === strpos($afterPath, 'http')) {
         if (false !== strpos($afterPath, '?')) {
             $afterPath .= '&' . http_build_query($afterParameters);
         } else {
             $afterPath .= '?' . http_build_query($afterParameters);
         }
         $token->setAfterUrl($afterPath);
     } elseif ($afterPath) {
         $token->setAfterUrl($this->generateUrl($afterPath, $afterParameters));
     }
     $this->tokenStorage->updateModel($token);
     return $token;
 }