Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I resolve the 10007 - "permission denied" PayPal API error using the paypal-express gem in ruby on rails
    text
    copied!<p>I'm using the <a href="https://github.com/nov/paypal-express" rel="nofollow">paypal-express</a> gem in my ruby on rails project. I want users to be able to purchase digital goods on my web application. I've created a controller with a new and create action. The <code>new</code> action generates a PayPal link which users visit. Users are returned from PayPal to the <code>create</code> action where I attempt to complete the order.</p> <p>Everything works fine in development when using sandbox credential, when using production credentials I receive a "10007 - permission denied" error from PayPal.</p> <p>I have triple checked the username/password/API signature i've entered for production and they are correct (The user is sent to the correct PayPal store).</p> <p>Here is my controller:</p> <pre><code>class DigitalPaymentsController &lt; ApplicationController before_filter :authenticate_user!, :only =&gt; [ :new, :create ] def new Paypal.sandbox! unless Rails.env.production? response = paypal_request.setup( payment_request, success_url, cancel_url, :no_shipping =&gt; true ) @paypal_url = response.redirect_uri end def create begin response = paypal_request.checkout!(params[:token], params[:PayerID], payment_request) if response.payment_info.first.payment_status == 'Completed' # TODO: Handle complete payments else # TODO: Handle non complete payments end rescue Paypal::Exception::APIError =&gt; e # Payment has failed, failure details are in e.message, also check params end end private def paypal_request @request ||= Paypal::Express::Request.new( :username =&gt; PAYPAL_USERNAME, :password =&gt; PAYPAL_PASSWORD, :signature =&gt; PAYPAL_SIGNATURE ) end def payment_request @payment_request ||= Paypal::Payment::Request.new( :currency_code =&gt; :USD, :amount =&gt; 15, :items =&gt; [{ :name =&gt; "Awesome Product", :description =&gt; 'Description of awesomeness', :amount =&gt; 15, :category =&gt; :Digital }] ) end end </code></pre> <p>Having a look into the paypal-express gem, it seems to call <code>DoExpressCheckoutPayment</code> on the PayPal API and pass the PayerID and the Token. The PayPal API documentation didn't list a way to resolve my error (10007).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload