/**
  * @return JsonResponse
  */
 public function getAllAction()
 {
     $normalizedFactories = [];
     foreach ($this->registry->getGatewayFactories() as $name => $factory) {
         $gatewayConfig = new GatewayConfig();
         $gatewayConfig->setFactoryName($name);
         $form = $this->formFactory->create('payum_gateway_config', $gatewayConfig, ['csrf_protection' => false, 'data_class' => GatewayConfig::class]);
         $normalizedFactories[$name]['config'] = $this->formToJsonConverter->convertMeta($form->get('config'));
     }
     $form = $this->formFactory->create('payum_gateway_config', null, ['csrf_protection' => false, 'data_class' => GatewayConfig::class]);
     return new JsonResponse(array('generic' => $this->formToJsonConverter->convertMeta($form), 'meta' => $normalizedFactories));
 }
 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);
 }
Example #3
0
 /**
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function createAction($content, Request $request)
 {
     $this->forward400Unless('json' == $request->getContentType() || 'form' == $request->getContentType());
     $rawToken = ArrayObject::ensureArrayObject($content);
     $form = $this->formFactory->create(CreateTokenType::class);
     $form->submit((array) $rawToken);
     if (false == $form->isValid()) {
         return new JsonResponse($this->formToJsonConverter->convertInvalid($form), 400);
     }
     $data = $form->getData();
     /** @var Payment $payment */
     $this->forward400Unless($payment = $this->payum->getStorage(Payment::class)->find($data['paymentId']));
     if ($data['type'] == 'capture') {
         $token = $this->payum->getTokenFactory()->createCaptureToken('', $payment, $data['afterUrl'], ['payum_token' => null, 'paymentId' => $payment->getId()]);
     } else {
         if ($data['type'] == 'authorize') {
             $token = $this->payum->getTokenFactory()->createAuthorizeToken('', $payment, $data['afterUrl'], ['payum_token' => null, 'paymentId' => $payment->getId()]);
         } else {
             $this->forward400(sprintf('The token type %s is not supported', $data['type']));
         }
     }
     return new JsonResponse(['token' => $this->tokenToJsonConverter->convert($token)], 201);
 }
Example #4
0
 /**
  * @return JsonResponse
  */
 public function metaAction()
 {
     $form = $this->formFactory->create(CreatePaymentType::class);
     return new JsonResponse(array('meta' => $this->formToJsonConverter->convertMeta($form)));
 }
Example #5
0
 /**
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function metaAction(Request $request)
 {
     $form = $this->formFactory->create('create_payment');
     return new JsonResponse(array('meta' => $this->formToJsonConverter->convertMeta($form)));
 }