SSL error when using Active Merchant and PayPal - ruby-on-rails

I'm trying to use Active Merchant and PayPal to process payments on a staging server. I have everything setup as follows.
Setup PayPal merchant account
Put the credentials into the Active Merchant / PayPal config
Downloaded the PayPal PEM and put it on my server
Bought and uploaded an SSL certificate from PositiveSSL
However, when I run the code (below), I receive this error:
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read finished A: sslv3 alert handshake failure
This is the code I am using
ActiveMerchant::Billing::PaypalGateway.pem_file = File.read("#{Rails.root}/config/cert_key_pem.pem")
#credit_card ||= ActiveMerchant::Billing::CreditCard.new(:brand => "Visa", :number => "4242424242424242", :verification_value => "123", :month => "11", :year => "2016", :first_name => "John", :last_name => "Doe")
gateway = ActiveMerchant::Billing::PaypalGateway.new(:login => "sales_api1.example.com", :password => "password")
response = gateway.authorize(150, #credit_card, :ip=>"123.123.123.1")
Anyone experience this problem or know of a solution to the SSL failing?

Well, I eventually gave up and instead of using the certificate method of validation, I used the PayPal signature.
So I removed the PEM file and am now using
gateway = ActiveMerchant::Billing::PaypalGateway.new(:login => "sales_api1.example.com", :password => "password", :signature => "fake_signature")
and it works great. So... yeah, if anyone else if having problems with Active Merchant and PayPal, try swapping your authentication methods from certificate to signature.

try this,
http://railsapps.github.com/openssl-certificate-verify-failed.html

Related

Authorize.net in Rails - User Authentication failed due to invalid authentication values

I am building a client's ecommerce website. I'm at the latest stages, where I have to integrate the payment system. I signed up for a developer account for Authorize.net in order to test the system. I've ran into a roadblock here
I submitted my payment form, and found the following in my Development Logs
User authentication failed due to invalid authentication values
I set up my gateway as followed, based on my login information to Authorize.net
gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(
:login => "mylogin",
:password => "mypassword",
:test => false
)
Apparently, I'm missing something, but I'm not sure what it is. I watched the RailsCasts videos 144 and 145. I just substituted the gateway to AuthorizeNetGateWay.
Where am I going wrong here?
Here is my development.rb file
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
::GATEWAY = ActiveMerchant::Billing::AuthorizeNetGateway.new(
:login => "mylogin",
:password => "mypassword",
#:signature => "AGjv6SW.mTiKxtkm6L9DcSUCUgePAUDQ3L-kTdszkPG8mRfjaRZDYtSu"
:test_requests => false
)
end
Could the problem be ActiveMerchant::Billing::Base.mode = :test considering this is my Development Environment file?
If you're using a developer account set test to true to use the developer server:
:test => true

SSL Error when sending email via amazon-ses-mailer gem

I found this post Using Amazon SES with Rails ActionMailer and followed the examples found on https://github.com/abronte/Amazon-SES-Mailer but I'm getting this error when sending the mail
"SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed"
config/environments/development.rb:
config.action_mailer.delivery_method = AmazonSes::Mailer.new(
:secret_key => 'AKIAJ*******',
:access_key => 'Ahs08*********'
)
sending message:
mailer = ActionMailer::Base.delivery_method = AmazonSes::Mailer.new(
:secret_key => 'AKI*******',
:access_key => 'Ah***********'
)
mailer.deliver( UserMailer.test(#this_user.email).encoded )
Why am I having SSL Errors here? I tried another configuration using smtp with personal gmail account and its sending the email just fine. Is it a problem with SES? How do I fix this?
I don't think you need the SES Mailer gem anymore. SES used to support TLS wrappers only but as of March 7th 2012...
Amazon SES now supports STARTTLS
As stated in an answer at this SO question. It should be as simple as...
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "email-smtp.us-east-1.amazonaws.com",
:user_name => "..." # Your SMTP user here.
:password => "...", # Your SMTP password here.
:authentication => :login,
:enable_starttls_auto => true
}

Rails ActiveMerchant - Paypal Express Checkout Error

I am getting this error when I call this code.
response = EXPRESS_GATEWAY.setup_purchase(order.price_in_cents,
:ip => request.remote_ip,
:return_url => url_for(:action => :create, :only_path => false),
:cancel_return_url => root_path
)
redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token)
Error:
This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow.
To show I setup EXPRESS_GATEWAY correctly. code development.rb file.
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
:login => '*****************************',
:password => '*************',
:signature => '*******************************************************'
}
::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
end
Gem file
gem 'activemerchant', :require => 'active_merchant'
So the login, password, and sig. were created in the sandbox are of paypal. So they should be working.
What should I try to get this error fixed. Or is this Paypal's side? Is there something wrong in the ActiveMerchant gem?
UPDATE 1
After inspecting the response var, this is what I get.
#<ActiveMerchant::Billing::PaypalExpressResponse:0x00000102402790 #params={"timestamp"=>"2012-06-29T01:30:18Z", "ack"=>"Failure", "correlation_id"=>"d1cb5dbb30425", "version"=>"72", "build"=>"3067390", "message"=>"CancelURL is invalid.", "error_codes"=>"10472", "Timestamp"=>"2012-06-29T01:30:18Z", "Ack"=>"Failure", "CorrelationID"=>"d1cb5dbb30425", "Errors"=>{"ShortMessage"=>"Transaction refused because of an invalid argument. See additional error messages for details.", "LongMessage"=>"CancelURL is invalid.", "ErrorCode"=>"10472", "SeverityCode"=>"Error"}, "Version"=>"72", "Build"=>"3067390"}, #message="CancelURL is invalid.", #success=false, #test=true, #authorization=nil, #fraud_review=false, #avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil}, #cvv_result={"code"=>nil, "message"=>nil}>
Any feedback is appreciated.
UDPATE 2
Turns out after looking at that message above, it was the cancelURL that was invalid, so I fixed that and presto!
Thanks.
This error is shown when you are not properly logged into the sandbox account on paypal's site.
Login to http://sandbox.paypal.com/
Open your site and checkout
When sent to paypal, login as one of your buyer test accounts

Foursquare & Heroku: certificate verify failed

I obtained a key/secret for userless access at the foursquare developer site and now I want to fetch data with the use of the foursquare2 gem:
#foursquare = Foursquare2::Client.new(:client_id => 'xxx', :client_secret => 'yyy')
This works fine on localhost but on Heroku I get the following error:
ActionView::Template::Error (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed)
I didn't set up any SSL or Omniauth within the app.
Update: Found the solution! You have to pass in a ssl hash with the path to heroku's certificates path.
#foursquare = Foursquare2::Client.new(:client_id => 'xxx',
:client_secret => 'yyy',
:ssl => { :verify => OpenSSL::SSL::VERIFY_PEER, :ca_file => '/usr/lib/ssl/certs/ca-certificates.crt' })
I also mentioned that problem under ruby 1.9.3. After downgrading to ruby 1.9.2 I didn't get that error anymore...

Fail:(TESTMODE) Transactions of this market type cannot be processed on this system

I have created a test account with Authorize.net and am using ActiveMerchant to process
credit card payments for a website. What error I always get is Error#*87 - "Transactions of this market type cannot be processed on this system" mentioned in ActiveMerchant documentations. Any suggestions how to resolve this error ?
Following is how i created my gateway. I also checked gateway.test? and it returns true.
gateway = ActiveMerchant::Billing::Base.gateway(:authorized_net).new(
:login =>'API Login ID',
:password =>'Transaction Key',
:test => true)
Try
gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(
:login => 'API Login ID',
:password => 'Transaction Key',
:test => true)

Resources