Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using $this when not in object context #152

Open
adetech2017 opened this issue Nov 16, 2021 · 4 comments
Open

Using $this when not in object context #152

adetech2017 opened this issue Nov 16, 2021 · 4 comments

Comments

@adetech2017
Copy link

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;

}
@mishiray
Copy link

@MShoaibAkram
Copy link

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

@mishiray
Copy link

mishiray commented Mar 7, 2022

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

@MShoaibAkram
Copy link

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

}
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants