<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic AIM Integration. No errors in test mode, payment not processed in production mode in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/AIM-Integration-No-errors-in-test-mode-payment-not-processed-in/m-p/31922#M16615</link>
    <description>&lt;P&gt;Hi I got the code from here: &lt;A target="_blank" href="http://community.developer.authorize.net/t5/The-Authorize-Net-Developer-Blog/Handling-Online-Payments-Part-10-A-Little-Bit-More-PHP/ba-p/13414"&gt;http://community.developer.authorize.net/t5/The-Authorize-Net-Developer-Blog/Handling-Online-Payments-Part-10-A-Little-Bit-More-PHP/ba-p/13414&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It doesn't give me any errors while on test mode but any Credit Card I use, payments doesn't go through on live mode. 2 errors come up:&lt;/P&gt;&lt;P&gt;1. Your credit card was declined by your bank. Please try another form of payment.;&lt;/P&gt;&lt;P&gt;2. We encountered an error while processing your payment. Your credit card was not charged. Please try again or contact customer service to place your order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: My Credit Card has more than enough balance to cover the transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code: I've removed the API login ID and Transaction key as well as replaced the domain name in the code below.&lt;/P&gt;&lt;PRE&gt;&amp;lt;?php
    session_start();
	error_reporting(E_ALL);
	ini_set('display_errors', '1');
	

    $errors = array();

    if ('POST' === $_SERVER['REQUEST_METHOD'])
    {
        require('payment-functions.php');

        $credit_card           = sanitize($_POST['credit_card']);
        $expiration_month      = (int) sanitize($_POST['expiration_month']);
        $expiration_year       = (int) sanitize($_POST['expiration_year']);
        $cvv                   = sanitize($_POST['cvv']);
        $cardholder_first_name = sanitize($_POST['cardholder_first_name']);
        $cardholder_last_name  = sanitize($_POST['cardholder_last_name']);
        $billing_address       = sanitize($_POST['billing_address']);
        $billing_address2      = sanitize($_POST['billing_address2']);
        $billing_city          = sanitize($_POST['billing_city']);
		$billing_state         = sanitize($_POST['billing_state']);
        $billing_zip           = sanitize($_POST['billing_zip']);
        $telephone             = sanitize($_POST['telephone']);
        $email                 = sanitize($_POST['email']);
        $honeypot              = sanitize($_POST['ssn']);
        $token                 = sanitize($_POST['token']);

        if ($token !== $_SESSION['token'])
        {
            $errors['token'] = "This form submission is invalid. Please try again or contact support for additional assistance.";
        }
        if (!empty($honeypot))
        {
            $errors['hp'] = "This form submission is invalid. Please try again or contact support for additional assistance.";
        }
        if (!validateCreditcard_number($credit_card))
        {
            $errors['credit_card'] = "Please enter a valid credit card number";
        }
        if (!validateCreditCardExpirationDate($expiration_month, $expiration_year))
        {
            $errors['expiration_month'] = "Please enter a valid expiration date for your credit card";
        }
        if (!validateCVV($credit_card, $cvv))
        {
            $errors['cvv'] = "Please enter the security code (CVV number) for your credit card";
        }
        if (empty($cardholder_first_name))
        {
            $errors['cardholder_first_name'] = "Please provide the card holder's first name";
        }
        if (empty($cardholder_last_name))
        {
            $errors['cardholder_last_name'] = "Please provide the card holder's last name";
        }
        if (empty($billing_address))
        {
            $errors['billing_address'] = 'Please provide your billing address.';
        }
        if (empty($billing_city))
        {
            $errors['billing_city'] = 'Please provide the city of your billing address.';
        }
		if (empty($billing_state))
        {
            $errors['billing_state'] = 'Please provide the state for your billing address.';
        }
        if (empty($telephone) || strlen($telephone) &amp;gt; 20)
        {
            $errors['billing_city'] = 'Please provide a telephone number where we can reach you if necessary.';
        }
        if (!filter_var($email, FILTER_VALIDATE_EMAIL))
        {
            $errors['email'] = "Please provide a valid email address";
        }
        // If there are no errors let's process the payment
        if (count($errors) === 0)
        {
            // Format the expiration date
            $expiration_date = sprintf("%04d-%02d", $expiration_year, $expiration_month);

            // Include the SDK
            //require_once('config.php');
			require_once 'AuthorizeNet.php'; 
			define("AUTHORIZENET_API_LOGIN_ID", ""); 
			define("AUTHORIZENET_TRANSACTION_KEY", ""); 
			define("AUTHORIZENET_SANDBOX", false);

            // Process the transaction using the AIM API
            $transaction = new AuthorizeNetAIM;
            $transaction-&amp;gt;setSandbox(AUTHORIZENET_SANDBOX);
            $transaction-&amp;gt;setFields(
                array(
                'amount' =&amp;gt; '20.00',
                'card_num' =&amp;gt; $credit_card,
                'exp_date' =&amp;gt; $expiration_date,
                'first_name' =&amp;gt; $cardholder_first_name,
                'last_name' =&amp;gt; $cardholder_last_name,
                'address' =&amp;gt; $billing_address,
                'city' =&amp;gt; $billing_city,
				'state' =&amp;gt; $billing_state,
                'zip' =&amp;gt; $billing_zip,
                'email' =&amp;gt; $email,
                'card_code' =&amp;gt; $cvv,
                )
            );
            $response = $transaction-&amp;gt;authorizeAndCapture();
            if ($response-&amp;gt;approved)
            {
                // Transaction approved. Collect pertinent transaction information for saving in the database.
                $transaction_id     = $response-&amp;gt;transaction_id;
                $authorization_code = $response-&amp;gt;authorization_code;
                $avs_response       = $response-&amp;gt;avs_response;
                $cavv_response      = $response-&amp;gt;cavv_response;

                // Put everything in a database for later review and order processing
                // How you do this depends on how your application is designed
                // and your business needs.

                //unset our PRG session variable if it exists
                if (isset($_SESSION['prg']))
                {
                    unset($_SESSION['prg']);
                }
				
				$_SESSION['$transaction_id'] = $transaction_id;
				$_SESSION['$authorization_code'] = $authorization_code;
				$_SESSION['$avs_response'] = $avs_response;
				$_SESSION['$cavv_response'] = $$cavv_response;

                // Once we're finished let's redirect the user to a receipt page
                header('Location: &lt;A target="_blank" href="https://www.mydomain.com/introduction.php');"&gt;https://www.mydomain.com/introduction.php');&lt;/A&gt;
                exit;
            }
            else if ($response-&amp;gt;declined)
            {
                // Transaction declined. Set our error message.
                $errors['declined'] = 'Your credit card was declined by your bank. Please try another form of payment.';
            }
            else
            {
                // And error has occurred. Set our error message.
                $errors['error'] = 'We encountered an error while processing your payment. Your credit card was not charged. Please try again or contact customer service to place your order.';

                // Collect transaction response information for possible troubleshooting
                // Since our application won't be doing this we'll comment this out for now.
                //
                // $response_subcode     = $response-&amp;gt;response_subcode;
                // $response_reason_code = $response-&amp;gt;response_reason_code;
            }
        }
        else
        {
            // Create an array in our session for use to store their variables
            $_SESSION['prg'] = array();

            // Put their information into the array
            $_SESSION['prg']['credit_card']           = $credit_card;
            $_SESSION['prg']['expiration_month']      = $expiration_month;
            $_SESSION['prg']['expiration_year']       = $expiration_year;
            $_SESSION['prg']['cvv']                   = $cvv;
            $_SESSION['prg']['cardholder_first_name'] = $cardholder_first_name;
            $_SESSION['prg']['cardholder_last_name']  = $cardholder_last_name;
            $_SESSION['prg']['billing_address']       = $billing_address;
            $_SESSION['prg']['billing_address2']      = $billing_address2;
            $_SESSION['prg']['billing_city']          = $billing_city;
			$_SESSION['prg']['billing_state']         = $billing_state;
            $_SESSION['prg']['billing_zip']           = $billing_zip;
            $_SESSION['prg']['telephone']             = $telephone;
            $_SESSION['prg']['email']                 = $email;

            // Don't forget the $errors array!
            $_SESSION['prg']['errors']                = $errors;

            // Do our redirect. Make sure it sends the 303 header
            header('Location: &lt;A target="_blank" href="https://www.mydomain.com/payment-form.php',"&gt;https://www.mydomain.com/payment-form.php',&lt;/A&gt; true, 303);
            exit;
        }
    }
    else if (isset($_SESSION['prg']) &amp;amp;&amp;amp; is_array($_SESSION['prg']))
    {
        // Retreive the user's information and our error messages
        // Don't store the credit card information unless you are 100% sure your
        // server and website is PCI compliant!
        // $credit_card           = $_SESSION['prg']['credit_card'];
        // $expiration_month      = $_SESSION['prg']['expiration_month'];
        // $expiration_year       = $_SESSION['prg']['expiration_year'];
        $cvv                   = $_SESSION['prg']['cvv'];
        $cardholder_first_name = $_SESSION['prg']['cardholder_first_name'];
        $cardholder_last_name  = $_SESSION['prg']['cardholder_last_name'];
        $billing_address       = $_SESSION['prg']['billing_address'];
        $billing_address2      = $_SESSION['prg']['billing_address2'];
        $billing_city          = $_SESSION['prg']['billing_city'];
		$billing_state         = $_SESSION['prg']['billing_state'];
        $billing_zip           = $_SESSION['prg']['billing_zip'];
        $telephone             = $_SESSION['prg']['telephone'];
        $email                 = $_SESSION['prg']['email'];
        $errors                = $_SESSION['prg']['errors'];
    }

    $_SESSION['token'] = md5(uniqid(rand(), true));
?&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Dec 2012 22:34:34 GMT</pubDate>
    <dc:creator>darkwind</dc:creator>
    <dc:date>2012-12-06T22:34:34Z</dc:date>
    <item>
      <title>AIM Integration. No errors in test mode, payment not processed in production mode</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/AIM-Integration-No-errors-in-test-mode-payment-not-processed-in/m-p/31922#M16615</link>
      <description>&lt;P&gt;Hi I got the code from here: &lt;A target="_blank" href="http://community.developer.authorize.net/t5/The-Authorize-Net-Developer-Blog/Handling-Online-Payments-Part-10-A-Little-Bit-More-PHP/ba-p/13414"&gt;http://community.developer.authorize.net/t5/The-Authorize-Net-Developer-Blog/Handling-Online-Payments-Part-10-A-Little-Bit-More-PHP/ba-p/13414&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It doesn't give me any errors while on test mode but any Credit Card I use, payments doesn't go through on live mode. 2 errors come up:&lt;/P&gt;&lt;P&gt;1. Your credit card was declined by your bank. Please try another form of payment.;&lt;/P&gt;&lt;P&gt;2. We encountered an error while processing your payment. Your credit card was not charged. Please try again or contact customer service to place your order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: My Credit Card has more than enough balance to cover the transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code: I've removed the API login ID and Transaction key as well as replaced the domain name in the code below.&lt;/P&gt;&lt;PRE&gt;&amp;lt;?php
    session_start();
	error_reporting(E_ALL);
	ini_set('display_errors', '1');
	

    $errors = array();

    if ('POST' === $_SERVER['REQUEST_METHOD'])
    {
        require('payment-functions.php');

        $credit_card           = sanitize($_POST['credit_card']);
        $expiration_month      = (int) sanitize($_POST['expiration_month']);
        $expiration_year       = (int) sanitize($_POST['expiration_year']);
        $cvv                   = sanitize($_POST['cvv']);
        $cardholder_first_name = sanitize($_POST['cardholder_first_name']);
        $cardholder_last_name  = sanitize($_POST['cardholder_last_name']);
        $billing_address       = sanitize($_POST['billing_address']);
        $billing_address2      = sanitize($_POST['billing_address2']);
        $billing_city          = sanitize($_POST['billing_city']);
		$billing_state         = sanitize($_POST['billing_state']);
        $billing_zip           = sanitize($_POST['billing_zip']);
        $telephone             = sanitize($_POST['telephone']);
        $email                 = sanitize($_POST['email']);
        $honeypot              = sanitize($_POST['ssn']);
        $token                 = sanitize($_POST['token']);

        if ($token !== $_SESSION['token'])
        {
            $errors['token'] = "This form submission is invalid. Please try again or contact support for additional assistance.";
        }
        if (!empty($honeypot))
        {
            $errors['hp'] = "This form submission is invalid. Please try again or contact support for additional assistance.";
        }
        if (!validateCreditcard_number($credit_card))
        {
            $errors['credit_card'] = "Please enter a valid credit card number";
        }
        if (!validateCreditCardExpirationDate($expiration_month, $expiration_year))
        {
            $errors['expiration_month'] = "Please enter a valid expiration date for your credit card";
        }
        if (!validateCVV($credit_card, $cvv))
        {
            $errors['cvv'] = "Please enter the security code (CVV number) for your credit card";
        }
        if (empty($cardholder_first_name))
        {
            $errors['cardholder_first_name'] = "Please provide the card holder's first name";
        }
        if (empty($cardholder_last_name))
        {
            $errors['cardholder_last_name'] = "Please provide the card holder's last name";
        }
        if (empty($billing_address))
        {
            $errors['billing_address'] = 'Please provide your billing address.';
        }
        if (empty($billing_city))
        {
            $errors['billing_city'] = 'Please provide the city of your billing address.';
        }
		if (empty($billing_state))
        {
            $errors['billing_state'] = 'Please provide the state for your billing address.';
        }
        if (empty($telephone) || strlen($telephone) &amp;gt; 20)
        {
            $errors['billing_city'] = 'Please provide a telephone number where we can reach you if necessary.';
        }
        if (!filter_var($email, FILTER_VALIDATE_EMAIL))
        {
            $errors['email'] = "Please provide a valid email address";
        }
        // If there are no errors let's process the payment
        if (count($errors) === 0)
        {
            // Format the expiration date
            $expiration_date = sprintf("%04d-%02d", $expiration_year, $expiration_month);

            // Include the SDK
            //require_once('config.php');
			require_once 'AuthorizeNet.php'; 
			define("AUTHORIZENET_API_LOGIN_ID", ""); 
			define("AUTHORIZENET_TRANSACTION_KEY", ""); 
			define("AUTHORIZENET_SANDBOX", false);

            // Process the transaction using the AIM API
            $transaction = new AuthorizeNetAIM;
            $transaction-&amp;gt;setSandbox(AUTHORIZENET_SANDBOX);
            $transaction-&amp;gt;setFields(
                array(
                'amount' =&amp;gt; '20.00',
                'card_num' =&amp;gt; $credit_card,
                'exp_date' =&amp;gt; $expiration_date,
                'first_name' =&amp;gt; $cardholder_first_name,
                'last_name' =&amp;gt; $cardholder_last_name,
                'address' =&amp;gt; $billing_address,
                'city' =&amp;gt; $billing_city,
				'state' =&amp;gt; $billing_state,
                'zip' =&amp;gt; $billing_zip,
                'email' =&amp;gt; $email,
                'card_code' =&amp;gt; $cvv,
                )
            );
            $response = $transaction-&amp;gt;authorizeAndCapture();
            if ($response-&amp;gt;approved)
            {
                // Transaction approved. Collect pertinent transaction information for saving in the database.
                $transaction_id     = $response-&amp;gt;transaction_id;
                $authorization_code = $response-&amp;gt;authorization_code;
                $avs_response       = $response-&amp;gt;avs_response;
                $cavv_response      = $response-&amp;gt;cavv_response;

                // Put everything in a database for later review and order processing
                // How you do this depends on how your application is designed
                // and your business needs.

                //unset our PRG session variable if it exists
                if (isset($_SESSION['prg']))
                {
                    unset($_SESSION['prg']);
                }
				
				$_SESSION['$transaction_id'] = $transaction_id;
				$_SESSION['$authorization_code'] = $authorization_code;
				$_SESSION['$avs_response'] = $avs_response;
				$_SESSION['$cavv_response'] = $$cavv_response;

                // Once we're finished let's redirect the user to a receipt page
                header('Location: &lt;A target="_blank" href="https://www.mydomain.com/introduction.php');"&gt;https://www.mydomain.com/introduction.php');&lt;/A&gt;
                exit;
            }
            else if ($response-&amp;gt;declined)
            {
                // Transaction declined. Set our error message.
                $errors['declined'] = 'Your credit card was declined by your bank. Please try another form of payment.';
            }
            else
            {
                // And error has occurred. Set our error message.
                $errors['error'] = 'We encountered an error while processing your payment. Your credit card was not charged. Please try again or contact customer service to place your order.';

                // Collect transaction response information for possible troubleshooting
                // Since our application won't be doing this we'll comment this out for now.
                //
                // $response_subcode     = $response-&amp;gt;response_subcode;
                // $response_reason_code = $response-&amp;gt;response_reason_code;
            }
        }
        else
        {
            // Create an array in our session for use to store their variables
            $_SESSION['prg'] = array();

            // Put their information into the array
            $_SESSION['prg']['credit_card']           = $credit_card;
            $_SESSION['prg']['expiration_month']      = $expiration_month;
            $_SESSION['prg']['expiration_year']       = $expiration_year;
            $_SESSION['prg']['cvv']                   = $cvv;
            $_SESSION['prg']['cardholder_first_name'] = $cardholder_first_name;
            $_SESSION['prg']['cardholder_last_name']  = $cardholder_last_name;
            $_SESSION['prg']['billing_address']       = $billing_address;
            $_SESSION['prg']['billing_address2']      = $billing_address2;
            $_SESSION['prg']['billing_city']          = $billing_city;
			$_SESSION['prg']['billing_state']         = $billing_state;
            $_SESSION['prg']['billing_zip']           = $billing_zip;
            $_SESSION['prg']['telephone']             = $telephone;
            $_SESSION['prg']['email']                 = $email;

            // Don't forget the $errors array!
            $_SESSION['prg']['errors']                = $errors;

            // Do our redirect. Make sure it sends the 303 header
            header('Location: &lt;A target="_blank" href="https://www.mydomain.com/payment-form.php',"&gt;https://www.mydomain.com/payment-form.php',&lt;/A&gt; true, 303);
            exit;
        }
    }
    else if (isset($_SESSION['prg']) &amp;amp;&amp;amp; is_array($_SESSION['prg']))
    {
        // Retreive the user's information and our error messages
        // Don't store the credit card information unless you are 100% sure your
        // server and website is PCI compliant!
        // $credit_card           = $_SESSION['prg']['credit_card'];
        // $expiration_month      = $_SESSION['prg']['expiration_month'];
        // $expiration_year       = $_SESSION['prg']['expiration_year'];
        $cvv                   = $_SESSION['prg']['cvv'];
        $cardholder_first_name = $_SESSION['prg']['cardholder_first_name'];
        $cardholder_last_name  = $_SESSION['prg']['cardholder_last_name'];
        $billing_address       = $_SESSION['prg']['billing_address'];
        $billing_address2      = $_SESSION['prg']['billing_address2'];
        $billing_city          = $_SESSION['prg']['billing_city'];
		$billing_state         = $_SESSION['prg']['billing_state'];
        $billing_zip           = $_SESSION['prg']['billing_zip'];
        $telephone             = $_SESSION['prg']['telephone'];
        $email                 = $_SESSION['prg']['email'];
        $errors                = $_SESSION['prg']['errors'];
    }

    $_SESSION['token'] = md5(uniqid(rand(), true));
?&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2012 22:34:34 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/AIM-Integration-No-errors-in-test-mode-payment-not-processed-in/m-p/31922#M16615</guid>
      <dc:creator>darkwind</dc:creator>
      <dc:date>2012-12-06T22:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: AIM Integration. No errors in test mode, payment not processed in production mode</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/AIM-Integration-No-errors-in-test-mode-payment-not-processed-in/m-p/31928#M16618</link>
      <description>&lt;P&gt;echo the $response-&amp;gt;response_subcode and $response-&amp;gt;response_reason_code&lt;/P&gt;&lt;P&gt;and see what the error is.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2012 00:02:33 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/AIM-Integration-No-errors-in-test-mode-payment-not-processed-in/m-p/31928#M16618</guid>
      <dc:creator>RaynorC1emen7</dc:creator>
      <dc:date>2012-12-07T00:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: AIM Integration. No errors in test mode, payment not processed in production mode</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/AIM-Integration-No-errors-in-test-mode-payment-not-processed-in/m-p/31938#M16623</link>
      <description>&lt;P&gt;it says "AVS mismatch. the address provided does not match the address of cardholder"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The fact though is it matches&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2012 04:20:21 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/AIM-Integration-No-errors-in-test-mode-payment-not-processed-in/m-p/31938#M16623</guid>
      <dc:creator>darkwind</dc:creator>
      <dc:date>2012-12-07T04:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: AIM Integration. No errors in test mode, payment not processed in production mode</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/AIM-Integration-No-errors-in-test-mode-payment-not-processed-in/m-p/31944#M16625</link>
      <description>&lt;P&gt;What is the AVS response code? double check the billing address right before it get send to authorize.net.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2012 12:15:44 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/AIM-Integration-No-errors-in-test-mode-payment-not-processed-in/m-p/31944#M16625</guid>
      <dc:creator>RaynorC1emen7</dc:creator>
      <dc:date>2012-12-07T12:15:44Z</dc:date>
    </item>
  </channel>
</rss>

