2

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 ?

$this->load->library('merchant');
$this->merchant->load('authorize_net_sim');
$settings = array(
'api_login_id' => 'xxxx',
'transaction_key' => 'xxxx',
'test_mode' => true);

$this->merchant->initialize($settings);

$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');
10
  • And what does print_r($response) return? Commented Feb 6, 2013 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
    Commented Feb 6, 2013 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). Commented Feb 6, 2013 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
    Commented Feb 6, 2013 at 10:01
  • 1
    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). Commented Feb 6, 2013 at 11:19

1 Answer 1

1

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,
);
$this->merchant->initialize($settings);
2
  • How to know the payment is success, I cannot use the function $response->success() ?? Can we use normal post method to check ?
    – Ashok KS
    Commented Feb 14, 2013 at 11:30
  • You need to call purchase_return() when the customer returns to your site, as per the tutorial on ci-merchant.org Commented Feb 14, 2013 at 14:37

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