Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unauthorized Access with Paypal REST API

Everything works fine in a development/localhost environment.

When deploying to heroku, using sandbox/test credentials on a new app, and creating a new payment I am getting

A PayPal::SDK::Core::Exceptions::UnauthorizedAccess occurred in orders#create:

  Failed.  Response code = 401.  Response message = Unauthorized.

Again, everything thing works in a development environment

Should I permit any specific domains (like in Facebook integration)?

like image 334
Nick Ginanto Avatar asked Dec 02 '25 10:12

Nick Ginanto


1 Answers

If you are running a Rails application on a public server, there is quite a chance that the Rails environment is set to "production".

If you further use the config/initializers/paypal.rb and config/paypal.yml generated by the Paypal API SDK's standard generator, then:

  • the initializer loads configuration for the current Rails environment, which is "production"
  • and in the production configuration one important line presumes that you want to run on the live API

So most probably you are attempting to communicate with the live API without knowing it. Changing the line to mode: sandbox should make you happy.

like image 94
igneus Avatar answered Dec 04 '25 00:12

igneus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!