Search code examples
phpauthorize.netrecurring-billing

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;

Solution

  • 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!