/**
  * Implements all 3 steps of the Direct Post Method for demonstration
  * purposes.
  */
 public static function directPost($url, $item_number, $price = "0.00", $rand = '', $nonce)
 {
     $options = array_merge(mt_default_settings(), get_option('mt_settings'));
     $api = $options['mt_gateways']['authorizenet']['api'];
     $key = $options['mt_gateways']['authorizenet']['key'];
     // Step 1: Show checkout form to customer.
     $fp_sequence = $rand;
     // Any sequential number like an invoice number.
     return mt_AuthorizeNetMyTickets::getCreditCardForm($price, $item_number, $fp_sequence, $url, $api, $key, $nonce);
 }
function mt_gateway_authorizenet($form, $gateway, $args)
{
    if ($gateway == 'authorizenet') {
        $options = array_merge(mt_default_settings(), get_option('mt_settings'));
        $payment_id = $args['payment'];
        $shipping_price = $args['method'] == 'postal' ? $options['mt_shipping'] : 0;
        $handling = isset($options['mt_handling']) ? $options['mt_handling'] : 0;
        $total = mt_money_format('%i', $args['total'] + $shipping_price + $handling);
        $nonce = wp_create_nonce('my-tickets-authnet-authorizenet');
        $url = mt_replace_http(add_query_arg('mt_authnet_ipn', 'true', trailingslashit(home_url())));
        $rand = time() . rand(100000, 999999);
        $form = mt_AuthorizeNetMyTickets::directPost($url, $payment_id, $total, $rand, $nonce);
        /* This might be part of handling discount codes.
        		if ( $discount == true && $discount_rate > 0 ) {
        			$form .= "
        			<input type='hidden' name='discount_rate' value='$discount_rate' />";
        			if ( $quantity == 'true' ) {
        				$form .= "
        				<input type='hidden' name='discount_rate2' value='$discount_rate' />";	
        			}
        		}
        		*/
        $form .= apply_filters('mt_authnet_form', '', $gateway, $args);
    }
    return $form;
}