Commit daa569e9 authored by obsidiandesign's avatar obsidiandesign

#756600 by garethsprice - prevent submission for an authorization when validation

 of the webform fails.
#526658 by justin_vt - allow fieldsets up to three levels deep for the webform.
parent b52ee2ad
......@@ -237,8 +237,12 @@ function authorizenet_create_custom_field_spec($custom_fields) {
*/
function authorizenetwebform_process($step, $node, $form, $form_state) {
module_load_include('inc', 'authorizenetwebform', '/authorizenetwebform_fields');
$form_values = $form_state['values'];
// DO NOT forward to Authorize.net if there are errors in the form validation
if (form_get_errors()) {
return $form_state;
}
$wfkeys = array();
$wfkeys[0] = "";
......@@ -259,15 +263,40 @@ function authorizenetwebform_process($step, $node, $form, $form_state) {
if (array_key_exists(strtolower($mkey), $form_values['submitted_tree'])) {
$submission[$mkey] = $form_values['submitted_tree'][strtolower($mkey)];
}
else {
foreach ($form_values['submitted_tree'] as $fkey => $fvalue) {
if (is_array($fvalue)) {
if (array_key_exists(strtolower($mkey), $fvalue)) {
$submission[$mkey] = $form_values['submitted_tree'][$fkey][strtolower($mkey)];
}
else {
foreach ($fvalue as $gkey => $gvalue) {
if (is_array($gvalue)) {
if (array_key_exists(strtolower($mkey), $gvalue)) {
$submission[$mkey] = $form_values['submitted_tree'][$fkey][$gkey][strtolower($mkey)];
}
else {
foreach ($gvalue as $hkey => $hvalue) {
if (is_array($hvalue)) {
if (array_key_exists(strtolower($mkey), $hvalue)) {
$submission[$mkey] = $form_values['submitted_tree'][$fkey][$gkey][$hkey][strtolower($mkey)];
}
}
}
}
}
}
}
}
}
}
}
$post_vars = array();
foreach ($submission as $key => $value) {
if (strcmp(substr($key, 0, 2), "x_") == 0 && $value != "") {
$post_vars[$key] = $value;
}
}
// Authorize.Net required field information
$posturl = variable_get('authorizenetwebform_url', NULL);
$post_url = ($posturl == "main") ? "https://secure.authorize.net/gateway/transact.dll" : "https://test.authorize.net/gateway/transact.dll";
......@@ -300,7 +329,6 @@ function authorizenetwebform_process($step, $node, $form, $form_state) {
$post_string .= "$key=". urlencode( $value ) ."&";
}
$post_string = rtrim( $post_string, "& " );
$request = curl_init($post_url); // initiate curl object
curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment