M
M
makaravich2017-09-07 22:56:20
HTML
makaravich, 2017-09-07 22:56:20

How to make a post request when using Authorize.Net?

Developer.authorize.net/api/reference/index.html describes how to use the Authorize.Net payment system API. As far as I understand, you can work with this by sending a POST request to one of the URLs
listed on the API Endpoints tab, depending on whether it is a test request or a working one (in particular, for testing https://apitest.authorize.net/xml/v1/ request.api).
As I understand it, the request should be XML data, examples of which can be seen on the Try It tabs. But it is not clear which field this XML data should belong to. Tried a bunch of options - nothing works.
Hence the question: maybe someone has come across the Authorize.Net API and knows how to send this request correctly, or maybe there are some standards for such things that I don’t know about?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
makaravich, 2017-09-07
@makaravich

All figured out. You really don't need any fields. Working code example:

<?php
$ch = curl_init();
$request='<authenticateTestRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    <merchantAuthentication>
        <name>хххххххххх</name>
        <transactionKey>ххххххххххххххх</transactionKey>
    </merchantAuthentication>
</authenticateTestRequest>';

curl_setopt($ch, CURLOPT_URL,            "https://apitest.authorize.net/xml/v1/request.api" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST,           1 );
curl_setopt($ch, CURLOPT_POSTFIELDS,     $request ); 
curl_setopt($ch, CURLOPT_HTTPHEADER,     array('Content-Type: text/xml')); 

$result=curl_exec ($ch);
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question