Integration and Testing

Authorize.Net API questions and help with your payment integration.

Reply
Regular Contributor
Posts: 82
Registered: ‎02-15-2013

Re: Getting error E00002 The content-type specified is not supported

Thanks. I have had so many version of this I wasn't sure. Ok this is what I have now. Seems it is sending the data to Authorize.Net. Sure its hard coded info for now but I will try to change that later.

 

Now I need to incorporate that response code to my site. I can get the error box to display that defualt hard coded error"  by leaviing the values of the status array empty. That getElement is using another class that allow you tosearchthe XML for things such as ID, code or whatever.

 

Any thing like echo $xml->messages->resultCode;  is just outputs at the top of the page.

 

	var $cards = array("visa", "mc", "amex", "disc", "jcb", "dc");
    var $status = array("" => "CHARGED","" => "PENDING");

	function AuthorizeNet () {
		parent::__construct();
		$this->setup('login','password','testmode');
	}

	function actions () {
		add_action('mycart_process_order',array(&$this,'process'));
	}

	
		function process () {
		global $Mycart;
		
		$message = $this->build();
		$Response = $this->send($message);
		$status = $Response->getElementContent('responseCode');
		
		if ($status == "" || $status == "") {
			$message = $Response->getElementContent('messages');
			//$message = $Response->getElementContent('text');
			$code = $Response->getElementContent('code');
			
			//var_dump($Response->getElementContent('messages'));
			if (empty($message)) {
				new MycartError(__("A configuration error occurred while processing this transaction. Please contact the site administrator.","Mycart"),'authnet_error',MYCART_TRXN_ERR);
				return;
			}
			new MycartError($message,'authnet_error',MYCART_TRXN_ERR,
				array('code'=>$code));
				return;
		}
		
		$transaction = $Response->getElement('Transaction');
		$txnid = $transaction['CHILDREN']['Id']['CONTENT'];
		$txnstatus = $this->status[$status];
		$Mycart->Order->transaction($txnid,$txnstatus);

	}
	
	
	

	function build () {
		$Order = $this->Order;
	

 
$xml = new AuthnetXML(AUTHNET_LOGIN, AUTHNET_TRANSKEY, AuthnetXML::USE_DEVELOPMENT_SERVER);
    $xml->createCustomerProfileTransactionRequest(array(
      'transaction' => array(
            'profileTransAuthCapture' => array(
                'amount' => '10.95',
                'tax' => array(
                    'amount' => '1.00',
                    'name' => 'state sales tax',
                    'description' => 'state sales tax'
                ),
                'shipping' => array(
                    'amount' => '2.00',
                    'name' => 'ground based shipping',
                    'description' => 'Ground based 5 to 10 day shipping'
                ),
                'lineItems' => array(
                    0 => array(
                        'itemId' => '1',
                        'name' => 'widget 1',
                        'description' => 'desc',
                        'quantity' => '18',
                        'unitPrice' => '45.00'
                    ),
                    1 => array(
                        'itemId' => '2',
                        'name' => 'widget 2',
                        'description' => 'desc',
                        'quantity' => '10',
                        'unitPrice' => '85.00'
                    )
                ),
                'customerProfileId' => '129',
                'customerPaymentProfileId' => '1193',
                'customerShippingAddressId' => '120',
                'order' => array(
                    'invoiceNumber' => 'INV9',
                    'description' => 'description of transaction',
                    'purchaseOrderNumber' => 'PON9'
                ),
                'taxExempt' => 'false',
                'recurringBilling' => 'false',
                'cardCode' => '000'
            )
        ),
        'extraOptions' => '<![CDATA[x_customer_ip=100.0.0.1]]>'
		
    ));
echo $xml->messages->resultCode;

echo 	$xml->messages->message->code;



//echo "Raw request: " . htmlspecialchars($xml) . "<br><br>";
//$response = send_xml_request($xml);
//echo "Raw response: " . htmlspecialchars($response) . "<br><br>";
//$parsedresponse = parse_api_response($response);
if ("Ok" == $parsedresponse->messages->resultCode) {
	echo "customerProfileId <b>"
		. htmlspecialchars($parsedresponse->customerProfileId)
		. "</b> was successfully created.<br><br>";
}

//echo "<br><a href=index.php?customerProfileId="
	//. urlencode($parsedresponse->customerProfileId)
	//. ">Continue</a><br>";
 }	

	
	
	
function send ($message) {
		$url = 'https://apitest.authorize.net/xml/v1/request.api' ;
		$response = parent::send($message,$url);
		return new XMLdata($response);
	}

function response ($buffer) { //added to test error
		$_ = new stdClass();

		list($_->code,
			 $_->subcode,
			 $_->reasoncode,
			 $_->reason,
			 $_->authcode,
			 $_->avs,
			 $_->transactionid,
			 $_->invoicenum,
			 $_->description,
			 $_->amount,
			 $_->method,
			 $_->type,
			 $_->customerid,
			 $_->firstname,
			 $_->lastname,
			 $_->company,
			 $_->address,
			 $_->city,
			 $_->state,
			 $_->zip,
			 $_->country,
			 $_->phone,
			 $_->fax,
			 $_->email,
			 $_->ship_to_first_name,
			 $_->ship_to_last_name,
			 $_->ship_to_company,
			 $_->ship_to_address,
			 $_->ship_to_city,
			 $_->ship_to_state,
			 $_->ship_to_zip,
			 $_->ship_to_country,
			 $_->tax,
			 $_->duty,
			 $_->freight,
			 $_->taxexempt,
			 $_->ponum,
			 $_->md5hash,
			 $_->cvv2code,
			 $_->cvv2response) = explode(",",$buffer);
		return $_;
	}	

	function settings () {
		$this->ui->cardmenu(0,array(
			'name' => 'cards',
			'selected' => $this->settings['cards']
		),$this->cards);

		$this->ui->text(1,array(
			'name' => 'login',
			'value' => $this->settings['login'],
			'size' => '16',
			'label' => __('Enter your AuthorizeNet Login ID.','Mycart')
		));

		$this->ui->password(1,array(
			'name' => 'password',
			'value' => $this->settings['password'],
			'size' => '24',
			'label' => __('Enter your AuthorizeNet Password or Transaction Key.','Mycart')
		));

		$this->ui->checkbox(1,array(
			'name' => 'testmode',
			'checked' => $this->settings['testmode'],
			'label' => __('Enable test mode','Mycart')
		));

	}

} // END class AuthorizeNet

 

Regular Contributor
Posts: 82
Registered: ‎02-15-2013

Re: Getting error E00002 The content-type specified is not supported

This is part of the response XML. I need to get the code back with the getElement.

 

<?xml version="1.0" encoding="utf-8"?>
<createCustomerProfileTransactionResponse>
  <messages>
    <resultCode>Ok</resultCode>
    <message>
      <code>I00001</code>
      <text>Successful.</text>
    </message>
  </messages>
  <directResponse>1,1,1,This transaction has been approved.,MY6ACN,Y,2186330627,INV10,description of transaction,10.95,CC,auth_capture,2,Joe,Smith,,128 Place,New York,NY,33874,,65447488,,joes@somedomain.com,Joe,Smith,,128 Place,New York,NY,33874,,65447488,,1.00,,2.00,FALSE,PON10,BE55E61FD13711C10,P,2,,,,,,,,,,,XXXX0015,MasterCard,,,,,,,,,,,,,,,,,12031425,100.0.0.1]]&gt;</directResponse>
</createCustomerProfileTransactionResponse>

 

Regular Contributor
Posts: 82
Registered: ‎02-15-2013

Re: Getting error E00002 The content-type specified is not supported

The status must not be getting a value. Yet it will show error  "E00002" which means  "The only supported content-types are text/xml and application/xml"  But the XML sends the data successfully. I hope someone can help me with this I have been struggling a couple weeks.