Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried to integrate codeigniter authorize.net payment gateway by using the docs http://ci-merchant.org , I can successfully integrate the paypal but unfortunately i couldn't do authorize.net. The below code i have tried,but not working, how to do it ?

$settings = array(
'api_login_id' => 'xxxx',
'transaction_key' => 'xxxx',
'test_mode' => true);


$params = array( 
        'amount' => 10, 
        'currency' => 'USD', 
        'card_no' => '4111111111111111', 
        'exp_month' => '12', 
        'exp_year' => '14', 
        'csc' => 123, 
        'first_name' => 'Ashok', 
        'last_name' => 'KS',
        'return_url' => 'http://www.ioss.in/success',
        'cancel_url' => 'http://www.ioss.in/cancel'    
$response = $this->merchant->purchase($params);   

print_r($response) returns:

Merchant_response Object (
    [_status:protected] => failed
    [_message:protected] =>
    [_reference:protected] =>
    [_data:protected] =>
    [_redirect_url:protected] =>
    [_redirect_method:protected] => GET
    [_redirect_message:protected] =>
    [_redirect_data:protected] =>

UPDATE 1 after change the code, its working fine...

$params = array(
'amount' => 10.00,
'currency' => 'USD',
'return_url' => 'http://www.ioss.in',
'cancel_url' => 'http://www.google.in');
share|improve this question

closed as off topic by John Conde Feb 6 '13 at 12:27

Questions on Webmasters Stack Exchange are expected to relate to webmastering within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

And what does print_r($response) return? – Adrian Macneil Feb 6 '13 at 8:52
Merchant_response Object ( [_status:protected] => failed [_message:protected] => [_reference:protected] => [_data:protected] => [_redirect_url:protected] => [_redirect_method:protected] => GET [_redirect_message:protected] => [_redirect_data:protected] => ) – Ashok KS Feb 6 '13 at 8:59
Hmm. Two things: Authorize.net SIM doesn't need a credit card number. I think you want Authorize.net AIM. Also, when I've seen a failure with no error message before it was because you aren't using HTTPS on your payment page (which is required to securely transmit credit card details). – Adrian Macneil Feb 6 '13 at 9:03
Thankyou, when I change code $params = array( 'amount' => 10.00, 'currency' => 'USD', 'return_url' => 'ioss.in';, 'cancel_url' => 'ioss.in'); then works but it shows the error The following errors have occurred. (13) The merchant login ID or password is invalid or the account is inactive. Can I use test account for checking ?? because it goes to secure.authorize.net/gateway/transact.dll – Ashok KS Feb 6 '13 at 10:01
Ah good. I think you want to set the developer_mode parameter to true instead of test_mode - I can't exactly remember the difference, it's something weird that Auth.net does, and there are two different ways of testing (either using a developer account, or as a test transaction on a live account). – Adrian Macneil Feb 6 '13 at 11:19
up vote 1 down vote accepted

Per the comments, if the $response is failing with no error message it's generally because you are trying to submit credit card details unencrypted (not using HTTPS), which isn't supported by CI Merchant (for obvious security reasons).

In this case, the credit card details wern't necessary anyway because the Auth.net SIM gateway is an off-site gateway (card details are not entered on your site). Changing the $request to this fixed the problem:

$params = array(
    'amount' => 10.00,
    'currency' => 'USD',
    'return_url' => 'http://www.ioss.in',
    'cancel_url' => 'http://www.google.in',

In addition, to use the Authorize.net developer endpoint, developer_mode must be set to true in the gateway settings. This is different from test_mode (Auth.net specific feature):

$settings = array(
    'api_login_id' => 'xxxx',
    'transaction_key' => 'xxxx',
    'developer_mode' => true,
share|improve this answer
How to know the payment is success, I cannot use the function $response->success() ?? Can we use normal post method to check ? – Ashok KS Feb 14 '13 at 11:30
You need to call purchase_return() when the customer returns to your site, as per the tutorial on ci-merchant.org – Adrian Macneil Feb 14 '13 at 14:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.