weboutreach has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks, I have a perplexing problem. I need to integrate BarclayCard's ePDQ credit card authentication system (you know, the rather pointless Verified by Visa/Mastercard SecureCode thing) with an existing Perl shopping card I wrote. The Perl isn't the problem. The problem is that Barclaycard, in their wisdom, provide an API in C++ or Java. I don't do either - I do Perl or PHP! However, I thought using XS might be the answer, creating my own Perl library interfacing to the supplied shared object file (which I don't have the source for of course, but do have a header file). I have taken a look at the manpage perlxstus and am now even more confused! Anyone have any ideas where to start? I basically need to make a Perl interface to a shared object where I don't even have the source code (but do have the header file). The header file is 1734 lines long so I can't post it here, but I'm posting a snippet here:
MS_API_EXTERN int xfortInitializePAReqBuffer(unsigned int uPAReqBufLen, asc7char *pPAReqBuf, XFortCreatePAReqResult *result, asc7char *szErrMsgBuf, unsigned int uErrMsgBufLen);
Thanks in advance, oh wise ones! Neil p.s. At least the header file is well documented!

Replies are listed 'Best First'.
Re: Integrating ePDQ C++ library using PerlXS
by ForgotPasswordAgain (Vicar) on Jan 07, 2008 at 10:17 UTC

    The source isn't necessary as long as you can link to the library files (.dll or .so). However, from the example you give, you might have some work ahead of you, depending on how complicated XFortCreatePAReqResult is. My best advice is to copy+paste shamelessly from existing Perl C++/XS projects, for example http://search.cpan.org/dist/Lucene/ or http://search.cpan.org/dist/Wx/ (I also have two, http://search.cpan.org/dist/Mozilla-DOM/ and http://search.cpan.org/dist/Ogre/, but I don't necessarily recommend them as good examples... :) ).

    By the way, I'm interested in knowing what other examples of C++ libraries there are (edit: sorry, I meant C++ libraries with Perl XS bindings), or ways of finding out. Also I'm interested in someone porting Py++ to Perl/XS.

      Thanks for that, really helpful. I'll go and study the examples!

      I didn't think it would be that simple, and the header file does have a lot of functions, not all of which will be needed of course.

      My real question is does my client really want to pay for my time to explore this, or do we ditch ePDQ and change payment provider!

      Thanks for your comment anyway - if I manage to get it working I will, of course, post my results here!

      Neil