Jump to content

Trouble with Auth.net and setting up action


classic

Recommended Posts

Hi Guys,I am trying to set up a success page after a donation occurs. The test environment is with Auth.net which is different than others I have worked with in the past. Basically, upon submitting the form, I want it too display the transaction message from the gateway and if the response is successful activate a tracking code that a marketing team is going to send over.Here is what I have. The donation form posts to a page with this PHP code:

<?phprequire_once('authorizenet.class.php');$a = new authorizenet_class;// You login using your login, login and tran_key, or login and password.  It// varies depending on how your account is setup.// I believe the currently reccomended method is to use a tran_key and not// your account password.  See the AIM documentation for additional information. $a->add_field('x_login', 'xxxxxxxxxx');$a->add_field('x_tran_key', 'xxxxxxxxxx');//$a->add_field('x_password', 'CHANGE THIS TO YOUR PASSWORD');$a->add_field('x_version', '3.1');$a->add_field('x_type', 'AUTH_CAPTURE');$a->add_field('x_test_request', 'FALSE');    // Just a test transaction$a->add_field('x_relay_response', 'FALSE');// You *MUST* specify '|' as the delim char due to the way I wrote the class.// I will change this in future versions should I have time.  But for now, just// make sure you include the following 3 lines of code when using this class.$a->add_field('x_delim_data', 'TRUE');$a->add_field('x_delim_char', '|');     $a->add_field('x_encap_char', '');// Setup fields for customer information.  This would typically come from an// array of POST values froma secure HTTPS form.$a->add_field('x_first_name', $_POST['firstname']);$a->add_field('x_last_name', $_POST['lastname']);$a->add_field('x_address', $_POST['address']);$a->add_field('x_city', $_POST['billingcity']);$a->add_field('x_state', $_POST['billingstate']);$a->add_field('x_zip', $_POST['billingzip']);$a->add_field('x_country', $_POST['billingcountry']);$a->add_field('x_email', $_POST['email']);$a->add_field('x_phone', $_POST['phone']);$a->add_field('x_description', 'US Immigration Explained DVD Series');$a->add_field('x_ship_to_first_name', $_POST['firstname']);$a->add_field('x_ship_to_last_name', $_POST['lastname']);$a->add_field('x_ship_to_address', $_POST['shippingaddress']);$a->add_field('x_ship_to_city', $_POST['shippingcity']);$a->add_field('x_ship_to_state', $_POST['shippingstate']);$a->add_field('x_ship_to_zip', $_POST['shippingzip']);$a->add_field('x_ship_to_country', $_POST['shippingcountry']);// Using credit card number '4007000000027' performs a successful test.  This// allows you to test the behavior of your script should the transaction be// successful.  If you want to test various failures, use '4222222222222' as// the credit card number and set the x_amount field to the value of the // Response Reason Code you want to test.  // // For example, if you are checking for an invalid expiration date on the// card, you would have a condition such as:// if ($a->response['Response Reason Code'] == 7) ... (do something)//// Now, in order to cause the gateway to induce that error, you would have to// set x_card_num = '4222222222222' and x_amount = '7.00'//  Setup fields for payment information$a->add_field('x_method', 'CC');$a->add_field('x_card_num', $_POST['cardnumber']);   // test successful visa//$a->add_field('x_card_num', '370000000000002');   // test successful american express//$a->add_field('x_card_num', '6011000000000012');  // test successful discover//$a->add_field('x_card_num', '5424000000000015');  // test successful mastercard// $a->add_field('x_card_num', '4222222222222');    // test failure card number$a->add_field('x_amount', $_POST['orderamount']);$a->add_field('x_exp_date', $_POST['exp']);    // march of 2008$a->add_field('x_card_code', $_POST['cvv2']);    // Card CAVV Security code// Process the payment and output the resultsswitch ($a->process()) {   case 1:  // Successs      echo "<b>Your Purchase was Successful:</b><br>";      echo $a->get_response_reason_text();      echo "<br><br>Thank you for your purchase! If you have any questions, please contact sr@usaexplained.com<br><br>";      break;         case 2:  // Declined      echo "<b>You Payment was declined for the following reason:</b><br>";      echo $a->get_response_reason_text();      echo "<br><br><br><br>";      break;         case 3:  // Error      echo "<b>There was an error with the transaction for the following reason:</b><br>";      echo $a->get_response_reason_text();      echo "<br><br><br><br>";      break;}if (get_response_reason_text=="This transaction has been approved.") {echo "<br><br>TRACKING CODE GOES HERE?<br><br>";}?>

Sorry if this is obvious, just new to PHP.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...