PayPal\Api\Payment::get PHP Method

get() public static method

Shows details for a payment, by ID.
public static get ( string $paymentId, ApiContext $apiContext = null, PayPalRestCall $restCall = null ) : Payment
$paymentId string
$apiContext PayPal\Rest\ApiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
$restCall PayPalRestCall is the Rest Call Service that is used to make rest calls
return Payment
    public static function get($paymentId, $apiContext = null, $restCall = null)
    {
        ArgumentValidator::validate($paymentId, 'paymentId');
        $payLoad = "";
        $json = self::executeCall("/v1/payments/payment/{$paymentId}", "GET", $payLoad, null, $apiContext, $restCall);
        $ret = new Payment();
        $ret->fromJson($json);
        return $ret;
    }

Usage Example

 public function getPaymentStatus()
 {
     // Get the payment ID before session clear
     $payment_id = Session::get('paypal_payment_id');
     // clear the session payment ID
     Session::forget('paypal_payment_id');
     if (empty(Input::get('PayerID')) || empty(Input::get('token'))) {
         return Redirect::route('original.route')->with('error', 'Payment failed');
     }
     $payment = Payment::get($payment_id, $this->_api_context);
     // PaymentExecution object includes information necessary
     // to execute a PayPal account payment.
     // The payer_id is added to the request query parameters
     // when the user is redirected from paypal back to your site
     $execution = new PaymentExecution();
     $execution->setPayerId(Input::get('PayerID'));
     //Execute the payment
     $result = $payment->execute($execution, $this->_api_context);
     echo '<pre>';
     print_r($result);
     echo '</pre>';
     exit;
     // DEBUG RESULT, remove it later
     if ($result->getState() == 'approved') {
         // payment made
         return Redirect::route('original.route')->with('success', 'Payment success');
     }
     return Redirect::route('original.route')->with('error', 'Payment failed');
 }
All Usage Examples Of PayPal\Api\Payment::get