Closed strategicdots closed 4 years ago
Hi @strategicdots did you ever figure out the solution to this error? I'm currently experiencing it and I don't know how to deal with it.
Hi i'm also experiencing the same problem, any solution?
@Emmanuel96 and @nensok , I updated my packages using composer update
(this is after I added "unicodeveloper/laravel-paystack": "1.0.*"
to my composer.json file of course) and it worked.
Try that and let's see
I assume you have already done the installation of the package and added paystack.php
manually and populated config:app
, with the provider and alliases to get this error, if not do so.
now this is what worked for me:
composer update
config:cache
and you are good to goI would advise you do "sensitive" Paystack data initialization in the controller.
public function redirectToGateway(Request $request)
{
// computed amount -> $amount;
$paystack = new Paystack();
$user = Auth::user();
$request->email = $user->email;
$request->amount = $amount;
$request->reference = $paystack->genTranxRef();
$request->key = config('paystack.secretKey');
return $paystack->getAuthorizationUrl()->redirectNow();
}
And then in your web.php
do the needful routing.
So install Guzzle Then run run composer update after the update run config:cache and you are good to go
Hi guys ... so i used dis package worked perfectly on my local server buh when i deployed it i get the "URI must be a string or UriInterface"... i currently dont know how to fix it ...
I would advise you do "sensitive" Paystack data initialization in the controller.
public function redirectToGateway(Request $request) { // computed amount -> $amount; $paystack = new Paystack(); $user = Auth::user(); $request->email = $user->email; $request->amount = $amount; $request->reference = $paystack->genTranxRef(); $request->key = config('paystack.secretKey'); return $paystack->getAuthorizationUrl()->redirectNow(); }
And then in your
web.php
do the needful routing.
@aeadedoyin any sample on how you can pass ur form datails to Paystack. With your approach which is passing the datails from your controller to Paystack, After which in view page, we just create an empty form with submit button to pass the details to Paystack. Is this a good implementation and would it work fine?
<form method="POST" action="{{ route('agentPay') }}" accept-charset="UTF-8" class="form-horizontal" role="form">
{{ csrf_field() }}
<button class="btn btn-success btn-lg btn-block" type="submit" value="Pay Now!"> <i class="fa fa-plus-circle fa-lg"></i> Pay Now! </button>
</form>
@Akhibemudu
Alright, you see the redirectToGateway(Request $request)
method is where all the magic takes place.
the amount, email, reference, and key are the required fields you need to pass to the request before it can go through.
In web.php
here's a sample route to be able to call route('agentPay')
from the 'Pay Now' button in your code.
Route::post('/land/{id}/pay', 'PagesController@redirectToGateway')->name('agentPay');
@aeadedoyin Please have you encountered this error before?
Client error:
POST https://api.paystack.co/transaction/initializeresulted in a
401 Unauthorizedresponse: { "status": false, "message": "Invalid key" }
Note:
I have updated my .env file, i have also set the callback url to response
if you are certain your API Keys are correctly placed, because this might seem to be the possible reason, maybe you should try clearing config cache php artisan config:cache
and php artisan cache:clear
yea @shoutershub I did that several times and I ended up getting the same error message. So I switched to Rave but would have preferred to use Paystack since it supports international payment. Any assistance on this @unicodeveloper
There are a lot of open issues and PRs on this package. I don’t know if it’s still being maintained. The paystack official doc is well detailed and you can implement anything you want with few lines of code. Since there is really no update happening on this package just consume the paystack API with guzzle.
Hi guys ... so i used dis package worked perfectly on my local server buh when i deployed it i get the "URI must be a string or UriInterface"... i currently dont know how to fix it ...
@Pauloo101 i experienced this same issue and it took me three days to discover that i didn't update my .env with paystack details in production server (in deployment) as shown below. hope this help someone.
PAYSTACK_PUBLIC_KEY=xxxxxxxxxxxxxxxx PAYSTACK_SECRET_KEY=xxxxxxxxxxxxxxxxx PAYSTACK_PAYMENT_URL=https://api.paystack.co MERCHANT_EMAIL=unicodeveloper@gmail.com
You will most likely experience this issue on a live server. Here is how to fix
Explanation The reason you are seeing this error is due to the fact that you added Paystack details after publishing your website to a live server since .env is in gitignore file, it means that the changes you make are not tracked on the live server. So by removing .env from the gitignore file, the changes can now be tracked an effected. You can also decide to readd .env to gitignore after your changes take effect.
@aremu-smog This is a wrong approach. You don't expose your env file like that and not all server will recognize your env file. If you using Google cloud, you will need app.yaml file. If your using heroku you have to write your configuration in your configvar
Thanks a lot for this @odutolaabisoye. It would be nice to know a better approach to resolve this particular issue though because I battled this for over a week before trying that approach.
Which server are you using?
heroku
On Mon, 16 Mar 2020 at 12:04, odutolaabisoye notifications@github.com wrote:
Which server are you using?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/unicodeveloper/laravel-paystack/issues/57#issuecomment-599474985, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALP3ZWUAGSAULZ72WPM6OY3RHYBS7ANCNFSM4FPRN3FA .
--
Goto Settings -> Config Vars -> Reveal Config Vars -> Add your confugurations
Thanks a lot for this.
if you are still facing this issue, the simplest way is to remove <input type="hidden" name="reference" value="{{ Paystack::genTranxRef() }}">
from your blade and generate the reference on your controller using this $reference = Paystack::genTranxRef();
. Then you are good.
Hi guys ... so i used dis package worked perfectly on my local server buh when i deployed it i get the "URI must be a string or UriInterface"... i currently dont know how to fix it ...
@Pauloo101 i experienced this same issue and it took me three days to discover that i didn't update my .env with paystack details in production server (in deployment) as shown below. hope this help someone.
PAYSTACK_PUBLIC_KEY=xxxxxxxxxxxxxxxx PAYSTACK_SECRET_KEY=xxxxxxxxxxxxxxxxx PAYSTACK_PAYMENT_URL=https://api.paystack.co MERCHANT_EMAIL=unicodeveloper@gmail.com
This solved my problem.
Thanks!
URI must be a string or UriInterface I have been facing this error and have tried different solution it keep show this error I need help to solve this pls
The app has been throwing this error for a while. If I comment out this line in the form
<input type="hidden" name="reference" value="{{ Paystack::genTranxRef() }}">
it works fine but throws that same error on thePaymentController@redirectToGateway
controller.I search and realized it has to do with Guzzle, anyway to bypass this exception?