<?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 how to get an authorization/transaction number? in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/how-to-get-an-authorization-transaction-number/m-p/23995#M12891</link>
    <description>&lt;P&gt;It looks like I've got a working script that posts to to authorize.net (with some help from a friend) but I'm not sure how to get back a confirmation number and/or transaction number to put in my database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the script as it stands now. ( In the AIM.class.php, the form is verfied and the array of values to send, are set)&lt;/P&gt;&lt;PRE&gt;&amp;lt;?php


require("AIM.class.php");
$aim = new AIM("xxxxxxx", "xxxxxxxxxxxxxxx");


// If you want to send test transactions, use the setTesting method to
// tell the class to talk to the certification server
//$aim-&amp;gt;setTesting(1);
$expfull = $_REQUEST['expmonth'] . $_REQUEST['expyear'];
$nameoncard = $_REQUEST['cc_name'];
$final_total = $_REQUEST['final_total'];
if (!$aim-&amp;gt;setCard($nameoncard, $_REQUEST['ccnumber'], $_REQUEST['expmonth'], $_REQUEST['expyear'], $_REQUEST['cc_code']))
	die("The credit card is invalid: " . print_r($aim-&amp;gt;errorStack, 1));

// Sets the customer's billing information
$aim-&amp;gt;setBuyer($_REQUEST['bfname'], $_REQUEST['blname'], $_REQUEST['badd1'], $_REQUEST['bcity'], $_REQUEST['bstate'], $_REQUEST['bzip'], $_REQUEST['phone']);

// Attempt to process the card and set $approval to the approval code
if (!$approval = $aim-&amp;gt;processCard("Workshops for Youth", $final_total)){
	echo "&amp;lt;strong&amp;gt;Oops!&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;Error proccessing credit card: " . print_r($aim-&amp;gt;errorStack,1);
	$appcodedesc = "Error processing credit card.";
	$approval = 0;
}else{
	// If we made it this far, the card was successfully charged
	echo "&amp;lt;strong&amp;gt;Payment Approved&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;Successfully charged the credit card.  Please print for your records."; // Approval code: " . $approval;
	$approval = 1;
	$appcodedesc = "Payment Approved";
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 05 Mar 2012 14:38:24 GMT</pubDate>
    <dc:creator>turpentyne</dc:creator>
    <dc:date>2012-03-05T14:38:24Z</dc:date>
    <item>
      <title>how to get an authorization/transaction number?</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/how-to-get-an-authorization-transaction-number/m-p/23995#M12891</link>
      <description>&lt;P&gt;It looks like I've got a working script that posts to to authorize.net (with some help from a friend) but I'm not sure how to get back a confirmation number and/or transaction number to put in my database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the script as it stands now. ( In the AIM.class.php, the form is verfied and the array of values to send, are set)&lt;/P&gt;&lt;PRE&gt;&amp;lt;?php


require("AIM.class.php");
$aim = new AIM("xxxxxxx", "xxxxxxxxxxxxxxx");


// If you want to send test transactions, use the setTesting method to
// tell the class to talk to the certification server
//$aim-&amp;gt;setTesting(1);
$expfull = $_REQUEST['expmonth'] . $_REQUEST['expyear'];
$nameoncard = $_REQUEST['cc_name'];
$final_total = $_REQUEST['final_total'];
if (!$aim-&amp;gt;setCard($nameoncard, $_REQUEST['ccnumber'], $_REQUEST['expmonth'], $_REQUEST['expyear'], $_REQUEST['cc_code']))
	die("The credit card is invalid: " . print_r($aim-&amp;gt;errorStack, 1));

// Sets the customer's billing information
$aim-&amp;gt;setBuyer($_REQUEST['bfname'], $_REQUEST['blname'], $_REQUEST['badd1'], $_REQUEST['bcity'], $_REQUEST['bstate'], $_REQUEST['bzip'], $_REQUEST['phone']);

// Attempt to process the card and set $approval to the approval code
if (!$approval = $aim-&amp;gt;processCard("Workshops for Youth", $final_total)){
	echo "&amp;lt;strong&amp;gt;Oops!&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;Error proccessing credit card: " . print_r($aim-&amp;gt;errorStack,1);
	$appcodedesc = "Error processing credit card.";
	$approval = 0;
}else{
	// If we made it this far, the card was successfully charged
	echo "&amp;lt;strong&amp;gt;Payment Approved&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;Successfully charged the credit card.  Please print for your records."; // Approval code: " . $approval;
	$approval = 1;
	$appcodedesc = "Payment Approved";
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2012 14:38:24 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/how-to-get-an-authorization-transaction-number/m-p/23995#M12891</guid>
      <dc:creator>turpentyne</dc:creator>
      <dc:date>2012-03-05T14:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to get an authorization/transaction number?</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/how-to-get-an-authorization-transaction-number/m-p/24007#M12897</link>
      <description>&lt;P&gt;This is a simple version of the code I use, layered on top of an unmodified version of the PHP SDK:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;    $authorize = new AuthorizeNetAIM(
        $GLOBALS['_authorize_id'], $GLOBALS['_authorize_key']);
    $authorize-&amp;gt;setSandbox(false);

    $fields = array(
        'first_name' =&amp;gt; $_POST['first'],
        'last_name' =&amp;gt; $_POST['last'],
        'company' =&amp;gt; $_POST['company'],
        'address' =&amp;gt; $_POST['address'],
        'city' =&amp;gt; $_POST['city'],
        'state' =&amp;gt; $_POST['state'],
        'zip' =&amp;gt; $_POST['zip'],
        'country' =&amp;gt; 'US',

        'phone' =&amp;gt; $_POST['phone'],
        'email' =&amp;gt; $_POST['email'],

        'customer_ip' =&amp;gt; $_SERVER['REMOTE_ADDR'],

        'description' =&amp;gt; 'removed for privacy reasons - insert yours',
        'amount' =&amp;gt; $_POST['initial_payment'],

        'card_num' =&amp;gt; $_POST['card_number'],
        'exp_date' =&amp;gt; sprintf('%02d%02d', $_POST['card_exp_month'], ($_POST['card_exp_year'] % 1000)),
        'card_code' =&amp;gt; $_POST['card_ccv']
    );

    $authorize-&amp;gt;setFields($fields);
    $result = $authorize-&amp;gt;authorizeAndCapture();

    if ($result-&amp;gt;{'response_code'} != 1)
        $errors[] = "Failure - {$result-&amp;gt;response_reason_text}";
    else
        // Do something with $result-&amp;gt;transaction_id&lt;/PRE&gt;&lt;P&gt;Note that I do validate the fields before putting them into the transaction, and some are inserted into $_POST by me, but specific application is left up to you.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2012 17:39:12 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/how-to-get-an-authorization-transaction-number/m-p/24007#M12897</guid>
      <dc:creator>TJPride</dc:creator>
      <dc:date>2012-03-05T17:39:12Z</dc:date>
    </item>
  </channel>
</rss>

