Forums

does $emails[0]->enabled = 0; not send to authorize.net?

samoht 11 Dec, 2008
hello again,

I have a recurring problem every no and then with authorize.net approving a transaction that my form registers as being rejected on the basis of an expired card.
To fix this issue I thought of two things:

1. set the card expiration month and year to always be greater than today.

2. check to see if I am sending authorize.net two submissions.

I am not sure how to set up the code to display an array of numbers that start from today etc - so I went to check the #2 option and I was curious. I have
<?php
global  $cf_AUTHNET_response_code, $cf_AUTHNET_response_subcode, $cf_AUTHNET_response_reason_code, $cf_AUTHNET_response_reason_text, $cf_AUTHNET_approval_code, $cf_AUTHNET_avs_result_code, $cf_AUTHNET_transaction_id;

// If the form has just been submitted  
// re-display with Edit & Pay buttons 
if ( $_POST['submit'] == 'Process') { 
    $_POST['submit'] = 'Confirm'; 
    $error_found = true;
$emails[0]->enabled = 0; 
    showform($_POST); 
} elseif ( $_POST['submit'] == 'Edit') { 
    $_POST['submit'] = 'Submit'; 
    $error_found = true;
$emails[0]->enabled = 0; 
    showform($_POST); 
} elseif ( $_POST['submit'] == 'Pay') {

 $_POST['AUTHNET_response_code'] = $anet_response_code;
 $_POST['AUTHNET_trans_id'] = $anet_trans_id;

    if($cf_AUTHNET_response_code == 'Declined'){
    $rows[0]->emailresults = 0;
    }

    echo '<p style="font-size:2em; font-weight:bold;">' .$cf_AUTHNET_response_code .'</p>';
    if ($cf_AUTHNET_response_code == 'Declined' || $cf_AUTHNET_response_code != 'Approved') {
      echo '<p>Sorry your transaction was declined by the payment gateway.<br>Please try again.</p>';
    }else{
      echo '<h5>Thank-you for your submission.<br> An email confirmation should be sent to you shortly.</h5>';
    }    
  echo '<p align="center"><a href="javascript:window.close();">Close Window</a></p>';

}
?>

On Submit Before sending email, and I have authorize.net plugin set to go before sending email. $emails[0]->enabled = 0; keeps the form from sending email but does it still send to authorize.net??
Max_admin 12 Dec, 2008
Hi samoht,

can't understand whats the issue is!

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 12 Dec, 2008
Sorry about that.

the code snippet is from the On Submit Before email block and just handles the different stages of the form. Since I have a confirmation page the user fills out the form then hits "Process" (submit) and this takes the form to the confirmation stage - if all is good the user hits "Pay" and that should send a request to authorize.net and then if authorize.net accepts the transaction an email should be sent to the client. For some reason the form was occasionally sending an email to the client that said the transaction was denied based on an expired card - but when the client check authorize.net the transaction went through just fine. I called authorize.net and they said everything is working just fine on their end. So I figured that I must have a duplication problem going on somewhere.

I am using $emails[0]->enabled=0; to stop the form from submitting the fist time through before the confirm page - but I wondered if the data was still getting sent to authorize.net?
GreyHead 12 Dec, 2008
Hi samoht,

You probably need to use $error_found = true; - see earlier in your code. This should prevent any further processing after the OnSubmit code.

The $emails[0]->enabled=0; code only skips the email step.

Bob
Max_admin 12 Dec, 2008
Hi samoht,

once the form is submitted the first time before displaying the confirmation page, all processing will be in action, you need to submit to another form, thats the easy way, then got to authorize from there, the $error_found = true; will work in versions before V3.0 but in V3.0 it will block only the email and not the data saving unless you disable the data saving too!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 12 Dec, 2008
So the first form would collect all the info and write it to the database - then the second form would display that info for confirmation and on submit would send the info to authorize.net and email the form - right?

but how would the user return to the form to "edit" if they see a mistake in the confirm form?
GreyHead 12 Dec, 2008
Hi Max,

Are you sure about $error_found ?? I just checked the code and I think it should still skip the plugins and the autogenerated code. It think it goes from line 511 (or thereabouts) to line 578.

Bob
samoht 12 Dec, 2008
OK,

So if I use 2 separate forms - how do I grab the confirmation form from the input forms submit?
Would that be a custom action? or a redirect ??
samoht 13 Dec, 2008
Well I'm close.

I have the two forms working. On the first form I just send the user to the second form using the redirect url.

Then I query the db for the lasted form entry to display for confirmation - and the second form comes up with the right info. Only problem is the edit button on the second form needs to go back to the first form. And once there it maybe that the user is no longer the latest form entry - so when redirected to the confirmation form the info displayed could be wrong.
Please advise.

I have attached a bcakup of both forms (form 1 = giftcard_submit; form 2 = authorize_and_email)
Max_admin 14 Dec, 2008
Hi Bob,

You are correct, I missed this! 😲 🙂

@samoht, you can make the edit link point to the first form and attach the record id to the link and query the record in the first form and display the data, what do you think ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.