diff --git a/htdocs/langs/en_US/paybox.lang b/htdocs/langs/en_US/paybox.lang index 269242b910b..d3c26c8e65a 100644 --- a/htdocs/langs/en_US/paybox.lang +++ b/htdocs/langs/en_US/paybox.lang @@ -37,3 +37,4 @@ PAYBOX_PAYONLINE_SENDEMAIL=Email notification after payment attempt (success or PAYBOX_PBX_SITE=Value for PBX SITE PAYBOX_PBX_RANG=Value for PBX Rang PAYBOX_PBX_IDENTIFIANT=Value for PBX ID +PAYBOX_HMAC_KEY=HMAC key \ No newline at end of file diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index 3c761b930e3..abad76ce228 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -73,7 +73,7 @@ if ($action == 'setvalue' && $user->admin) if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYBOX_HMAC_KEY", dol_encode(GETPOST('PAYBOX_HMAC_KEY', 'alpha')), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error++; - + if (! $error) { @@ -151,7 +151,7 @@ print ''; print ''; print ''.$langs->trans("PAYBOX_HMAC_KEY").''; print ''; -print '
'.$langs->trans("Example").': 2 ('.$langs->trans("Test").')'; +print '
'.$langs->trans("Example").': 1A2B3C4D5E6F'; print ''; print ''; @@ -181,7 +181,8 @@ print ''; print ''; print ''.$langs->trans("PAYBOX_CGI_URL_V2").''; print ''; -print '
'.$langs->trans("Example").': http://mysite/cgi-bin/modulev2_redhat72.cgi'; +print '
'.$langs->trans("Example").' (preprod): https://preprod-tpeweb.paybox.com/php/'; +print '
'.$langs->trans("Example").' (prod): https://tpeweb.paybox.com/php/'; print ''; diff --git a/htdocs/paybox/lib/paybox.lib.php b/htdocs/paybox/lib/paybox.lib.php index 7dca957e489..2d9eceb4a5f 100644 --- a/htdocs/paybox/lib/paybox.lib.php +++ b/htdocs/paybox/lib/paybox.lib.php @@ -78,15 +78,15 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) return -1; } + $conf->global->PAYBOX_HASH = 'sha512'; + // Definition des parametres vente produit pour paybox - $IBS_CMD=$TAG; + $IBS_CMD=$TAG; $IBS_TOTAL=$PRICE*100; // En centimes $IBS_MODE=1; // Mode formulaire $IBS_PORTEUR=$EMAIL; $IBS_RETOUR="montant:M;ref:R;auto:A;trans:T"; // Format des parametres du get de validation en reponse (url a definir sous paybox) $IBS_TXT=' '; // Use a space - $IBS_BOUTPI=$langs->trans("Wait"); - //$IBS_BOUTPI=''; $IBS_EFFECTUE=$urlok; $IBS_ANNULE=$urlko; $IBS_REFUSE=$urlko; @@ -102,7 +102,9 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) $IBS_OUTPUT='E'; $PBX_SOURCE='HTML'; $PBX_TYPEPAIEMENT='CARTE'; - + $PBX_HASH = $conf->global->PAYBOX_HASH; + $PBX_TIME = dol_print_date(dol_now(), 'dayhourrfc', 'gmt'); + $msg = "PBX_IDENTIFIANT=".$PBX_IDENTIFIANT. "&PBX_MODE=".$IBS_MODE. "&PBX_SITE=".$IBS_SITE. @@ -122,11 +124,13 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) "&PBX_OUTPUT=".$IBS_OUTPUT. "&PBX_SOURCE=".$PBX_SOURCE. "&PBX_TYPEPAIEMENT=".$PBX_TYPEPAIEMENT; - + "&PBX_HASH=".$PBX_HASH; + "&PBX_TIME=".$PBX_TIME; + $binKey = pack("H*", dol_decode($conf->global->PAYBOX_HMAC_KEY)); - - $hmac = strtoupper(hash_hmac('sha512', $msg, $binKey)); - + + $hmac = strtoupper(hash_hmac($PBX_HASH, $msg, $binKey)); + dol_syslog("Soumission Paybox", LOG_DEBUG); dol_syslog("IBS_MODE: $IBS_MODE", LOG_DEBUG); @@ -147,10 +151,12 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) dol_syslog("PBX_IDENTIFIANT: $PBX_IDENTIFIANT", LOG_DEBUG); dol_syslog("PBX_SOURCE: $PBX_SOURCE", LOG_DEBUG); dol_syslog("PBX_TYPEPAIEMENT: $PBX_TYPEPAIEMENT", LOG_DEBUG); + dol_syslog("PBX_HASH: $PBX_HASH", LOG_DEBUG); + dol_syslog("PBX_TIME: $PBX_TIME", LOG_DEBUG); header("Content-type: text/html; charset=".$conf->file->character_set_client); header("X-Content-Type-Options: nosniff"); - + print ''."\n"; print ''."\n"; print "\n"; @@ -182,6 +188,9 @@ function print_paybox_redirect($PRICE, $CURRENCY, $EMAIL, $urlok, $urlko, $TAG) print ''."\n"; print ''."\n"; print ''."\n"; + print ''."\n"; + print ''."\n"; + // Footprint of parameters print ''."\n"; print ''."\n"; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 7eea7e45df6..145df4f9e94 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -355,7 +355,7 @@ if ($action == 'dopayment') if ($paymentmethod == 'paybox') { $PRICE=price2num(GETPOST("newamount"), 'MT'); - $email=GETPOST("email", 'alpha'); + $email=$conf->global->ONLINE_PAYMENT_SENDEMAIL; $thirdparty_id=GETPOST('thirdparty_id', 'int'); $origfulltag=GETPOST("fulltag", 'alpha'); @@ -754,7 +754,7 @@ if (! empty($conf->paypal->enabled)) } if (! empty($conf->paybox->enabled)) { - + print ''."\n"; } if (! empty($conf->stripe->enabled)) {