unicodeveloper / laravel-paystack

:credit_card: :package: :moneybag: Laravel 6, 7, 8, 9, 10 and 11 Package for Paystack
https://paystack.co
MIT License
612 stars 314 forks source link

How to give callback url per transaction #20

Closed tommygr8 closed 7 years ago

tommygr8 commented 7 years ago

From the documentation, you can only register callback url on the dashboard unlike the codeigniter api where you can specify callback url per transaction. I may have many transactions from different website, how do i specify callback for each transaction

tommygr8 commented 7 years ago

I just saw it in the code that there is a callback_url in the parameter and so one can pass the callback_url as part of the hidden field and the value to be the callback url you want it return to after the payment. Moreso, passing the value in the hidden field is not secured as one can change the the amount value from the inspect element. What i did is to remove the hidden field and in the controller, i have to add the parameters to request before calling Paystack::getAuthorizationUrl()->redirectNow()

Francis-Njoku commented 5 years ago

@tommygr8 Please how did you pass the callback_url as part of the hidden field, could you drop a snippet. Thanks

tommygr8 commented 5 years ago

You can add the callback url to the request before getAuthorizationUrl

function pay(Request $request) {

                   ..... 
                       $request->request->add([
                                'callback_url' =>"my callback",
                            ]);

    return \Paystack::getAuthorizationUrl()->redirectNow();

}

or use

tommygr8 commented 5 years ago

function pay(Request $request) {

               ..... 
                   $request->request->add([
                            'callback_url' =>"my callback",
                        ]);

return \Paystack::getAuthorizationUrl()->redirectNow();

}

or add hidden field and name="callback_url" and value="callback_ur;" < input type="" name="callback_url" value="callback_ur" >

Francis-Njoku commented 5 years ago

I will try it