Exemple #1
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;
 }
 public function createAction($content)
 {
     $form = $this->formFactory->create('payum_gateway_config', null, ['data_class' => GatewayConfig::class, 'csrf_protection' => false]);
     $form->submit($content);
     if ($form->isValid()) {
         /** @var GatewayConfigInterface $gatewayConfig */
         $gatewayConfig = $form->getData();
         $this->gatewayConfigStorage->update($gatewayConfig);
         $getUrl = $this->urlGenerator->generate('gateway_get', array('name' => $gatewayConfig->getGatewayName()), $absolute = true);
         return new JsonResponse(array('gateway' => $this->gatewayConfigToJsonConverter->convert($gatewayConfig)), 201, array('Location' => $getUrl));
     }
     return new JsonResponse($this->formToJsonConverter->convertInvalid($form), 400);
 }
Exemple #3
0
 /**
  * {@inheritDoc}
  */
 public function onPostExecute(Context $context)
 {
     $request = $context->getRequest();
     if ($request instanceof ModelAggregateInterface) {
         $this->scheduleForUpdateIfSupported($request->getModel());
     }
     if (false == $context->getPrevious()) {
         foreach ($this->scheduledForUpdateModels as $modelHash => $model) {
             $this->storage->update($model);
             unset($this->scheduledForUpdateModels[$modelHash]);
         }
     }
 }
    protected function onPostXXX($request)
    {
        $this->stackLevel--;

        if ($request instanceof ModelAggregateInterface) {
            $this->scheduleForUpdateIfSupported($request->getModel());
        }

        if (0 === $this->stackLevel) {
            foreach ($this->scheduledForUpdateModels as $modelHash => $model) {
                $this->storage->update($model);
                unset($this->scheduledForUpdateModels[$modelHash]);
            }
        }
    }