[ic] custom payment module works

Glenn McCalley glenn at bnetmd.net
Fri Aug 21 16:40:09 UTC 2009


So I wrote a custom payment module!
Learned a lot about IC in the process.
Thanks to Gert van der Spoel for several suggestions that triggered things 
to try.  Beer owed.

I started with the AuthorizeNet module (copied AuthorizeNet.pm to CMDI.pm) 
as the processor I needed to use would accept a name=value array.  Not sure 
where this would have gone if they needed XML.

I had a Perl program that could be executed from the command line and would 
successfully process a payment.  That was a huge benefit as I was able to 
see what their responses look like using that.  Changed the code to make 
that program into a subroutine (sub post_cmdi ) which I added to CMDI.pm. 
This replaced the use of Payment.pm to actually process the payment. 
Changed the line "post_data()" (the original call to Payment.pm) to 
"post_cmdi()".

Then had to parse CMDI's response (which is far simpler than AuthNet's which 
allowed a bunch of code to be ripped out), and used that result to set 
MStatus as 'success' or 'failure' just like before.  Parsed out an error 
code that they supply and added a short hash of messages indexed by the 
error code to set ErrorMsg so it will show up on the checkout page in the 
case of failure.

So now payments process through these jokers.
Then they call and say "that's great and oh by the way can you also pass us 
the items and quantities with the charge, we'd like to track that".  Here's 
an XML construct to put into a name/value pair to do that.  Damn, never had 
to work with cart detail.

Google is my friend, found an 8 year old post by "Chris and Ben" on this 
list that talked about $Vend::Session{carts}{main}[n]{code} and bashed that 
into a cart listing routine out of which comes an XML string to do the job.

So it works, now to get on to the auto-add item at checkout to round up a 
purchase to the next even $10.00 as a contribution to the cause.  I think 
I'll take Saturday off though.

Glenn.







More information about the interchange-users mailing list