Hi,

I've redeveloped the PX Post module quite a bit to use proper XML writers and parsers, and also to support additional transaction modes such as auth-complete and refund (not recurring payments yet though).

The code is now a lot more "correct" and not based so much on the sample code from DPS, which is pretty ugly.

The patched code will require PHP5, but drops the Curl requirement as it now uses drupal_http_request() instead.

Changes:

  • Removed menu callbacks - these appeared to be from PXPay and are not relevant to PxPost
  • Update hook_payment_gateway() to support extra credit_txn_types, and made necessary code changes to support these too
  • Rewrote the charge function to properly format dates and use XMLWriter to ensure characters are properly escaped (was possible to have invalid XML before since Ubercart doesn't HTML escape the fields passed in, eg. CardHolderName)
  • Swapped Curl out for drupal_http_request, which is capable enough for this purpose and ships with Drupal
  • Parse resulting XML using SimpleXML rather than the old XML parser. Correctly detect parse errors.
  • Removed superfluous uc_dps_pxpost_complete() menu callback function that does nothing with the hook_menu() removed
  • Stored/logged the actual approval code, rather than "PURCHASE" (TxnType)

I hope these changes are welcome. I'm happy to work on the patch some more if you're not happy with it.

This work was sponsored by New Zealand Post.

CommentFileSizeAuthor
uc_pxpost-improvements.patch12.39 KBneilnz

Comments

gbilski’s picture

Thank you for this patch, it fixed the issue I was having with the GST module enabled.

gbilski’s picture

I had to change line 154 (after patching) to be
$xml->writeElement('Amount', number_format($amount, 2, '.', ''));
adding the extra stuff after the 2 to handle amounts in the thousands.
The code would send a comma to indicate thousands which made the DPS payment fail.

Gary

neilnz’s picture

Thanks, I'm glad you discovered this!

We just went live with nzpost.co.nz today without this change, so now scrambling :)

xurizaemon’s picture

Status: Needs review » Fixed

Applied Neil's patch, gbilski's number_format fix, and added a requirements check for SimpleXML.

These changes will be available in 6.x-1.x-dev shortly.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.