0

I am implementing a paypal payment within a project.

Following paypals instructions I built a procedural php file to get a users payment. This worked so I took the next step to make it a class.

Within this class I call a static method from a class provided by paypal. This call gives back an error:

Fatal error: Cannot access empty property in line xy.

By this line:

use PayPal\Api\Payment;

the class is made available.

This line throws the error:

/*xy=>*/ $this->payment = Payment::get ( $this->paymentId, $this->apiContext );

First I checked that $this->paymentId and $this->apiContext are populated and not empty.

( xy=> is the line number ).

usually I separate variables by lines but the editor here does not support it so do not wonder why I only tried to experiment with paymentID and not with apiContext. This is because apiContext is in the next line (xy+1 ) within my source code.

I tried to transfer the volume of $this->paymentId to a variable $abc and then tried the call:

$abc = $this->paymentId;
/*xy=>*/ $this->payment = Payment::get ( $abc, $this->apiContext );

Then I tried to instantiate the paypal class before calling the funtion like:

$ppobj= new \PayPal\Api\Payment();
/*xy=>*/ $this->payment = $ppobj->Payment::get ( $this->paymentId, $this->apiContext );

And I tried a call like:

$this->payment = \PayPal\Api\Payment::get( $this->paymentId, $this->apiContext );

Please be so kind and tell me what I am doing wrong and what I am supposed to do.

Phil
  • 157,677
  • 23
  • 242
  • 245
Paul
  • 126
  • 1
  • 11
  • _"the class is made available"_ but have you also made sure all its dependencies are available, such as `PayPal\Validation\ArgumentValidator` and `PayPal\Common\PayPalResourceModel` – Phil Jul 12 '19 at 03:54
  • 1
    Also, you get that error if you try something like `$this->$paymentId` (notice the extra `$`). See [PHP Fatal error: Cannot access empty property](https://stackoverflow.com/questions/14920216/php-fatal-error-cannot-access-empty-property). Are you absolutely sure you have nothing like that in your code? – Phil Jul 12 '19 at 03:56
  • It also sounds like your error reporting is not high enough and may be missing `E_NOTICE` level errors. See [How can I get useful error messages in PHP?](https://stackoverflow.com/questions/845021/how-can-i-get-useful-error-messages-in-php) – Phil Jul 12 '19 at 03:58

0 Answers0