curl-library
Re: Curl::easy / Authorize.net
Date: Thu, 17 Apr 2003 09:59:17 +1000
On Wed, 16 Apr 2003 06:02 pm, Chris Ryan wrote:
> Has anyone used Curl::easy with Authorize.net? I am having a terrible time
> trying to connect successfully and transmit data to them. I make the post
> OK it seems, but they return an error about using the wrong integration
> method, though I've checked and re-checked and it all seems right.
I've never used authoriz.net, but usually that sort of message does suggest
you aren't sending them the right data for a valid transaction, rather than
being an http(s) protocol or network problem.
> There
> are lots of curl and php examples out there, but I have to go through Perl
> on my server. My code is below: ##begin code##
Looking at your code, I'm assuming you're using the AIM interface to
authorize.net (I just flicked through the docs on their support site).
(snip)
> my $datapost =
> "x_Version=3.1&x_Delim_Data=True&x_Password=[removed]&x_Login=[removed]&x_T
>ran_Key=[removed]";
I couldn't see anything in the AIM guide saying that you were required to send
your merchant password for a transaction - just login and tran_key. Perhaps
they are trying to save you from yourself?
> my $curl = Curl::easy->new() or die "curl init failed!\n";
>
> $curl->setopt(CURLOPT_URL, $url);
> $curl->setopt(CURLOPT_HEADER, 1);
> $curl->setopt(CURLOPT_POST, 1);
> $curl->setopt(CURLOPT_POSTFIELDS, $datapost);
>
> my $returnstring = $curl->perform();
>
> print "Content-type: text/html\n\n";
>
> print "$returnstring\n";
$returnstring is only going to have a curl status code in it - it's not going
to have the output of your request in it - that will already have been
produced by $curl->perform and sent to stdout. Assuming this is a CGI script,
you probably wanted to send your own headers to the browser *before* you get
the output from curl. Does this help?
print "Content-type: text/html\n\n";
my $returnstring = $curl->perform();
print "status=$returnstring\n";
-----
If you want the output from the authorize.net site to be in a variable for
further processing (and I think you do, given that it's just a bunch of
status values), you would need to use a body callback to capture the output
to a string - there are examples in the t/ directory of Curl::easy - though I
don't think you're up to that point yet....
Cris
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-04-19