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;
}
This has been solved here https://github.com/unicodeveloper/laravel-paystack/issues/16#issuecomment-431568603
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();
}
}`