Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Null Response from Authorize.net Automatic Recurrent Billing(ARB)

I am getting null response from Authorize.Net when i try to create a recurring profile from my test server using credit card. this is what i get on var_dump($response) :

  object(AuthorizeNetARB_Response)#18 (2) {
      ["xml"]=>
      NULL
      ["response"]=>
      bool(false)
    }

While it is working perfectly when request made from localhost. var_dump($response) from localhost gives this output:

object(AuthorizeNetARB_Response)#18 (3) {
  ["xml"]=>
  object(SimpleXMLElement)#19 (2) {
    ["messages"]=>
    object(SimpleXMLElement)#21 (2) {
      ["resultCode"]=>
      string(2) "Ok"
      ["message"]=>
      object(SimpleXMLElement)#22 (2) {
        ["code"]=>
        string(6) "I00001"
        ["text"]=>
        string(11) "Successful."
      }
    }
    ["subscriptionId"]=>
    string(7) "2382386"
  }
  ["response"]=>
  string(401) "<?xml version="1.0" encoding="utf-8"?><ARBCreateSubscriptionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><subscriptionId>2382386</subscriptionId></ARBCreateSubscriptionResponse>"
  ["xpath_xml"]=>
  object(SimpleXMLElement)#20 (2) {
    ["messages"]=>
    object(SimpleXMLElement)#21 (2) {
      ["resultCode"]=>
      string(2) "Ok"
      ["message"]=>
      object(SimpleXMLElement)#22 (2) {
        ["code"]=>
        string(6) "I00001"
        ["text"]=>
        string(11) "Successful."
      }
    }
    ["subscriptionId"]=>
    string(7) "2382386"
  }
}

Don't know where could be the problem. Please help

Here's the code

Yii::import('application.vendor.anet_php_sdk.AuthorizeNet');
        Yii::import('application.vendor.anet_php_sdk.lib.*');
        Yii::import('application.vendor.anet_php_sdk.lib.shared.*');
        include('AuthorizeNetARB.php');
        include('shared/AuthorizeNetTypes.php');
        define("AUTHORIZENET_API_LOGIN_ID", Yii::app()->params['authorize_net_login_id']);
        define("AUTHORIZENET_TRANSACTION_KEY", Yii::app()->params['authorize_net_transaction_key']);
        define("AUTHORIZENET_SANDBOX", Yii::app()->params['authorize_net_sandbox_mode']);
        define("AUTHORIZENET_MD5_SETTING",Yii::app()->params['authorize_net_login_id']);

        $subscription                          = new AuthorizeNet_Subscription;
        $subscription->name                    = "Monthly Subscription";
        $subscription->intervalLength          = "1";
        $subscription->intervalUnit            = "months";
        $subscription->startDate               = "$today";
        $subscription->totalOccurrences        = "$months";
        $subscription->amount                  = "$amt";
        $subscription->creditCardCardNumber    = "$card_number";
        $subscription->creditCardExpirationDate= "$card_expiration";
        $subscription->creditCardCardCode      = "$cvv_number";
        $subscription->billToFirstName         = "Happy";
        $subscription->billToLastName          = "User";

        // Create the subscription.
        $request = new AuthorizeNetARB;
        $response = $request->createSubscription($subscription);
        $subscription_id = $response->getSubscriptionId();
        $status = $response->getResultCode();

        //var_dump($subscription);
        var_dump($response);die;
like image 201
manoj Avatar asked Apr 11 '15 04:04

manoj


People also ask

What is an ARB transaction?

ARB, or Automated Recurring Billing, is exactly what the name implies: a solution for automatically processing recurring or subscription-based payments. ARB allows you to create a subscription that includes your customers' payment information, billing amount and payment schedule.

Does Authorize.net allow recurring payments?

Accept and submit monthly recurring or installment payments with Automated Recurring Billing (ARB), and give customers a flexible way to pay via credit card or direct from their bank account. Create a subscription in your Merchant Interface, or integrate our ARB API to customize your online payments form.

What is automated recurring billing?

In the simplest terms, recurring payments (also known as subscription payments, automatic payments, or recurring billing) take place when customers authorize a merchant to charge them repeatedly for goods or services on a prearranged schedule (monthly, weekly, daily or annually).

Is Authorize.net real?

Authorize.Net is a United States-based payment gateway service provider, allowing merchants to accept credit card and electronic check payments through their website and over an Internet Protocol (IP) connection. Founded in 1996, Authorize.Net is now a subsidiary of Visa Inc.


2 Answers

Got it!!! It was a connection error. Got the error when i tried to make a payment with AIM. Still don't know why the error was not shown in ARB response. Anyways, here's what i did

In /lib/shared/AuthorizeNetRequest.php

Changed

public $VERIFY_PEER = true;

to

public $VERIFY_PEER = false;

And it worked!

like image 60
manoj Avatar answered Oct 23 '22 07:10

manoj


I see that you found a solution for your problem, but what you did there is a bad idea, You are essentially disabling SSL certificate validation.

Your server configuration should have trusted SSL authorities list so you wont run into this issue in the future & still be able to validate certificates.

If you don't have the ability to modify server configurations, You can download CA bundle from Mozilla & Feed it to curl in your code.

CA-Bundle URL: http://curl.haxx.se/ca/cacert.pem

Setting it up in your curl is easy as follows:

curl_setopt($ch, CURLOPT_CAINFO, '/path/to/cacert.pem');

If you have the ability to use a custom php.ini file or overriding php values in your system, You can set this globally for PHP.

curl.cainfo=/path/to/cacert.pem
like image 21
ahmad Avatar answered Oct 23 '22 06:10

ahmad