One doubt. My application before going to paypal first shows a form that takes some information from the user. Once this information is saved in the database, then I redirect to paypal site. So my controller uses this code
ruby
#code that saves the cart in db
redirect_to @morder.paypal_url(store_url,hook_path,@cart.id)
So now i added encryption just as you said and would like to send the values, but I am getting an error.
ruby
#Same code as yours
values = encrypt_for_paypal(values)
"https://www.sandbox.paypal.com/cgi-bin/webscr?" + values.to_query#Error displayed here says "wrong number of arguments"endPAYPAL_CERT_PEM = File.read("#{Rails.root}/certs/paypal_cert.pem")
APP_CERT_PEM = File.read("#{Rails.root}/certs/app_cert.pem")
APP_KEY_PEM = File.read("#{Rails.root}/certs/app_key.pem")
defencrypt_for_paypal(values)
signed = OpenSSL::PKCS7::sign(OpenSSL::X509::Certificate.new(APP_CERT_PEM), OpenSSL::PKey::RSA.new(APP_KEY_PEM, ''), values.map { |k, v| "#{k}=#{v}" }.join("\n"), [], OpenSSL::PKCS7::BINARY)
OpenSSL::PKCS7::encrypt([OpenSSL::X509::Certificate.new(PAYPAL_CERT_PEM)], signed.to_der, OpenSSL::Cipher::Cipher::new("DES3"), OpenSSL::PKCS7::BINARY).to_s.gsub("\n", "")
end
I am trying to run the project i downloaded from the above given link. When i run "rake setup" I am cleary getting some compatibility erros since I am running the latest version of rails. How to fix this?
rake aborted!
LoadError: cannot load such file -- initializer
/home/vishal/Study/Agile Web Rails/store/config/boot.rb:54:in `load_initializer'
/home/vishal/Study/Agile Web Rails/store/config/boot.rb:38:in `run'
/home/vishal/Study/Agile Web Rails/store/config/boot.rb:11:in `boot!'
/home/vishal/Study/Agile Web Rails/store/config/boot.rb:109:in `<top (required)>'
/home/vishal/Study/Agile Web Rails/store/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
vishal@vishal-Rev-1-0:~/Study/Agile Web Rails/store$ rake setup --trace
rake aborted!
LoadError: cannot load such file -- initializer
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:121:in `require'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:121:in `require'
/home/vishal/Study/Agile Web Rails/store/config/boot.rb:54:in `load_initializer'
/home/vishal/Study/Agile Web Rails/store/config/boot.rb:38:in `run'
/home/vishal/Study/Agile Web Rails/store/config/boot.rb:11:in `boot!'
/home/vishal/Study/Agile Web Rails/store/config/boot.rb:109:in `<top (required)>'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/home/vishal/Study/Agile Web Rails/store/Rakefile:4:in `<top (required)>'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load_rakefile'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:689:in `raw_load_rakefile'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:77:in `block in run'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/vishal/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/home/vishal/.rbenv/versions/2.2.1/bin/rake:33:in `<main>'
with the latest versions , the event.preventdefault() does not seem to make any difference,any ideas?
thanks , just what i wanted
Great save sir
Yes it worked
Can you post a link to your blog?
One doubt. My application before going to paypal first shows a form that takes some information from the user. Once this information is saved in the database, then I redirect to paypal site. So my controller uses this code
So now i added encryption just as you said and would like to send the values, but I am getting an error.
The error is wrong number of arguments (0 for 1)
I am trying to run the project i downloaded from the above given link. When i run "rake setup" I am cleary getting some compatibility erros since I am running the latest version of rails. How to fix this?