Created a form, set the plug in, set the debug and was pleasantly suprised to see the data send to authorize.net and actually get the expect response (approve with correct credit card data, error with bad credit card data)
While looking through the forums, I saw an earlier poster who wanted to have chronoforms kick the user back to the original form and post an error message. He had one minor error in the code (the RESPONSE_CODE from authorize net is not "1", but ERROR or APPROVE--the response_code_number is 1 or some other number).
What puzzles me beyond that though is when you put the code in the form code BEFORE EMAIL or AFTER EMAIL section, the form does indeed send you back to the form and kick up an error message when authorize.net rejects the card.
But what is very odd is that when authorize.net APPROVES the transaction, the form submits the code twice (before the redirect sends the user to another url)!
What am I missing in this code that would do that. Without the code, the form submits once and all works as expected.
<?php
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
$MyPlugins->runPlugin('after_email', array('ONSUBMIT', 'ONLOADONSUBMIT'), 'cf_Authorize_dotnet');
if($MyPlugins->cf_Authorize_dotnet['response_code'] == 'APPROVE'){
echo "Thank you for your purchase. You will be receiving a confirmation email shortly";
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'enabled', '1');
$MyFormEmails->sendEmails($MyForm, $MyFormEmails->emails);
}else{
$MyForm->addErrorMsg( 'An error occured with the Credit Card Processing:<br />'.$MyPlugins->cf_Authorize_dotnet['response_code'].': '.$MyPlugins->cf_Authorize_dotnet['response_reason_text'] );
$MyForm->haltFunction["autogenerated_after_email"] = true;
}
?>