Problems using PHP and CURL
Craig Hoffman
choffman at eclimb.net
Fri Jan 23 07:57:58 PST 2009
Hi Chris -
Thanks for responding. I pasted a code snippet below. Basically it
sends an array to Authorize.Net for processing. Authorize.Net
responds with transaction details (approved, declined, wrong address,
etc...).
When CURL is working, using Liyanage PHP I get this response:
Sent:
Array ( [x_login] => 6zz6m5N4Et [x_test_request] => TRUE [x_tran_key]
=> 9V9wUv6Yd92t27t5 [x_delim_char] => | [x_delim_data] => TRUE
[x_encap_char] => [x_amount] => [x_method] => CC [x_type] =>
AUTH_CAPTURE [x_card_num] => [x_card_code] => [x_exp_date] =>
[x_first_name] => [x_last_name] => [x_address] => [x_company] =>
[x_city] => [x_state] => [x_zip] => [x_country] => [x_phone] =>
[x_customer_ip] => ::1 [x_description] => [x_invoice_num] => )
Received:
Array ( [0] => 3 [1] => 2 [2] => 33 [3] => (TESTMODE) Credit card
number is required. ....
Using MacPorts PHP (5.2.8) - I do not get any response from CURL. The
received array comes returns empty.
Array ([0]=>)
Any thoughts? Something with the configuration?
Code Snippet:
public function processTransaction() {
$this->transaction = array(
"x_login" => "$this->login", // no x_version
"x_test_request" => "$this->test_mode",
"x_tran_key" => "$this->transactionkey",
"x_delim_char" => "$this->delim_char",
"x_delim_data" => "$this->delim_data",
"x_encap_char" => "$this->encaps_char",
"x_amount" => "$this->amount",
"x_method" => "$this->ccecheck",
"x_type" => "$this->trans_type",
"x_card_num" => "$this->cc_number",
"x_card_code" => "$this->ccv_num",
"x_exp_date" => "$this->exp_date",
"x_card_code" => "$this->ccv_num",
"x_first_name" => "$this->billing_first_name",
"x_last_name" => "$this->billing_last_name",
"x_address" => "$this->billing_address",
"x_company" => "$this->billing_company",
"x_city" => "$this->billing_city",
"x_state" => "$this->billing_state",
"x_zip" => "$this->billing_zip",
"x_country" => "$this->billing_country",
"x_phone" => "$this->billing_phone",
"x_customer_ip" => "$this->customer_ip",
"x_description" => "$this->billing_desc",
"x_invoice_num" => "$this->invoice");
//Print transaction array out for debugging
print_r($this->transaction);
$data = "";
reset($this->transaction);
while (list ($key, $val) = each($this->transaction)) {
$data .= $key . "=" . urlencode($val) . "&";
}
$data = preg_replace("/&$/", '', $data); // strip the trailing &
$AuthNetConn = curl_init();
curl_setopt($AuthNetConn, CURLOPT_URL, $this->auth_url);
curl_setopt($AuthNetConn, CURLOPT_POST, 1);
curl_setopt($AuthNetConn, CURLOPT_POSTFIELDS, $data);
curl_setopt($AuthNetConn, CURLOPT_RETURNTRANSFER, 1);
$this->response = curl_exec($AuthNetConn);
$this->AuthResponse = explode($this->delim_char, $this->response);
curl_close($AuthNetConn);
}
_______________________
Craig Hoffman
iChat / AIM: mountain.dog
_______________________
On Jan 23, 2009, at 8:40 AM, Chris Janton wrote:
> On 2009-01-23 , at 06:54 , Craig Hoffman wrote:
>
>> Ok, here it goes. I'll try to explain this the best I can. A few
>> days ago I started using MacPorts to replace Marc Lynage's PHP
>> package. Everything installed and worked without a hitch (PHP,
>> Apache2, MySQL, CURL, Etc...). Yesterday, while working on a PHP
>> CURL script, I noticed CURL is not sending or receiving the
>> request. The script works fine on our production server and when
>> I'm running Marc Lynage's PHP package (5.2.5) / Apple's stock
>> Apache version. MacPort PHP Info file (5.2.8) tells me CURL is
>> installed. I've also compared both PHP INI files (Lynage's and
>> MacPorts) and their identical. I'm stumped on why it works on one
>> but not the other. Could it be something with Apache2?
>>
>> Does anyone have any ideas what's going on?
>
>
> I replaced the Liyanage PHP long time ago - do you have an example
> script (PHP, simple) that demonstrates the problem?
>
> 8)
> ----------------------------------
> Chris Janton - face at CentosPrime dot COM
> Netminder for Opus1.COM
>
>
More information about the macports-users
mailing list