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); } }