Reputation: 2804
I am trying to create Authorize.net recurring subscriptions using PHP. I installed Composer, then used the composer.json as shown here https://github.com/AuthorizeNet/sample-code-php/blob/master/composer.json to install the Authorize.net SDK. Now I am trying to create a subscription on my sandbox account using the code found here: https://github.com/AuthorizeNet/sample-code-php/blob/master/RecurringBilling/create-subscription.php.
When I try to run this, it gives me the following error:
Fatal error: Uncaught exception 'Exception' with message 'Error getting valid response from api. Check log file for error details' in /home/tpmadmin/public_html/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php:122 Stack trace: #0 /home/tpmadmin/public_html/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php(104): net\authorize\api\controller\base\ApiOperationBase->execute('https://apitest...') #1 /home/tpmadmin/public_html/test.php(58): net\authorize\api\controller\base\ApiOperationBase->executeWithApiResponse('https://apitest...') #2 {main} thrown in /home/tpmadmin/public_html/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php on line 122
I checked the error log and it's showing me the following:
Tue, 13 Oct 2015 06:51:05 +0000:CURL ERROR: SSL certificate problem: unable to get local issuer certificate
Tue, 13 Oct 2015 06:51:22 +0000: Request Serialization Begin
Tue, 13 Oct 2015 06:51:22 +0000: Request Serialization End
Tue, 13 Oct 2015 06:51:22 +0000: Url: https://apitest.authorize.net/xml/v1/request.api
Tue, 13 Oct 2015 06:51:22 +0000:Request to AnetApi:
<?xml version="1.0" encoding="UTF-8"?>
<ARBCreateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name><![CDATA[MY_API_LOGIN]]></name>
<transactionKey><![CDATA[MY_TRANSACTION_KEY]]></transactionKey>
</merchantAuthentication>
<refId><![CDATA[ref1444719082]]></refId>
<subscription>
<name><![CDATA[Sample Subscription]]></name>
<paymentSchedule>
<interval>
<length>1</length>
<unit><![CDATA[months]]></unit>
</interval>
<startDate><![CDATA[2020-08-30]]></startDate>
<totalOccurrences>12</totalOccurrences>
<trialOccurrences>1</trialOccurrences>
</paymentSchedule>
<amount>10.29</amount>
<trialAmount>0.00</trialAmount>
<payment>
<creditCard>
<cardNumber><![CDATA[4111111111111111]]></cardNumber>
<expirationDate><![CDATA[2020-12]]></expirationDate>
</creditCard>
</payment>
<billTo>
<firstName><![CDATA[John]]></firstName>
<lastName><![CDATA[Smith]]></lastName>
</billTo>
</subscription>
</ARBCreateSubscriptionRequest>
Sending 'XML' Request type
Tue, 13 Oct 2015 06:51:22 +0000:Sending http request via Curl
Tue, 13 Oct 2015 06:51:23 +0000:Response from AnetApi:
Tue, 13 Oct 2015 06:51:23 +0000:CURL ERROR: SSL certificate problem: unable to get local issuer certificate`
Note: in the message above I replaced my actual API_LOGIN_ID and TRANSACTION_KEY. The real message has the correct login information.
I don't know much about SSL certificates or what could be causing this. I've searched for hours on Google with no luck. Any help or advice would be awesome!
UPDATE: It's working on the live account, but not on the Sandbox account -_-
Upvotes: 3
Views: 656
Reputation: 25
I had a similar issue, but I'm only wanting to authorize.
So, for my situation with authOnly SANDBOX requests I modified HttpClient to include curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
If I were doing more than authOnly requests, I'd probably use a different Authorize API (CIM via SOAP, for example)
One of my peers believes that PROD won't give the issue and shouldn't require curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false) but I haven't tested that thoroughly.
Upvotes: 1