function authnet_CalculateFP($loginid, $x_tran_key, $amount, $sequence, $tstamp, $currency = "") { // $txnkey, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency return authnet_hmac($x_tran_key, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency); }
function payment_button($order_id) { global $label; $sql = "SELECT * from orders where order_id='" . $order_id . "'"; $result = mysql_query($sql) or die(mysql_error() . $sql); $order_row = mysql_fetch_array($result); ?> <center> <?php if (AUTHNET_TEST_MODE == 'YES') { ?> <FORM action="https://test.authorize.net/gateway/transact.dll" method="POST"> <?php } else { ?> <FORM action="https://secure.authorize.net/gateway/transact.dll" method="POST"> <?php } $loginid = AUTHNET_LOGIN_ID; $x_tran_key = AUTHNET_X_TRAN_KEY; $x_Amount = $order_row['price']; $amount = convert_to_currency($x_Amount, $order_row['currency'], AUTHNET_CURRENCY); // Seed random number for security and better randomness. srand(time()); $sequence = rand(1, 1000); $tstamp = time(); $fingerprint = authnet_hmac($x_tran_key, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . AUTHNET_CURRENCY); echo '<input type="hidden" name="x_fp_sequence" value="' . $sequence . '">'; echo '<input type="hidden" name="x_fp_timestamp" value="' . $tstamp . '">'; echo '<input type="hidden" name="x_fp_hash" value="' . $fingerprint . '">'; // Insert rest of the form elements similiar to the legacy weblink integration //echo ("<input type=\"hidden\" name=\"x_description\" value=\"" . $x_Description . "\">\n" ); echo "<input type=\"hidden\" name=\"x_login\" value=\"" . $loginid . "\">\n"; echo "<input type=\"hidden\" name=\"x_amount\" value=\"" . $amount . "\">\n"; // *** IF YOU ARE PASSING CURRENCY CODE uncomment the line below ***** echo "<input type=\"hidden\" name=\"x_currency_code\" value=\"" . AUTHNET_CURRENCY . "\">\n"; ?> <INPUT type="hidden" name="x_background_url" value="<?php echo AUTHNET_X_BACKGROUND_URL; ?> "> <INPUT type="hidden" name="x_logo_url" value="<?php echo AUTHNET_X_LOGO_URL; ?> "> <INPUT type="hidden" name="x_color_background" value="<?php echo AUTHNET_X_COLOR_BACKGROUND; ?> "> <INPUT type="hidden" name="x_color_link" value="<?php echo AUTHNET_X_COLOR_LINK; ?> "> <INPUT type="hidden" name="x_color_text" value="<?php echo AUTHNET_X_COLOR_TEXT; ?> "> <INPUT type="hidden" name="x_receipt_link_method" value="<?php echo AUTHNET_X_RECEIPT_LINK_METHOD; ?> "> <INPUT type="hidden" name="x_receipt_link_url" value="<?php echo AUTHNET_X_RECEIPT_LINK_URL; ?> "> <INPUT type="hidden" name="x_receipt_link_text" value="<?php echo AUTHNET_X_RECEIPT_LINK_TEXT; ?> "> <INPUT type="hidden" name="x_header_html_payment_form" value="<?php echo AUTHNET_X_HEADER_HTML_PAYMENT_FORM; ?> "> <INPUT type="hidden" name="x_footer_html_payment_form" value="<?php echo AUTHNET_X_FOOTER_HTML_PAYMENT_FORM; ?> "> <INPUT type="hidden" name="x_cust_id" value="<?php echo $order_row['user_id']; ?> "> <INPUT type="hidden" name="x_relay_response" value="TRUE"> <INPUT type="hidden" name="x_relay_url" value="<?php echo AUTHNET_X_RELAY_URL; ?> "> <INPUT type="hidden" name="x_invoice_num" value="<?php echo $order_row['order_id']; ?> "> <INPUT type="hidden" name="x_description" value="<?php echo SITE_NAME; ?> "> <INPUT type="hidden" name="x_cust_id" value="<?php echo $order_row['user_id']; ?> "> <INPUT type="hidden" name="x_show_form" value="PAYMENT_FORM"> <?php if (AUTHNET_TEST_MODE == 'YES') { ?> <INPUT type="hidden" name="x_test_request" value="TRUE"> <?php } else { ?> <INPUT type="hidden" name="x_test_request" value="FALSE"> <?php } ?> <INPUT type="submit" value="<?php echo $label['pay_by_authnet_button']; ?> "> </FORM> </center> <?php }