isAuthorizeNet()) { if ($response->approved) { // Do your processing here. $redirect_url = $url . '?response_code=1&transaction_id=' . $response->transaction_id; } else { // Redirect to error page. $redirect_url = $url . '?response_code='.$response->response_code . '&response_reason_text=' . $response->response_reason_text; } // Send the Javascript back to AuthorizeNet, which will redirect user back to your site. echo AuthorizeNetDPM::getRelayResponseSnippet($redirect_url); } else { echo "Error -- not AuthorizeNet. Check your MD5 Setting."; } } // Step 3: Show receipt page to customer. elseif (!count($_POST) && count($_GET)) { if ($_GET['response_code'] == 1) { echo "Thank you for your purchase! Transaction id: " . htmlentities($_GET['transaction_id']); } else { echo "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']); } } } /** * A snippet to send to AuthorizeNet to redirect the user back to the * merchant's server. Use this on your relay response page. * * @param string $redirect_url Where to redirect the user. * * @return string */ public static function getRelayResponseSnippet($redirect_url) { return " "; } /** * Generate a sample form for use in a demo Direct Post implementation. * * @param string $amount Amount of the transaction. * @param string $fp_sequence Sequential number(ie. Invoice #) * @param string $relay_response_url The Relay Response URL * @param string $api_login_id Your API Login ID * @param string $transaction_key Your API Tran Key. * @param bool $test_mode Use the sandbox? * @param bool $prefill Prefill sample values(for test purposes). * * @return string */ public static function getCreditCardForm($amount, $fp_sequence, $relay_response_url, $api_login_id, $transaction_key, $test_mode = true, $prefill = true) { $time = time(); $fp = self::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $time); $sim = new AuthorizeNetSIM_Form( array( 'x_amount' => $amount, 'x_fp_sequence' => $fp_sequence, 'x_fp_hash' => $fp, 'x_fp_timestamp' => $time, 'x_relay_response'=> "TRUE", 'x_relay_url' => $relay_response_url, 'x_login' => $api_login_id, ) ); $hidden_fields = $sim->getHiddenFieldString(); $post_url = ($test_mode ? self::SANDBOX_URL : self::LIVE_URL); $form = '
'.$hidden_fields.'
'; return $form; } }