Category Archives: PayPal

OpenSSL::PKey::RSAError Neither PUB key nor PRIV key:: nested asn1 error – Adaptive Payments Gem

Hey everyone,

I’ve been mucking around with PayPal for a while and decided to try out the adaptive_payments gem by Tommy Chheng. Unfortunately I ran into the following error:

OpenSSL::PKey::RSAError

Neither PUB key nor PRIV key:: nested asn1 error

It turns out that I’d simply skipped an important part of the readme file. The api_cert_file in the paypal_adaptive.yaml file should point to a file containing BOTH your paypal_cert_pem.txt and whatever your private key happens to be. This took an embarrassingly long time for me to figure out, so hopefully this will help some of you!


UPDATE
It turns out I still had this wrong, I was using the wrong certs. After sorting out a few more errors that I ran into after the one mentioned above I finally started getting a response from Paypal, unfortunately it was another error message:

Authentication failed. API credentials are incorrect

It turns out I was using the wrong certs. If you’ve run into the same problem you’ll need to go to Profile > Request API Credentials > Option 2 (Request API credentials to create your own API username and password.). Then download the cert and point to this.


UPDATE
Hey everyone, just another update to this. If you happened to be following the railscast on PayPal before attempting to use the gem, you may not get the option to download the certs mentioned above. To get around this, simply remove your existing certificates (Profile > API Access > Option 2 > Remove > Remove). You should now see the ‘Request API Certificate Option’.

Sorry about the confusing post, but there’s a *slight* chance it might be able to help someone else who runs into the same problem.
Cheers

Blocking Duplicate Payment – Paypal

Hey everyone,

Just a quick post on how to block duplicate payments with PayPal. All you have to do is pass an invoice parameter and then select the ‘block multiple payments per invoice ID’ option in PayPal. I’ve attached an extract from PayPal’s documentation below:

1. Login at https://www.paypal.com
2. Click the ‘Profile’ subtab
3. Under ‘Selling Preferences’ click ‘Payment Receiving Preferences’
4. Choose ‘Yes, block multiple payments per invoice ID’ if you wish to utilize this feature while passing the “invoice” variable
5. Scroll to the bottom and click the ‘Save’ button

To pass the invoice number for Website Payments Standard, you will need to add a line of code to your existing button code. You cannot add this code to a button originally created as encrypted. Example below:

<input type=”hidden” name=”invoice” value=”001″>

The documentation is available at the following link:
https://ppmts.custhelp.com/app/answers/detail/a_id/165

Paypal Platform Ruby SDK – Adaptive Payments

Hey everyone,

This is the SDK for PayPal adaptive payments. I’ve just uploaded it to *hopefully* make it a little easier to find. Please note that it has not been updated recently and that there are a few changes to be made. The StackOverflow post below provides a few examples:

StackOverflow Post:
Adaptive Payments with Ruby

I’ll try to list any others as I come across them, but if you’ve got some of your own please let me know and I’ll try to keep the post up to date.

Download SDK here:
Paypal Platform SDK


Error #1:

Internal Server Error

undefined method `debug_rjs=' for ActionView::Base:Class

Remove the following line from your development.rb config file:

PayPalPlatformRubySDK::Application.configure do
  # Settings specified here will take precedence over those in config/environment.rb

  # In the development environment your application's code is reloaded on
  # every request.  This slows down response time but is perfect for development
  # since you don't have to restart the webserver when you make code changes.
  config.cache_classes = false

  # Log error messages when you accidentally call methods on nil.
  config.whiny_nils = true

  # Show full error reports and disable caching
  config.consider_all_requests_local       = true
  #config.action_view.debug_rjs             = true <---- Comment this line out (no longer supported)
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger
  config.active_support.deprecation = :log

  # Only use best-standards-support built into browsers
  config.action_dispatch.best_standards_support = :builtin
end

Paypal IPN History:
For some reason the IPN history button often won’t appear in the sandbox, use the following link to view it:
https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_display-ipns-history

IPN Notifications:
Just a warning for anyone else setting up payments with PayPal, the sandbox IPN is extremely flaky. It has gone down twice in the last six months for weeks at a time, with no warning or error messages. If you’re not receiving the IPN check out the forums to make sure it’s not down.