Forums

How to stop submission to Authorize.net

pjgeorge 20 Jul, 2011
Hello, I have a payment form that has an option: "Mail a Check". If the user selects that, then I do not want to submit anything to authorize.net and just print the thank you message. Currently I am just ignoring the error that returns from authorize.net. Is there a way to skip the authorize.net processing completely and just go straight to my "On Submit code - after sending email" code block? (That's where I look at the payment type and (if necessary) authorize.net response code and print the thank you page). Here's the code... Thanks for any input on this.


<?php
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
$MyPlugins->runPlugin('after_email', array('ONSUBMIT', 'ONLOADONSUBMIT'), 'cf_Authorize_dotnet');

$msg = "";

$printThanks = "yes";

if ( $MyPlugins->cf_Authorize_dotnet['response_code'] == 'Approved' ) {
    $msg = "Credit Card Transaction Approved.<br><br>Thank you for signing up for a Corporate Membership! You should be receiving a confirmation email very soon. If you have any questions, please do not hesitate to contact us.";
}
else {
    if ( JRequest::getVar('payment_method') == "Mail_a_Check" ) {
       $msg = "Thank you for signing up for a Corporate Membership!  Please see below for instructions for mailing your check.";
    }
    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;
    	$printThanks = "no";
    }
}
  

if ( $printThanks == "yes" ) { ?>
	<h1>Thank you!<h1><div style='font-size: 18pt;'><?=$msg ?></div>
	<br/>
	<div style='font-size: 14pt;'>
		<b>Membership details:</b>
		<table>
			<tr style='font-size: 14pt;'><td>Company Name:</td><td>{co_name}</td></tr>
			<tr style='font-size: 14pt;'><td>Company Rep:</td><td>{rep}</td></tr>
			<tr style='font-size: 14pt;'><td>Address:</td><td>{addr}</td></tr>
			<tr style='font-size: 14pt;'><td>City:</td><td>{city}</td></tr>
			<tr style='font-size: 14pt;'><td>State:</td><td>{state}</td></tr>
			<tr style='font-size: 14pt;'><td>Zip:</td><td>{zip}</td></tr>
			<tr style='font-size: 14pt;'><td>Country:</td><td>{country}</td></tr>
			<tr style='font-size: 14pt;'><td>Phone:</td><td>{phone}</td></tr>
			<tr style='font-size: 14pt;'><td>Email:</td><td>{email}</td></tr>
			<tr style='font-size: 14pt;'><td>Fax:</td><td>{fax}</td></tr>
			<tr style='font-size: 14pt;'><td>Membership Level:</td><td>{membershipType}</td></tr>
			<tr style='font-size: 14pt;'><td>Payment Method:</td><td>{payment_method}</td></tr>
			<tr style='font-size: 14pt;'><td>Total Amount:</td><td>{total}</td></tr>
			<tr style='font-size: 14pt;'><td>Membership Description:</td><td>{description}</td></tr>
		</table>
	</div>
	
	<br/>
	
	<div  style='font-size: 12pt;'>
		If you chose to Mail A Check, please send a check made out to ASGSB to:
		<p style="text-align: center;">
			<span style="color: #000000; font-family: 'arial black', 'avant garde'; font-size: 12pt;">
				American Society for Gravitational and Space Biology<br/>
				P.O. Box 27057<br/>
				Washington, D.C. 20038-7057
			</span>
		</p>
	</div>
<?}?>
pjgeorge 20 Jul, 2011
Ok, I found the "Extra before onsubmit code" block in the Authorize.net plug-in page. I added this code:

<?php
if ( $_POST['payment_method'] == "Mail_a_Check" ) {
  echo "User is mailing a check!!!<br/>";
}
else {
  echo "User is NOT Mailing a Check - CREDIT CARD<br/>";
}
?>


and it successfully prints the echo statements above the authorize.net debug out put code. (eg:

User is mailing a check!!!
x_login=3R9nH9xbSQ&x_version=3.1&x_delim_char=%7C&x_delim_data=TRUE&x_url=FALSE&x_type=AUTH_CAPTURE&x_method=CC&x_tran_key=5DNpRF3B8D5z72t5&x_relay_response=FALSE&x_card_num=&x_exp_date=&x_description=ASGSB+Corporate+Membership+Gold+Level.&x_first_name=&x_last_name=&x_amount=6000&x_address=12216+Wheat+Mill+Loop&x_city=Bristow&x_state=VA&x_zip=20136&x_invoice_num=&x_cust_id=paul%40paulgeorge.com&x_company=712+Software&x_country=&x_phone=&x_fax=&x_email=paul%40paulgeorge.com&x_test_request=TRUE&
Response Code: 	Error
Response Subcode: 	2
Response Reason Code: 	33
Response Reason Text: 	(TESTMODE) Credit card number is required.
Approval Code: 	000000
AVS Result Code: 	P
Transaction ID: 	0
Invoice Number (x_invoice_num): 	NO VALUE RETURNED
Description (x_description): 	ASGSB Corporate Membership Gold Level.
Amount (x_amount): 	6000.00
Method (x_method): 	CC
Transaction Type (x_type): 	auth_capture
Customer ID (x_cust_id): 	paul@paulgeorge.com
Cardholder First Name (x_first_name): 	NO VALUE RETURNED
Cardholder Last Name (x_last_name): 	NO VALUE RETURNED
Company (x_company): 	712 Software
Billing Address (x_address): 	12216 Wheat Mill Loop
City (x_city): 	Bristow
State (x_state): 	VA
ZIP (x_zip): 	20136
Country (x_country): 	NO VALUE RETURNED
Phone (x_phone): 	NO VALUE RETURNED
Fax (x_fax): 	NO VALUE RETURNED
E-Mail Address (x_email): 	paul@paulgeorge.com
Ship to First Name (x_ship_to_first_name): 	NO VALUE RETURNED
Ship to Last Name (x_ship_to_last_name): 	NO VALUE RETURNED
Ship to Company (x_ship_to_company): 	NO VALUE RETURNED
Ship to Address (x_ship_to_address): 	NO VALUE RETURNED
Ship to City (x_ship_to_city): 	NO VALUE RETURNED
Ship to State (x_ship_to_state): 	NO VALUE RETURNED
Ship to ZIP (x_ship_to_zip): 	NO VALUE RETURNED
Ship to Country (x_ship_to_country): 	NO VALUE RETURNED
Tax Amount (x_tax): 	NO VALUE RETURNED
Duty Amount (x_duty): 	NO VALUE RETURNED
Freight Amount (x_freight): 	NO VALUE RETURNED
Tax Exempt Flag (x_tax_exempt): 	NO VALUE RETURNED
PO Number (x_po_num): 	NO VALUE RETURNED
MD5 Hash: 	2D9A4200DE9E6212438091411E320CE7
Card Code Response: 	NO VALUE RETURNED
Reserved (40): 	NO VALUE RETURNED
Reserved (41): 	NO VALUE RETURNED
Reserved (42): 	NO VALUE RETURNED
Reserved (43): 	NO VALUE RETURNED
Reserved (44): 	NO VALUE RETURNED
Reserved (45): 	NO VALUE RETURNED
Reserved (46): 	NO VALUE RETURNED
Reserved (47): 	NO VALUE RETURNED
Reserved (48): 	NO VALUE RETURNED
Reserved (49): 	NO VALUE RETURNED
Reserved (50): 	NO VALUE RETURNED
Reserved (51): 	NO VALUE RETURNED
Reserved (52): 	NO VALUE RETURNED
Reserved (53): 	NO VALUE RETURNED
Reserved (54): 	NO VALUE RETURNED
Reserved (55): 	NO VALUE RETURNED
Reserved (56): 	NO VALUE RETURNED
Reserved (57): 	NO VALUE RETURNED
Reserved (58): 	NO VALUE RETURNED
Reserved (59): 	NO VALUE RETURNED
Reserved (60): 	NO VALUE RETURNED
Reserved (61): 	NO VALUE RETURNED
Reserved (62): 	NO VALUE RETURNED
Reserved (63): 	NO VALUE RETURNED
Reserved (64): 	NO VALUE RETURNED
Reserved (65): 	NO VALUE RETURNED
Reserved (66): 	NO VALUE RETURNED
Reserved (67): 	NO VALUE RETURNED
Reserved (68): 	NO VALUE RETURNED
Merchant-defined (69): : 	FALSE


So what I really need is a way, in this code, to tell the plugin NOT to run and just carry on with the emails and Joomla! database insert. Is there anyway to stop the plugin from executing?

Thanks!
GreyHead 20 Jul, 2011
Hi pjgeorge,

ChronoForms v3 doesn't have any good flow controls for the post submit actions. You can change the order but you can't easily skip any actions. (CFv4 is much better in this area.)

The only thing I've found that you can do is to redirect the user before the Plug-in is run. So you could use the OnSubmit After Email box to check the payment method and, if it's by cheque, redirect the user to some other page (or form) before the plug-in runs.

Bob
This topic is locked and no more replies can be posted.