Can't Get Paypal Encrypted Website Payments to Work in Rails

Paypal Encrypted Website payments

Firstly, your problem with OpenSSL. If you use linux or Mac it is easy (as always). Install the package as usual and use the command on the paypal instructions page. On Windows, make sure you are downloading binaries not source from this page.

You do not need to use the Java programme they provide to generate the links. That part of the instruction sheet is for people making static pages, not using PHP. PayPal is a big solution that gives you a huge amount of flexibility, but they do that by providing you with lots of different APIs and ways of handling payments. EWPs (encrypted website payments), in the link you posted, are not what you are looking for.

It has been a couple of years now since I used PayPal in a solution for a customer. Last time, there was a separate API to do what you are asking called PDT (Payment data transfer). The API has changed a bit since I last used it, and the documentation seems to have moved around since I last downloaded it, but there is still the 'website payments standard integration guide' and 'order management integration guide'. Those still have the instructions you are looking for I think.

The short answer is that generating the encrypted links yourself to build a custom solution is very possible with PayPal, but you do have to do some work to make it happen. The docs are hard to find on the site

Railscast 143 (Paypal security) resulting in We were unable to decrypt the certificate id.

I repeated the entire process a few more times, and it started working. Also reviewed each value in a process similar to the next answer. Unfortunately, any time I switch deployment platforms, I seem to run into the same issue. And eventually, it starts working again.

PayPal API With ActiveMerchant (Legacy Code)

PayPal only allows you to use one or the other. It may have been that the previous person generated the cert or signature and added it to the code, only to switch over to the other method at a later date and never removed it from the code. If it's currently working and processing payments on the PayPal account, you could log into the PayPal account and see which one is currently active on the account. You are only going to see one or the other. Which ever one you are seeing, means the other one would not be being used. If it's not showing, it would not be valid anymore.

Another option, would be you could walk thru the code and see where the API call is being made, and check which one it is sending across to PayPal.

Is there a PayPal IPN code sample for Ruby on Rails?

I post here my working code sample for a Rails controller. It does verification. I hope it will be useful.

class PaymentNotificationsController < ApplicationController
protect_from_forgery :except => [:create] #Otherwise the request from PayPal wouldn't make it to the controller
def create
response = validate_IPN_notification(request.raw_post)
case response
when "VERIFIED"
# check that paymentStatus=Completed
# check that txnId has not been previously processed
# check that receiverEmail is your Primary PayPal email
# check that paymentAmount/paymentCurrency are correct
# process payment
when "INVALID"
# log for investigation
else
# error
end
render :nothing => true
end
protected
def validate_IPN_notification(raw)
live = 'https://ipnpb.paypal.com/cgi-bin'
sandbox = 'https://ipnpb.sandbox.paypal.com/cgi-bin'
uri = URI.parse(sandbox + '/webscr?cmd=_notify-validate')
http = Net::HTTP.new(uri.host, uri.port)
http.open_timeout = 60
http.read_timeout = 60
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.use_ssl = true
response = http.post(uri.request_uri, raw,
'Content-Length' => "#{raw.size}",
'User-Agent' => "My custom user agent"
).body
end
end

Code is inspired by Railscast 142 and this post by Tanel Suurhans

Delivery status Failed notify_url IPN in ruby on rails

Did you set your system encoding in PayPal account? It's somewhere under 'PayPal button encoding' in your profile, and you should set 'Send the data to me in the same encoding' to UTF-8.

As was discovered in comments, another error was due to misconfigured mailer. Note that #render call doesn't send data to client immediately, it just queues it until action ends.

Is it possible with any payment interface to keep cards on file to charge on demand?

Storing credit card information on your side is not practical for two reasons - security and cost (PCI compliance). Your best option is to use Stripe or Braintree.

Both offer great libraries and work as payment aggregators (no need for a merchant account with a bank to start processing payments).

https://stripe.com/docs/api#cards

https://developers.braintreepayments.com/ios+ruby/sdk/server/payment-method-management/create



Related Topics



Leave a reply



Submit