public function controlledResource() { if ($this->request->method === 'POST' || $this->request->method === 'OPTIONS' || $this->request->uri === '/votes') { return When::resolve(array()); } $search = (array) $this->request->query['search']; $options = (array) $this->request->query['options']; if (isset($search['created-min']) && isset($search['created-max'])) { $search = array('$and' => array(array('created' => array('$gte' => new DateTime($search['created-min']))), array('created' => array('$lte' => new DateTime($search['created-max']))))); } $this->response->headers['X-Count'] = Model::count($search, array(), $this->domain); return Model::fetch($search, $options, $this->domain); }
public static function executePayment($paymentId, $payerId, $domain) { if (!$paymentId || !$payerId) { return When::reject("PaymentID or PayerID invalid"); } $payment = static::getPaymentDetails($paymentId, $domain); $paymentExecution = new PaymentExecution(); $paymentExecution->setPayerId($payerId); try { $payment->execute($paymentExecution, static::getApiContext($domain)); return static::getPayment($payment->getId(), $domain); } catch (PayPalConnectionException $exception) { return When::reject($exception); } }