Add support for the new MAC field / keys replacing the MD5 field for new DIBS accounts, see http://tech.dibs.dk/parameters/.

Comments

beltofte’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
gnucifer’s picture

StatusFileSize
new28.71 KB

I needed to get the module up to date for a project, so implemented hmac support and fixed some other stuff. The module was apparently using an old endpoint url for "Payment Window"-method. Patch is perhaps not ready to be committed without some proper review and cleanup. I also made som minor changes to API, and some code refactoring. I will need better support for dibs status codes etc, so will probably make som more changes and upload a new patch later on.

googletorp’s picture

Status: Active » Needs work

It looks like you are doing a minor refactor in addition to adding hmac support. Try to limit the patch to actually only add the hmac support and if there are places where you think the code could or should be improved, add a seperate case and patch for that, so we don't have to make and all or nothing call.

For the hmac support needs to be added as an optional feature so users can use either hmac or the older md5 keys to not breakte existing solutions. For what I can tell this in a quick review, this replaces the md5 option entirely.

gnucifer’s picture

My patch does not remove md5-support, though I accidently removed the admin form validation for the md5-settings. I have fixed this in my local version and will upload a new path. The refactoring was mostly necessary in order to implement the hmac-support. And the the API-breakage can be reversed by uncommenting the code on line 245 in dibs.frontend.inc. The reason I removed the hook_dibsapi_form_alter is partly because one could use the general hook_form_alter to achieve the same result, but mostly because any changes to the form data will break the hmac/md5 validation. I will just fix some mistakes I made in the original patch, so ignore the first patch for now.

gnucifer’s picture

StatusFileSize
new44.71 KB

Uploading a new patch even though it is not 100%. Have tested and verified most of the functionallity. Feel free to review the changes, though I will probably work on this some more.

gnucifer’s picture

StatusFileSize
new44.4 KB

Removed some irrelevant comments.

gnucifer’s picture

Sorry about the large patch, but right now I don't have the time to split this into smaller issues and thought it better contributing all my changes than not sharing them at all.

beltofte’s picture

Releasing 7.x-1.0 today, and creating a new branch for the development of 7.x-2.x, where the new Payment Window will replace PayWin. Some of the changes from the big patch can also be implemented in this new dev version.

beltofte’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
gnucifer’s picture

I have fixed some more bugs in the patch in #6 since last time. But I can only access the code at work. On monday I can try to upload a new patch against latest dev with these changes if I can allocate anough time.

gnucifer’s picture

One thing that would be good to put in the roadmap for the 3.x-branch is to convert transactions into entities. This would greatly simplify tighter integration with for example rules and views. If you want you could delegate that task to me and I could try to work on an patch for this later.

gnucifer’s picture

StatusFileSize
new49.4 KB

Sorry about the delay, here comes the latest revision of the "monster"-patch against 7.x-2.x-dev:

Some of the changes are:

  • Instead of building data for payment window and flexwin as form components, first build the data itself, then generate the form. We need to do this to have a cleaner way of handling the params for things like hmac-generation etc.
  • Cleaned up the code handling hashing/signing, broken out in separate unctions
  • Minor corrections of code formatting here and there
  • Provided PHP-constants for some constants
  • Refactored to avoid code duplication in dibs response handing.
  • Added field to dibs-transaction for remote dibs transaction status
  • Changed gateway urls to the ones provided most recent version of dibs documentation
  • Started to implement more integration with dibs transaction statuses etc
  • Changed to the new version of payment window
  • HMAC validation support

+ Probably lots of more minor changes that I can't think of right now.

Some more problems that needs to be addressed:

  • Order-line format for the new payment-window is very different than for flexwin, need to handle this
  • The language parameter for flexwin also differs, needs to be fixed

And most important of all:
This patch also contains a quick-fix for a problem I encountered just a few days ago. Perhaps I should have reverted this change, but was to lazy to do so. Plus it might be a critical bug. To not clutter this thread even further I will create a separate issue for this and link to in this comment in the next hour or so.

EDIT: link to new issue: http://drupal.org/node/1866686

gnucifer’s picture

I created a github-repo where I will maintain a branch with all of these changes. Next I will try to implement transactions as entities: https://github.com/david-xelera/dibs

gnucifer’s picture

A warning: Right now there is a major issue with this branch (in http://drupal.org/node/1866688). Don't use in production until this is fixed!

gnucifer’s picture

The issue is now addressed. The fix required a database scheme change, but there is currently no upgrade path in my development version! So if you are using my 2.x-branch (https://github.com/david-xelera/dibs) (which you shouldn't unless you really know what you're doing) for now the only solution is to re-install or alter the database manually.