简体   繁体   中英

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;

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM