We have a working patch to 1.1 to allow use of 'HMAC'

Short: it removes the need for the CGI module when not using PAYBOX DIRECT(PPPS) method.

The problem we see here with PPPS is we don't want to see the client's card number on our servers (aka let paybox make their job - keeping transaction secure)

Status: code is there. maybe some improvements to add to admin interface (I removed CGI's need as HMAC key can be sufficient when provided. Dunno how to write this in admin.inc for now.

Please rewiew/test this: nothing working before should break, and HMAC method should work :)

Comments

dgeo’s picture

Assigned: Unassigned » dgeo
simon georges’s picture

Just a note: there already is no need for the CGI module if you use the PPPS method for Paybox. Anyway, I'll let you work on the patch. Thanks!

dgeo’s picture

Yes, but PPPS method would force us to get payment informations, and we prefer not to be responsible for them :)

dgeo’s picture

StatusFileSize
new9.03 KB

Here it is: seems to work for us®

Please take a look as we aren't really drupal-skilled…

dgeo’s picture

StatusFileSize
new9.03 KB

Well-named patch…

dgeo’s picture

Issue summary: View changes
Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: commerce_paybox-HMAC-2351971-4-7.x.patch, failed testing.

dgeo’s picture

StatusFileSize
new8.76 KB

well-formed git patch…

dgeo’s picture

Status: Needs work » Needs review
dgeo’s picture

Version: 7.x-1.1 » 7.x-1.x-dev

New patch is against 1.x-dev version (though unmodified since 1.1)

dgeo’s picture

StatusFileSize
new8.57 KB

adjusted admin interface. Should be understandable for everyone, HMAC is marked as 'preferred' method for Paybox System offsite.

dgeo’s picture

grimreaper’s picture

Hello,

Thanks for the patch.

I test without it, and the offsite payment method fail, in the error message it says that it require the CGI bin.

I don't know if I can test with it because I don't have paybox account. Is there an API provided by paybox to have a test gateway ?

I review your patch, I don't have a lot of things to say : mainly coding style standards, and the next point.

+++ b/commerce_paybox.module
@@ -229,51 +229,85 @@ function commerce_paybox_offsite_redirect_form($form, &$form_state, $order, $pay
+    // code as paybox's example to generate HMAC key
+    $keyTest = variable_get('commerce_paybox_hmac_key','');
+    $binKey = pack("H*", $keyTest);
+    $hash = strtolower($pbx_params['PBX_HASH']);
+    $hmac = strtoupper(hash_hmac($hash, $msg, $binKey));
+    $pbx_params['PBX_HMAC'] = $hmac;

I don't understand this part as there is already a variable_get to go in this part of the if ... else .. statement

Thanks for the patch.

EDIT : maybe in the .install file, you should add variable_del for the new variables you introduce.

dgeo’s picture

unfortunately, testing api on their side seems to be accessible only for clients. Maybe they can understand the problem and open a test-only account for this module ?

I'll have a look quickly to your suggestions. Thank you for feedback !

dgeo’s picture

StatusFileSize
new9.04 KB
  • removed one variable_get
  • Added two variable_del in .install
  • Better respect coding standard
dgeo’s picture

StatusFileSize
new9.04 KB

error in variable commerce_paybox_alg corrected in .install

grimreaper’s picture

StatusFileSize
new9.58 KB

Hello,

I attach a patch where I have fixed all the coding styles issues to not losing time in long patch exchanges.

The problems were mostly:

  • array('value1','value2') => array('value1', 'value2') : space after comma
  • Comments should starts with a capital letter and end with a point
  • indentation as tabulations instead of spaces
  • no capital letters in variable name
  • space before and after '=' sign and concatenation

I have nothing else to say.

I can't help you any more because I can't test if it is functionnal with the paybox API.

Thanks for your patch. Hoping it will be merged as soon as possible :)

dgeo’s picture

thank you Grimreaper :)
I'll try to better respect those rules next time…

seren10pity13’s picture

Hi !

thank you very much dgeo, that's just what I needed and it saved me a lot of work !
I just had to change one thing in your patch : The $hmac musn't be in lowercase as it is set in uppercase in the form. This causes the Paybox system to return an error cause it makes the the hash and the form data different.

   // Code as paybox's example to generate HMAC key.
   $binkey = pack("H*", $hmac_key);
-  $hash = strtolower($pbx_params['PBX_HASH']);
+  $hash = $pbx_params['PBX_HASH'];
   $hmac = strtoupper(hash_hmac($hash, $msg, $binkey));
   $pbx_params['PBX_HMAC'] = $hmac;
}

Except that point, your patch worked like a charm !

Mantalo Conseil’s picture

Hello,

Is this patch will be add to a new release soon ??

Thanks.

simon georges’s picture

If I understand correctly, this patch removes the need for a CGI module, am I right?

Since several people are confirming it works, I'm willing to commit it. But I'm unable to release a new version (I have not the right), so it will live in the -dev version for now...).

seren10pity13’s picture

Yes, that's it. This removes the need of CGI module.
Thanks for the dev !

dgeo’s picture

@seren10pity13: I don't agree with #20: the $hash variable will just be used in hash_hmac function call. The form element will still be $pbx_params['PBX_HASH'] (uppercased).

Furthermore this code works here with paybox tests servers AND production ones… Could you double-check this change is needed for you ?

If you need it, could you please provide more details about your install (php version, OS, output of <?php print_r(hash_algos()); to see if they are uppercased here)
Working here under FreeBSD 9 & 10, debian wheezy, php 5.4, php 5.3. algorithmes list:

<?php
print_r(hash_algos());
Array
(
    …
    [4] => sha224
    [5] => sha256
    [6] => sha384
    [7] => sha512
    …
)

Thank you, hope this can be included after double-checking this !

dgeo’s picture

Issue summary: View changes
dgeo’s picture

Status: Needs review » Reviewed & tested by the community
jcisio’s picture

Assigned: dgeo » Unassigned
Priority: Normal » Major
StatusFileSize
new42.83 KB
new2.15 KB

Works as expected. I check the algo and if is ok. All listed HMAC algos are supported in the first version of PHP where hash_hmac() was introduced.

In the attached patch there are a few more modification: correct some words and rename variables to match their meaning, so I'll keep the issue as RTBC.

jcisio’s picture

StatusFileSize
new8.96 KB

Ooops the patch was diff'ed against master instead of 7.x-1.x.

jcisio’s picture

The last submitted patch, 27: pbx_hmac_method-2351971-27.patch, failed testing.

The last submitted patch, 27: interdiff.diff, failed testing.

dgeo’s picture

Please commit (may I help ?)

simon georges’s picture

Status: Reviewed & tested by the community » Fixed

Alright, committed. Let me know if the -dev version (in a few hours) is correctly working, I'll eventually tag a new one.
Thanks for all the work and collaboration on the issue, and my apologies for the delay!

Status: Fixed » Closed (fixed)

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

pvasener’s picture

Status: Closed (fixed) » Needs work
StatusFileSize
new423 bytes

The latest -dev version doesn't work for me. I don't want to use the PBX_HMAC method so, I let the key empty but I have an 'unknown shop' error when I'm redirected to the Paybox page. I found a missing line in the code. Here is a patch which solved my problem.

dgeo’s picture

StatusFileSize
new652 bytes

@pvasener: sorry, you're right I broke CGI :(

Here is a patch against current -dev that should (please test it !) correct this: the line you added already exist in the code, it just needed another

else {}

Give it a try and report…

dgeo’s picture

Status: Needs work » Needs review

to test the last patch

grubshka_v2’s picture

HMAC method works well for me, thanks for your patch !

  • Simon Georges committed 406797a on 7.x-1.x authored by dgeo
    Issue #2351971 by dgeo, jcisio, Grimreaper, pvasener: PBX_HMAC method
    
arnaud.dabouis’s picture

Status: Needs review » Fixed

The patch has been applied to the dev branch, switching it to fixed.

Status: Fixed » Closed (fixed)

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

dgeo’s picture

Could this be an occasion to release a new stable version ?