/**
  * {@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;
 }
Example #2
0
 /**
  * {@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;
 }
Example #3
0
 /**
  * @return Payment
  */
 public function getPayment()
 {
     if ($identity = $this->getDetails()) {
         return static::$storageRegistry->getStorage($identity->getClass())->find($identity);
     }
 }