unicodeveloper / laravel-paystack

:credit_card: :package: :moneybag: Laravel 6, 7, 8, 9, 10 and 11 Package for Paystack

Home Page:https://paystack.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using $this when not in object context

adetech2017 opened this issue · comments

I'm getting error in line 210 of the package saying "Error Using $this when not in object context".
Please how do i solve this.
public function getAuthorizationUrl()
{
$this->makePaymentRequest();

    $this->url = $this->getResponse()['data']['authorization_url'];
    return $this;

}

Can you please update. is this issue resolved I am also facing this issue

This is what worked for me

/**
* Create a new controller instance.
*
* @return void
/
public function __construct()
{
$this->paystack = new Paystack();
}
/
*
* Redirect the User to Paystack Payment Page
* @return Url
*/
public function redirectToGateway()
{
try{
return $this->paystack->getAuthorizationUrl()->redirectNow();
}catch(\Exception $e) {
return Redirect::back()->withMessage(['msg'=>'The paystack token has expired. Please refresh the page and try again.', 'type'=>'error']);
}
}

I have fixed this solution by using using package of Paystack instead of Unicodedeveloper/Paystack.. below here is my payment controller code for reference
`use Paystack;
class PaymentController extends Controller{

public function redirectToGateway(Request $request){
  ......
  ......
  .....
   return Paystack::getAuthorizationUrl()->redirectNow();

}
}`