Re: Query related to authorized.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Reji,

The following are the coding for Authorize.Net payment gateway:

<?php

                            $currencycode = "USD";
                            $data = "";
                            $response = "";
                            $auth_desc = "Some Description";

                            $loginid  = "some_value from authorize.net";
                            $txnkey   = "some_value from authorize.net";
                            $x_test_request = "FALSE"; // For test transaction

                            $post_array = array(
                                 "x_login"                =>    $loginid
                                ,"x_tran_key"            =>    $txnkey
                                ,"x_version"            =>    $_POST['x_version']
                                ,"x_test_request"        =>    $x_Test_Request
                                ,"x_delim_data"            =>    $_POST['x_delim_data']
                                ,"x_delim_char"            =>    $_POST['x_delim_char']
                                ,"x_cust_id"            =>    $_SESSION['cust_id']
                                ,"x_customer_ip"        =>    $_POST['x_customer_ip']
                                ,"x_amount"                =>    $_POST['x_amount']
                                ,"x_currency_code"        =>    $currencycode
                                ,"x_method"                =>    "CC"
                                ,"x_type"                =>    $_POST['x_type']
                                ,"x_card_num"            =>    $_POST['x_card_num']
                                ,"x_card_code"            =>    $_POST['x_card_code']
                                ,"x_exp_date"            =>    $_POST['x_exp_date']
    
                                ,"x_first_name"            =>    $_POST['x_first_name']
                                ,"x_last_name"            =>    $_POST['x_last_name']
                                ,"x_address"            =>    $_POST['x_address']
                                ,"x_city"                =>    $_POST['x_city']
                                ,"x_state"                =>    $_POST['x_state']
                                ,"x_zip"                =>    $_POST['x_zip']
                                ,"x_country"            =>    $_POST['x_country']
                                ,"x_phone"                =>    $_POST['x_phone']
                                ,"x_email"                =>    $_POST['x_email']
    
                                ,"x_ship_to_first_name"    =>    $_POST['x_ship_to_first_name']
                                ,"x_ship_to_last_name"    =>    $_POST['x_ship_to_last_name']
                                ,"x_ship_to_address"    =>    $_POST['x_ship_to_address']
                                ,"x_ship_to_city"        =>    $_POST['x_ship_to_city']
                                ,"x_ship_to_state"        =>    $_POST['x_ship_to_state']
                                ,"x_ship_to_zip"        =>    $_POST['x_ship_to_zip']
                                ,"x_ship_to_country"    =>    $_POST['x_ship_to_country']
    
                                ,"x_invoice_num"        =>    $some_value
                            );

                            reset($post_array);
                            while (list ($key, $val) = each($post_array)) {
                                $data .= $key."=".urlencode($val)."&";
                            }

                            // Test URL
                            $AUTHNET_URL = "https://test.authorize.net/gateway/transact.dll";;
                            // OR Live URL
                            $AUTHNET_URL = "https://secure.authorize.net/gateway/transact.dll";;

                            $ch = curl_init();
                            curl_setopt($ch, CURLOPT_URL, $AUTHNET_URL);
                            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                            curl_setopt($ch, CURLOPT_FAILONERROR, 1);
                            curl_setopt($ch, CURLOPT_POST, 1);
                            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
                            $response = curl_exec($ch);
                            curl_close($ch);

if (count($response) > 0) {
$response_array = explode($_POST['x_delim_char'], $response);
if ($response_array[0] == 1) {
echo 'Transaction SUCCESS.';
}
else if ($response_array[0] == 2) {
echo 'Transaction DECLINED.';
}
else {
echo 'Transaction ERROR: <b>'.$response_array[3].'</b>';
}
}

?>

Try to avoid asking code in the community email mostly. Try to read the payment gateway API manual and integrate using cURL or SOAPClient whatever the manual recommends. However, yuo can get help from the people. The above coding will work definitely with proper test/live txnkey and loginid.

Bye.

Thanks & Regards
Udayakumar Sarangapani
Sr. PHP Developer
CompIndia Infotech Pvt. Ltd.
Chennai.

"Science is nothing but logic..."




----- Original Message ----
From: Reji Jayan <for_rejijayan@xxxxxxxxxxx>
To: php-objects@xxxxxxxxxxxxxxx
Sent: Thursday, 11 September, 2008 11:17:26 PM
Subject:  Query related to authorized.net


Hello  all,
 
i am asked this type of question by a friend of mine ... since i dont have any idea about this i am forwarding this here  .. expecting fast reply
 
 
 
the query is on how to  connect to authorize.net

there are some methods like AIM and SIM methods in this/.. for doing the payment.its same as paypal..but the coder work is some what different.
We need to give login id and  transaction key of the owner to connect to the authorize.net for online shopping.
where as in pay pal we give the owners email id to connect to paypal.

so i need some assistance for connecting to authorize.net
please ask for sample code which has successfully connected to the authorize.net

and how to give the login id, transaction key..in the source code..

i got the sample  code from authorize.net but it doesnot connect to the site..its showing error "incorrect login id or password".

 
Reji.

Connect with friends all over the world. Get Yahoo! India Messenger at http://in.messenger .yahoo.com/ ?wm=n/

[Non-text portions of this message have been removed]

    


      Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux