Make the paypal request and return a Response object

@param AbstractRequest $model
@return Response
@throws Exception
502384
public function send(AbstractRequest $request)
    {
        try {

            $client = $this->client;
            $config = $this->config;

            if(false === $config->isValid()) {
                throw new \Exception("Configuration is not valid.");
            }

            if(is_null($client)) {
                throw new \Exception('Zend\Http\Client must be set and must be valid.');
            }

            if(false === $request->isValid()) {
                throw new \Exception(get_class($request) . " is invalid.");
            }

            $client->setMethod('POST');
            $client->setUri(new \Zend\Uri\Http($config->getEndpoint()));
            $client->setRawBody($config . $request);

            $httpResponse = $client->send();

            $response = Response::factory($request->getMethod(), $httpResponse->getBody());

        } catch(\Exception $e) {

            $response = new Response();
            $response->addErrorMessage($e->getMessage());
        }

        return $response;
    }
510621
public function processForm($model)
	{
		try {
			$configManager = $this->container->get('asf_website.config.manager');
			
			// Check configuration alias (internal use)
			$isExists = $configManager->getRepository()->findOneBy(array('alias' => $model->getAlias()));
			if ( $isExists !== null ) {
				throw new \Exception($this->container->get('asf_layout.flash_message')->danger($this->container->get('translator')->trans('A website configuration already exists with alias "%name%".', array('%name%' => $model->getAlias()), 'asf_website')));
			}
			
			// Check default configuration
			$defaultExists = $configManager->getRepository()->findOneBy(array('isDefault' => true));
			if ( $defaultExists === null ) {
				$model->setIsDefault(true);
			} elseif ($model->getIsDefault() == true && $model->getId() != $defaultExists->getId() ) {
				throw new \Exception($this->container->get('asf_layout.flash_message')->danger($this->container->get('translator')->trans('A default website configuration already exists ("%name%").', array('%name%' => $defaultExists->getName()), 'asf_website')));
			}
			
			$model instanceof Config;
			foreach($model->getParameters() as $parameter ) {
				$parameter->setConfig($model);
			}
			
			$db_parameters = $this->container->get('asf_website.parameter.manager')->getRepository()->findBy(array('config' => $model));
			foreach($db_parameters as $db_parameter) {
				if ( !$model->getParameters()->contains($db_parameter) ) {
					$model->removeParameter($db_parameter);
					$this->container->get('asf_website.parameter.manager')->getEntityManager()->remove($db_parameter);
				}
			}
			
			return true;
			
		} catch (\Exception $e) {
			throw new \Exception(sprintf('An error occured : %s', $e->getMessage()));
		}
		
		return false;
	}
885030
public function handle(ServerRequestInterface $request, Factory $payments, ExceptionHandler $handler)
    {
        try {
            return $payments->driver((string)Request::route('shop'))->callback($request);
        } catch (Exception $exception) {
            $handler->report($exception);
            return new Response($exception->getMessage(), 500);
        }
    }
1353165
public function create($model, $data)
	{
		$params = $this->buildParams(array(
			$model,
			'create',
			$data
		));

		$response = $this->getClient('object')->call('execute', $params);

		return $response;
	}
926396
public function getBuilder(AbstractModel $model): ?AbstractBuilder {
		if ($model instanceof PhpClass) {
			return $this->classBuilder;
		}

		if ($model instanceof PhpConstant) {
			return $this->constantBuilder;
		}

		if ($model instanceof PhpFunction) {
			return $this->functionBuilder;
		}

		if ($model instanceof PhpInterface) {
			return $this->interfaceBuilder;
		}

		if ($model instanceof PhpMethod) {
			return $this->methodBuilder;
		}

		if ($model instanceof PhpParameter) {
			return $this->parameterBuilder;
		}

		if ($model instanceof PhpProperty) {
			return $this->propertyBuilder;
		}

		if ($model instanceof PhpTrait) {
			return $this->traitBuilder;
		}

		return null;
	}
1123829
public function resultAction(Request $request)
    {
        try {
            $this
                ->gestpayManager
                ->processResult($request->query->all());
        } catch (PaymentException $e) {
            $this
                ->logger
                ->log(
                    'error',
                    'Gestpay error "'.$e->getMessage(),
                    GestpayMethod::METHOD_NAME
                );
        }

        return new Response('OK');
    }
889947
public static AlipayFundCouponOrderAgreementPayResponse fundCouponOrderAgreementPayToResponse(
			AlipayFundCouponOrderAgreementPayModel model) throws AlipayApiException {
		AlipayFundCouponOrderAgreementPayRequest request = new AlipayFundCouponOrderAgreementPayRequest();
		request.setBizModel(model);
		return AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().execute(request);
	}
520637
public function fetchCacheData(AbstractModel $model)
    {
        $this->position = get_class($model);
        if (!isset($this->modelDataCache[$this->position])) {
            $this->modelDataCache[$this->position] = $this->prepareCacheData($model);
        }

        return $this->modelDataCache[$this->position];
    }
649322
protected function getType(AbstractModel $model)
    {
        $types = array(
            'Contact',
            'Invoice',
            'Estimate',
            'IncomingInvoice',
            'RecurringTemplate',
            'CurrentSession',
            'TaxRate',
            'Product',
            'Contact\Sync',
            'Contact\Note',
            'Invoice\History',
        );
        foreach ($types as $type) {
            $classname = __NAMESPACE__ . '\\' . $type;
            if ($model instanceof $classname) {
                return $type;
            }
        }
        return substr(get_class($model), strlen(__NAMESPACE__) + 1);
    }
19408
public static AlipayFundCouponOrderAppPayResponse fundCouponOrderAppPayToResponse(
			AlipayFundCouponOrderAppPayModel model) throws AlipayApiException {
		AlipayFundCouponOrderAppPayRequest request = new AlipayFundCouponOrderAppPayRequest();
		request.setBizModel(model);
		return AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().execute(request);
	}
238025
public function setCurrentRecord(Mage_Core_Model_Abstract $model = null)
    {
        if ($model) {
            $expectedClass = get_class($this->getModel());
            if (!is_a($model, $expectedClass)) {
                throw new RuntimeException($this->__('Invalid model class. Expected:%1$s Passed:%2$s', $expectedClass, get_class($model)));
            }
        }

        Mage::unregister($this->getCurrentRecordKey());

        if ($model) {
            Mage::register($this->getCurrentRecordKey(), $model);
        }

        return $this;
    }
600157
public function getRequest()
    {
        if ($this->request === null) {
            $this->request = oxNew(\OxidEsales\PayPalModule\Model\PayPalRequest\PayPalRequest::class);
        }

        return $this->request;
    }
422929
public static AlipayCommerceCityfacilitatorVoucherBatchqueryResponse voucherBatchqueryToResponse(
			AlipayCommerceCityfacilitatorVoucherBatchqueryModel model) throws AlipayApiException {
		AlipayCommerceCityfacilitatorVoucherBatchqueryRequest request = new AlipayCommerceCityfacilitatorVoucherBatchqueryRequest();
		request.setBizModel(model);
		return AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().execute(request);
	}
479804
public function send(Sendable $model, AbstractEnvelope $envelope)
    {
        $classname = $this->getType($model);

        if (intval($model->getId()) == 0) {
            $model->save($this->getService($classname));
        }

        $response = $this->request(
            $this->buildUrl($model, null, '/send_' . strtolower($classname)), 'PUT', $this->mapper->mapToStorage($envelope)
        );

        return $this->mapper->mapFromStorage($response);
    }
820285
@POST
    public final Response insert(@NotNull @Valid final MODEL model) throws Exception {
        return super.insert(model);
    }
450359
public function create()
    {
        //try to save all the fields we allow
        {
            if ($this->model->save($this->request->getPost(), $this->createFields)) {
                return $this->response($this->model->toArray());
            } else {
                //if not thorw exception
                throw new Exception($this->model->getMessages()[0]);
            }
        }
    }
978112
public static AlipayFundAuthOrderVoucherCreateResponse authOrderVoucherCreateToResponse(
			AlipayFundAuthOrderVoucherCreateModel model) throws AlipayApiException {
		AlipayFundAuthOrderVoucherCreateRequest request = new AlipayFundAuthOrderVoucherCreateRequest();
		request.setBizModel(model);
		return AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().execute(request);
	}