Monthly Archives: October 2012

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

Additional Logging – Heroku

Hey everyone,

I needed to do a fair bit of logging and came across a heroku guide that shows how to make things a little easier.

Change logging level to debug:
heroku config:add LOG_LEVEL=DEBUG

View a live(ish) feed of errors:
heroku logs –tail

If you’re aware of any other useful bits please let me know!

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

Uploadify – Limit to One Upload Only

Hey everyone,

Just a quick post detailing how to limit uploadify to a single file. Simply add the following settings to your uploadify initialisation:

multi: false
queueSizeLimit : 1
uploadLimit : 1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
$(document).ready(function() {
     $('#file_upload').uploadify({
        'swf' : '<?php echo $this->Html->url('/uploadify/uploadify.swf');?>',
	'uploader' : '<?php echo $this->Html->url('/uploadify/uploadify.php');?>',
	'cancelImg' : '<?php echo $this->Html->url('/webroot/uploadify/cancel.png');?>',
	'folder' : '<?php echo $this->Html->url('/extraz/uploaded_by_all_users');?>',
	'auto' : true,
	'buttonText' : 'Browse',
	'multi' : false,
	'queueSizeLimit' : 1,
	'uploadLimit' : 1,
	'sizeLimit' : 1073741824,
	'debug' : true,
	'multi' : false,	        
	'onUploadProgress' : upload_progress_handler,
	'onUploadStart' : upload_start_handler,
	'onUploadSuccess' : on_upload_success,
	'onUploadError' : on_upload_error
     });
});

Once the upload limit is exceeded the onUploadError event is raised.

Cheers

View Last Query Executed – Oracle

Hey all,

Just a quick post on how to view recent queries run into an Oracle database:

 
SELECT sql_text, sql_fulltext
  FROM v$sql
ORDER BY last_load_time DESC

Cheers

Git with KDiff3 – Windows

Hey all,

Just a quick post showing the config I needed to use in order to get KDiff3 working with git. It took a while to get this working so hopefully it’ll be able to help someone else out.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#Config file
[user]
	email = test@test.com.au
	name = test
[core]
	editor = \"C:\\Program Files\\Sublime Text 2\\sublime_text.exe\"
 
[apply]
    whitespace = fix
 
[color]
    branch = auto
    diff = auto
    interactive = auto
    status = auto
 
 
[core]
        pager = less -FRSX
        whitespace = cr-at-eol
        autocrlf = input
        excludesfile = /Users/test/.gitignore_global
        editor = mate -w
 
[alias]
        co = checkout
        lg = log --graph --pretty=oneline --abbrev-commit
 
[gui]
	recentrepo = Y:/Projects/Junk
	recentrepo = C:/xampp/htdocs/onlinemedia
[merge]
	tool = kdiff3

Screenshot of git config from GUI:

Git Config KDiff

Git Config KDiff

Running KDiff3:

Executing KDiff3

Executing KDiff3

KDiff3 display:

KDiff3 Display

KDiff3 Display