Hi !
I'm trying to read values sent by a form, inside a Hook to process calculation, but I think I don't doing the thing on the right way...
Here my FormIt call with the html code for the form :
[[!FormIt?
&submitVar=`valid`
&hooks=`spam,CalculSignature,redirect`
&redirectTo=`407`
&store=`1`
&validate=`nospam:blank,
vads_cust_last_name:required,
vads_cust_email:email:required
]]
[[!+fi.validation_error_message:notempty=`<p>[[!+fi.validation_error_message]]</p>`]]
<form method="post" action="[[~[[*id]]]]">
<input type="hidden" name="nospam" value="" />
<input type="hidden" name="vads_site_id" value="593211111">
<input type="hidden" name="vads_ctx_mode" value="TEST">
<input type="hidden" name="vads_currency" value="EUR">
<input type="hidden" name="vads_action_mode" value="INTERACTIVE">
<input type="hidden" name="vads_page_action" value="PAYMENT">
<input type="hidden" name="vads_version" value="V2">
<input type="hidden" name="vads_payment_config" value="SINGLE">
<label>Name</label>
<input type="text" name="vads_cust_last_name" value="">
<label>Postal address</label>
<input type="text" name="vads_cust_address" value="">
<label>ZIP code</label>
<input type="text" name="vads_cust_zip" value="">
<label>City</label>
<input type="text" name="vads_cust_city" value="">
<label>Country</label>
<input type="text" name="vads_cust_state" value="">
<label>e-mail adress</label>
<input type="text" name="vads_cust_email" value="">
<label>Phone</label>
<input type="text" name="vads_cust_phone" value="">
<input class="button button-flat-primary" type="submit" value="Valid" name="valid">
</form>
After form validation, I need to read all values of the vads_* fields on a function, to calculate a "signature".
I have a PHP code (not writen by myself!) to doing this :
// Function to calculate signature
// $params : array which contain the fields to send by the form
function getSignature($params){
//Initialisation of the variable which contain the string to be encrypted
$contenu_signature = "" ;
// sort the fields by alphabetical order
ksort($params);
foreach ($params as $nom =>$valeur)
{
// Retreive the vads_ fields
if (substr($nom,0,5)=='vads_') {
// Concatenation with "+" separator
$contenu_signature .= $valeur."+";
}
}
// Adding the certificat on the end
$contenu_signature .= $key;
// SHA-1 algorythm application
$signature = sha1($contenu_signature);
return $signature ;
}
I have tried to transform this piece of code on a hook/snippet "CalculSignature" to works with FormIt :
// Function to calculate signature
// We retreive the array of the sent values
$params = $hook->getValues();
// $params : array which contain the fields to send by the form
function getSignature($params){
//Initialisation of the variable which contain the string to be encrypted
$contenu_signature = "" ;
// sort the fields by alphabetical order
ksort($params);
foreach ($params as $nom =>$valeur)
{
// Retreive the vads_ fields
if (substr($nom,0,5)=='vads_') {
// Concatenation with "+" separator
$contenu_signature .= $valeur."+";
}
}
// Adding the certificat on the end
$contenu_signature .= $key;
// SHA-1 algorythm application
$signature = sha1($contenu_signature);
// We set the calculated signature on the placeholder [[+signature_calculated]] to be retreive on next step by FormItRetriever
$hook->setValue('signature_calculated', $signature);
}
// We are ending the Hook
return true;
But my hook doesn't works : after sending the form, the placeholder [[+signature_calculated]] is empty and I don't understand why...
What I'm doing wrong ?
[ed. note: Spheerys last edited this post 6 years, 8 months ago.]