LiveMetric LLC login · analytics · pricing · features · signup

 

Ruby bindings for Payflow Pro (pfpro4r)

About

pfpro4r is a set of bindings for Verisign's Payflow Pro SDK.

If you're distributing an app in Ruby/Rails and you use Verisign's Payflow Pro, you basically have three options (paraphrased from the RoR Wiki):

  1. Call the Java/Perl/PHP API from Ruby. (Ewww...)
  2. Call Verisign’s command line scripts. (DO NOT DO THIS. This is highly vulnerable to shell injection attacks.)
  3. Code a ruby extension which makes use of the Payflow shared library API and make calls directly from Ruby.

pfpro4r is an implementation of the last option.

Screenshot

static VALUE
pfpro4r_exec (VALUE class,
              VALUE rb_host_addr, 
              VALUE rb_host_port, 
              VALUE rb_parm_list,
              VALUE rb_time_out)
{
  char    *host_addr;
  int     host_port;
  ...  

License & Download

pfpro4r is released under the MIT License. It's our way of saying thanks and giving back to the Ruby community.

Please, if you make improvements, send me a patch so it can get incorporated back into pfpro4r.

Download here

Open Issues

How to compile and install

    $ tar xzvf ~/pfpro_freebsd.tar.gz
    $ ruby extconf.rb
    $ make
    $ make install

After you've installed, the Ruby API is simple! There is one function, Payflow.exec(), which takes a host_name, port_number, parm_list_string, and time_out.

result_string = Payflow.exec("test-payflow.verisign.com", 
                             443, 
                             parm_list,
                             30)

FAQ

  1. Is this supported in any way by Verisign?
    No.
     
  2. Is this supported in any way by LiveMetric LLC?
    No. Your best bet is to post to the rails mailing list and hope that someone else has had a similar problem.
     
  3. But I really need support for this. We are a business and it is critical. What are your rates?
    Please contact service@livemetric.com for consulting projects.
     
  4. When I require pfpro4r, I get the message pfpro4r.so: Shared object "libpfpro.so" not found, required by "pfpro4r.so" - pfpro4r.so (LoadError) . What gives?
    You need to add the directory containing libpfpro.so to your $LD_LIBRARY_PATH.
     
  5. Does it compile on Windows?
    Yes, but it is a horrible experience and you are bound to lose some hair. Good luck.
     
  6. When I run "ruby extconf.rb" on Windows, I get the message ./win32-libmaker.rb:17:in ``': No such file or directory - link -dump -exports ".\verisign\payflowpro\win32\lib\pfpro.dll" (Errno::ENOENT) . What gives?
    You need to set up your VC compiler environment. See WindowsCompiler for more information.
     
  7. When I run "make" on Windows, I get the message 'make' is not recognized as an internal or external command, operable program or batch file.. What gives?
    Use "nmake" instead.
     
  8. When I run "nmake" on Windows, I get the message LINK : fatal error LNK1181: cannot open input file 'msvcrt-ruby18.lib'. What gives?
    Edit the Makefile, changing "LIBRUBYARG_SHARED = $(LIBRUBY)" to "LIBRUBYARG_SHARED = /link /LIBPATH:C:\ruby\lib $(LIBRUBY)", replacing c:\ruby\lib with the path of your ruby install. (I'm sure there's a cleaner solution to this, patches welcome!)

More information