unicodeveloper / laravel-paystack

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

401 error #86

Closed Dilpenny closed 4 years ago

Dilpenny commented 4 years ago

Whenever i try to pay i get this error: Client error: POST https://api.paystack.co/transaction/initialize resulted in a 401 Unauthorized response: { "status": false, "message": "Invalid key" }

Bazzly commented 4 years ago

this you use this Unicodeveloper\Paystack\Facades\Paystack; in your payment controller ??

bere6255 commented 4 years ago

@Dilpenny the message is clear now you public or private key is not valid

EmmyGuy commented 2 years ago

@bere6255 I am querying my keys from a database table then used Config::set ("variablename", value) to set the value of the keys on the paystack config file. This however give error 401. But when I copy and paste the same queried key directly to paystack config file the request fires with 200 status code.

bere6255 commented 2 years ago

@bere6255 I am querying my keys from a database table then used Config::set ("variablename", value) to set the value of the keys on the paystack config file. This however give error 401. But when I copy and paste the same queried key directly to paystack config file the request fires with 200 status code.

Best practice do not store keys in database use env files and ignore them from commit that will solve your problem

EmmyGuy commented 2 years ago

@bere6255 thanks for your response. But the situation here warrants the choice. Scenario: I have SaaS where different users represents a different business on my paystack account. These users have different keys as such I want payment going to individual business bank account. My best shot is to dynamical set keys before making API call.

Any other way of handling such case shall be appreciated.

bere6255 commented 2 years ago

@bere6255 thanks for your response. But the situation here warrants the choice. Scenario: I have SaaS where different users represents a different business on my paystack account. These users have different keys as such I want payment going to individual business bank account. My best shot is to dynamical set keys before making API call.

Any other way of handling such case shall be appreciated.

Handle all disbursement from a single account and manage all your business accounts internally, the you will be able to track when things go wrong for customer support

EmmyGuy commented 2 years ago

thanks for the heads up @bere6255. but I got it done by writing it to the environment variable the fetch the same from the config... that way, every client payment goes to her account under a business on the paystack platform.

bere6255 commented 2 years ago

thanks for the heads up @bere6255. but I got it done by writing it to the environment variable the fetch the same from the config... that way, every client payment goes to her account under a business on the paystack platform.

Soft🎉