laravel-paystack icon indicating copy to clipboard operation
laravel-paystack copied to clipboard

Using $this when not in object context

Open adetech2017 opened this issue 4 years ago • 4 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;

}

adetech2017 avatar Nov 16 '21 12:11 adetech2017

This has been solved here https://github.com/unicodeveloper/laravel-paystack/issues/16#issuecomment-431568603

mishiray avatar Jan 21 '22 23:01 mishiray

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

MShoaibAkram avatar Mar 07 '22 18:03 MShoaibAkram

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

mishiray avatar Mar 07 '22 19:03 mishiray

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

} }`

MShoaibAkram avatar Mar 14 '22 17:03 MShoaibAkram