cancel
Showing results for 
Search instead for 
Did you mean: 

Possible not to use the SDK?

I have been working on migration over the last couple months since A.N eliminated the previous methods at the end of May 2017.

 

I never used the SDK because of the complexity.   The number of lines in my previous code to process credit cards is less than the number of files in the SDK.

 

All I need to do is AUTH_CAPTURE and VOID.  That's it.  I do not need all the other crap.

 

Unfortunately, all my solution testing returns null values from A.N so I have no possible way to diagnose errors.

 

Has anyone been successful creating a simple A.N interface?

mvpetrovich
Member
17 REPLIES 17

@mvpetrovich The SDK exists so you can implement all Authorize.Net features into your solution, seamlessly. But if all you need is to make two API calls, you only need to make the calls directly.

The calls you want are here:

https://developer.authorize.net/api/reference/#payment-transactions-charge-a-credit-card

https://developer.authorize.net/api/reference/#payment-transactions-void-a-transaction

--
"Move fast and break things," out. "Move carefully and fix what you break," in.
Lilith
Administrator Administrator
Administrator

Yes, not only is it possible to avoid using the SDK, in many cases it is desirable.

For example, posting the following XML with the appropriate actual values, to the Sandbox URL: https://apitest.authorize.net/xml/v1/request.api or
Production URL: https://api.authorize.net/xml/v1/request.api as the case may be, should enable you to easily Void a transaction.

 

<createTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <merchantAuthentication>
    <name>API_LOGIN_ID</name>
    <transactionKey>API_TRANSACTION_KEY</transactionKey>
  </merchantAuthentication>
  <refId>123456</refId>
  <transactionRequest>
    <transactionType>voidTransaction</transactionType>
    <refTransId>22434566</refTransId>
   </transactionRequest>
</createTransactionRequest>

Of course, the method you use to populate and post your XML payload will vary depending on your chosen language of implementation.

Powered by NexWebSites.com -
Certified Authorize.net developers
NexusSoftware
Trusted Contributor

I was getting a lot of misinformation.  I was told to use secure2.authorize.net/gateway/transact.dll and post using key-value pairs.  That gateway never returned a response, so I was left with trial and error.

 

I understand that the SDK can do everything possible with AN, but I do not want to do everything.  The SDK is bloated.  In fact, the SDK, for a trival aspect of a website, uses more files than my entire framework.  Most credit card processing requires only a couple hundred lines of code.

 

I am going to use your advice and go down the path of using the request.api with XML.  Hopefully, I will have better luck.

 

 

@mvpetrovich It sounds like people were directing you to use our legacy connection, which we wouldn't recommend in general. I apologize for the confusion there.

I understand and agree that you don't need the SDK. I was merely explaining what the SDK was for.

Let us know if you have any follow-on questions and we'll see what we can do for you.

--
"Move fast and break things," out. "Move carefully and fix what you break," in.

Well, I have continued to go down several dead ends.  I have never been able to get apitest.authorize.net/xml/v1/request.api to respond to anything I have done.  Trial and error programming is always frustrating.

 

Can someone post PHP CURL code and a simple XML markup that can actually retrieve something?

 

You would think simply taking the CURL from the SDK and sending a simple XML string would be an easy thing to do, but it did not work for me after hundreds of experiments.

<?php

$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
<ARBCreateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
	<merchantAuthentication>
		<name>LOGIN_ID</name>
		<transactionKey>TRANSACTION_KEY</transactionKey>
	</merchantAuthentication>
	<refId>Sample</refId>
	<subscription>
		<name>New Sample subscription</name>
		<paymentSchedule>
			<interval>
				<length>1</length>
				<unit>months</unit>
			</interval>
			<startDate>2018-02-28</startDate>
			<totalOccurrences>12</totalOccurrences>
			<trialOccurrences>1</trialOccurrences>
		</paymentSchedule>
		<amount>100.29</amount>
		<trialAmount>0.00</trialAmount>
		<payment>
			<creditCard>
				<cardNumber>4111111111111111</cardNumber>
				<expirationDate>2020-12</expirationDate>
			</creditCard>
		</payment>
		<billTo>
			<firstName>Rick</firstName>
			<lastName>Love</lastName>
		</billTo>
	</subscription>
</ARBCreateSubscriptionRequest>';

  $url = 'https://apitest.authorize.net/xml/v1/request.api';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlContent);
  $result = curl_exec($ch);
  echo $result;
  curl_close($ch);

 Just replace LOGIN_ID and TRANSACTION_KEY with your own sandbox credentials.

Powered by NexWebSites.com -
Certified Authorize.net developers

This is exactly what I asked for, but the code provided is not functional.  I have spent another day at this, and this took me down another dead end. 

 

I see differences with my test destination from Authorize.Net.  I can send and retrieve information very easily from my test destination, but not from Authorize.Net.

 

My test destination will not allow the 'https://' prefix, and I never use that normally with CURL.  For some reason my test destination will also not allow the content type to be sent.

 

I keep trying and adding and removing lines, trying to send an SSL and not.  I cannot figure out the behaviour of Authorize.Net.

 

I assume the posted code was never tested.  If you ever find functional code please post it.

 

That code was tested and does work. Use the following to find out what version of TLS your cURL is using.

<?php 
$ch = curl_init('https://www.howsmyssl.com/a/check');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);

$json = json_decode($data);
echo $json->tls_version ."\n";

 

 

Powered by NexWebSites.com -
Certified Authorize.net developers

Oh, Thanks!  My test site was using TLS 1.0, and I put the code on a site using TLS 1.2.  The code you supplied worked fine.  That should now move me forward.