- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I post transaction to my developer account using apitest.authorize.net I dont get the isSuccessful nor an AuthCode returning back from the xml.
"my code never goes in the (if ($cim->isSuccessful())) statement"
Is this cause the credit card really isnt going through cause it is voided and all that cause of developer/test....
I jsut want to make sure these will work, so i can correctly handle errors when I go live.
Below is the code to call the transaction:
// Step 3: Process a transaction // Process the transaction $cim->setParameter('amount', $amount); $cim->setParameter('customerProfileId', $customerProfileId); $cim->setParameter('customerPaymentProfileId', $customerPaymentProfileId); //$cim->setParameter('customerShippingAddressId', $shipping_profile_id); $cim->setParameter('cardCode', $cvv); $cim->setLineItem('1', 'xxxx', 'xxxxxx', '1', '9.95'); $cim->createCustomerProfileTransaction(); //test if transaction went through if ($cim->isSuccessful()) { //should we store this approval code??---------------------- $approval_code = $cim->getAuthCode();
This is the code that post the transaction:
public function createCustomerProfileTransaction($type = 'profileTransAuthCapture') { $types = array('profileTransAuthCapture', 'profileTransCaptureOnly','profileTransAuthOnly'); if (!in_array($type, $types)) { trigger_error('createCustomerProfileTransaction() parameter must be"profileTransAuthCapture", "profileTransCaptureOnly", "profileTransAuthOnly", or empty', E_USER_ERROR); } $this->xml = '<?xml version="1.0" encoding="utf-8"?> <createCustomerProfileTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>' . $this->login . '</name> <transactionKey>' . $this->transkey . '</transactionKey> </merchantAuthentication> <refId>'. $this->params['refId'] .'</refId> <transaction> <' . $type . '> <amount>'. $this->params['amount'] .'</amount>'; if (isset($this->params['taxAmount'])) { $this->xml .= ' <tax> <amount>'. $this->params['taxAmount'].'</amount> <name>'. $this->params['taxName'] .'</name> <description>'.$this->params['taxDescription'].'</description> </tax>'; } if (isset($this->params['shipAmount'])) { $this->xml .= ' <shipping> <amount>'. $this->params['shipAmount'].'</amount> <name>'. $this->params['shipName'] .'</name> <description>'.$this->params['shipDescription'].'</description> </shipping>'; } if (isset($this->params['dutyAmount'])) { $this->xml .= ' <duty> <amount>'. $this->params['dutyAmount'].'</amount> <name>'. $this->params['dutyName'] .'</name> <description>'.$this->params['dutyDescription'].'</description> </duty>'; } $this->xml .= ' <lineItems>' . $this->getLineItems() . '</lineItems> <customerProfileId>'.$this->params['customerProfileId'].'</customerProfileId> <customerPaymentProfileId>'.$this->params['customerPaymentProfileId'].'</customerPaymentProfileId> <customerShippingAddressId>'.$this->params['customerShippingAddressId'].'</customerShippingAddressId>'; if (isset($this->params['orderInvoiceNumber'])) { $this->xml .= ' <order> <invoiceNumber>'.$this->params['invoiceNumber'].'</orderInvoiceNumber> <description>'.$this->params['description'].'</orderDescription> <purchaseOrderNumber>'.$this->params['purchaseOrderNumber'].'</orderPurchaseOrderNumber> </order>'; } $this->xml .= ' <taxExempt>'. $this->params['taxExempt'].'</taxExempt> <recurringBilling>'.$this->params['recurringBilling'].'</recurringBilling> <cardCode>'. $this->params['cardCode'].'</cardCode>'; if (isset($this->params['orderInvoiceNumber'])) { $this->xml .= ' <approvalCode>'. $this->params['approvalCode'].'</approvalCode>'; } $this->xml .= ' </' . $type . '> </transaction> </createCustomerProfileTransactionRequest>'; $this->process(); }
here is the class code to go along with the above code.. if you really need it:
class AuthnetCIMException extends Exception {} class AuthnetCIM { const USE_PRODUCTION_SERVER = 0; const USE_DEVELOPMENT_SERVER = 1; const EXCEPTION_CURL = 10; private $params = array(); private $items = array(); private $success = false; private $error = true; private $login; private $transkey; private $xml; private $ch; private $response; private $url; private $resultCode; private $code; private $text; private $profileId; private $validation; private $paymentProfileId; private $results; public function __construct($login, $transkey, $test = self::USE_PRODUCTION_SERVER) { $this->login = trim($login); $this->transkey = trim($transkey); if (empty($this->login) || empty($this->transkey)) { trigger_error('You have not configured your ' . __CLASS__ . '() login credentials properly.', E_USER_ERROR); } $this->test = (bool) $test; $subdomain = ($this->test) ? 'apitest' : 'api'; $this->url = 'https://' . $subdomain . '.authorize.net/xml/v1/request.api'; $this->params['customerType'] = 'individual'; $this->params['validationMode'] = 'liveMode'; $this->params['taxExempt'] = 'false'; $this->params['recurringBilling'] = 'false'; } public function __destruct() { if (isset($this->ch)) { curl_close($this->ch); } } public function __toString() { if (!$this->params) { return (string) $this; } $output = '<table summary="Authnet Results" id="authnet">' . "\n"; $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Outgoing Parameters</b></th>' . "\n" . '</tr>' . "\n"; foreach ($this->params as $key => $value) { $output .= "\t" . '<tr>' . "\n\t\t" . '<td><b>' . $key . '</b></td>'; $output .= '<td>' . $value . '</td>' . "\n" . '</tr>' . "\n"; } $output .= '</table>' . "\n"; if (!empty($this->xml)) { $output .= 'XML: '; $output .= htmlentities($this->xml); } return $output; } private function process() { $this->ch = curl_init(); curl_setopt($this->ch, CURLOPT_URL, $this->url); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($this->ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); curl_setopt($this->ch, CURLOPT_HEADER, 0); curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->xml); curl_setopt($this->ch, CURLOPT_POST, 1); curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0); $this->response = curl_exec($this->ch); if($this->response) { $this->parseResults(); if ($this->resultCode === 'Ok') { $this->success = true; $this->error = false; } else { $this->success = false; $this->error = true; } curl_close($this->ch); unset($this->ch); } else { throw new AuthnetCIMException('Connection error: ' . curl_error($this->ch) . ' (' . curl_errno($this->ch) . ')', self::EXCEPTION_CURL); } }
and of course my cim =:
$cim = new AuthnetCIM('api-id', 'api-key', AuthnetCIM::USE_DEVELOPMENT_SERVER);
Any insight on this would be great...
I read a lil bit here and there, and I think that its because im not in "LIVE" mode and im using developer....
In my eyes this makes for a false development test site, since I can not complete testing my code fully without going live, so there really is no point in using a development site. If this is the case will it ever be allowed/updated to do such a thing of making real transactions that are "fake", to validate the code fully.
Solved! Go to Solution.
02-22-2012 01:41 PM - edited 02-22-2012 01:43 PM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
solved this by using the api in the real account, in test mode.. not using a developer account...
goes to show development and production servers are not using the same api code.. it is tweaked a little, therefor it is invailed to test aganst.
03-07-2012 02:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If i need to provide more info just let me know..
02-22-2012 03:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry to ask stupid questions, but why aren't you using the PHP SDK? Makes almost everything a lot simpler. I'd say download that and look at the CIM.markdown file in the doc folder, it has excellent examples of how to use the API.

02-22-2012 06:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I may have simply missed it, but I don't see anywhere in your code that would tell us what the "isSuccessful" method is looking at. In order to find out where the problem is originating, I would recommend starting by just dumping the curl response to see if you are even connecting.
02-24-2012 04:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the code connects works, infact everything works great.. i get email.. i see the accounts being made on backend i see the transactions work..
if i take it out of test mode i get issuccess..
only thing is the test mode on, returns the credit card as being voided. which is causeing the error.. of course it dont get voided in live mode.
03-07-2012 01:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I made a mistake, im not in test mode, im in developer...
03-07-2012 01:52 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
solved this by using the api in the real account, in test mode.. not using a developer account...
goes to show development and production servers are not using the same api code.. it is tweaked a little, therefor it is invailed to test aganst.
03-07-2012 02:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Trevor the isSuccessful is from the function:
private function process()
03-07-2012 04:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you use the Auto-decline feature that Authorize.Net offers then you're not really getting declines, you simply are declining already approved transactions which makes things much more technical and problematic then a true decline. Since they aren't really declined but you are simply making them look declined by reversing already approved transaction you are stuck with some card issuers holding those funds until the reversal clears.
03-07-2012 04:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
wow i found something wrong with my code, im returning succeffuls now.. heh i was trying to pass shipping infomation.. when i didnt have shipping... makes sense now..
03-07-2012 04:42 PM
