Be the first to know about special offers and new products for web developers and Internet business owners.
I will never share your email address with the bad boys. Period.
|
Be the first to know about special offers and new products for web developers and Internet business owners. I will never share your email address with the bad boys. Period.
The latest
Recent comments
|
PHP Class For Authorize.net Automated Recurring Billing Payments API
Submitted by alexis on Fri, 2007-02-23 19:18.
John Conde was the first one coding a PHP class for the recently launched Authorize.net Automated Recurring Payments API (ARB), he was also the guy who told me this so much wanted API was coming a few weeks ago. His code was PHP 5 only so I made a few changes a have just finished my first version, which runs in both PHP 5 and PHP 4. Download arb2.zip and let me know how it works for you. I'm still testing and could find some small bugs which need to some polish, I'll update this post and code if needed. You will need to have an ARB enabled Authorize.net account, of course. You can test the class with the following sample code: <?php
require_once("AuthnetARB.class.php");
$login = 'cnpdev4289';
$transkey = 'SR2P8g4jdEn7vFLQ';
$test = TRUE;
$arb = new AuthnetARB($login, $transkey, $test);
$arb->setParameter('interval_length', 1);
$arb->setParameter('interval_unit', 'months');
$arb->setParameter('startDate', date("Y-m-d"));
$arb->setParameter('totalOccurrences', 12);
$arb->setParameter('trialOccurrences', 0);
$arb->setParameter('trialAmount', 0.00);
$arb->setParameter('amount', 1.00);
$arb->setParameter('refId', 15);
$arb->setParameter('cardNumber', '5424000000000015');
$arb->setParameter('expirationDate', '2009-05');
$arb->setParameter('firstName', 'Joe');
$arb->setParameter('lastName', 'Doe');
$arb->setParameter('address', 'Casa 1872');
$arb->setParameter('city', 'City');
$arb->setParameter('state', 'FL');
$arb->setParameter('zip', '33619');
$arb->setParameter('country', 'us');
$arb->setParameter('subscrName', 'The Test Account');
$arb->createAccount();
echo 'isSuccessful: ' .$arb->isSuccessful() . '<br />';
if ($arb->isSuccessful()) {
echo 'cool, it worked! <br />';
} else {
echo 'error in payment <br />';
}
echo 'isError: ' .$arb->isError() . '<br />';
echo 'getSubscriberID: ' .$arb->getSubscriberID() . '<br />';
echo 'getResponse: ' .$arb->getResponse() . '<br />';
echo 'getResultCode:' .$arb->getResultCode() . '<br />';
echo 'getString: ' .$arb->getString() . '<br />';
echo 'getRawResponse: ' .$arb->getRawResponse() . '<br />';
?>Enjoy. Trackback URL for this post:http://ventanazul.com/webzine/trackback/42
|
Want to launch a online store, need a new look for your website, market your services on the Net or build a virtual community? Not a problem, let's talk about it. www.flickr.com
This is a Flickr badge showing public photos from alexisbellido. Make your own badge here.
Other Destinations |
cURL timesout
I am getting an error where the curl_exec($ch); command times out so completely that the php script stops running.
Suggestions?
If using on GoDaddy
First, thanks for the code! Second, if using this with GoDaddy, you will need to specify the use of an SSL Proxy.
GoDaddy shows the proxy info here:
http://help.godaddy.com/article.php?article_id=288&topic_id
You can paste the following right after the curl_init(); in the class (about line 57)
//required for GoDaddy
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
//required for GoDaddy
Not Getting Respons Variables
For some reason I'm not getting a response from auth.net, When I try to do a live subscription I get:
isSuccessful: 1
cool, it worked!
isError:
getSubscriberID: 1390463
getResponse: Successful.
getResultCode:Ok
getString:
BUT when I log in to auth.net it doesn't exist... I am in live mode, but its just not registering.. anybody else have this problem?
Also, how would on utilize the update and delete record functions?
THANKS SO MUCH FOR YOUR HELP
I've spent about 7 hours today working on this lol
I'm an idiot
Ok, I'm an idiot.. I was updating the WRONG auth.net account!!
However, I still was wondering how to use the delete record and update record functions with this script.
THANKS
Invalid authentication values
I have been tryign everything on this but get "User authentication failed due to invalid authentication values."
The api login id and transaction key i use is correct, and the authorize staff have confirmed that ARB is activated in my account.
Any ideas ?
Thanks
Gaurav
Having same issue
I am having the same issue... I doubt it's related to this class because I get it regardless... However I is giving me an E007 error message which is Invalid User Authentication...
I know I have the right login id and transaction key. I have also created new transaction keys just to make sure and using them unveils the same results..
Ne ideas?
User authentication failed explanation and fix
The reason you're experiencing user authentication errors is because you're running the script against the developer test url:
https://apitest.authorize.net/xml/v1/request.api
while using your real authorize.net login id and transaction key.
By "real", I mean the credentials you'd actually use in a live, business environment. Those credentials will only work with the production url:
https://api.authorize.net/xml/v1/request.api
The developer test url is only for those who registered for a free authorize.net developer test account. Your real, live authorize.net account login id and transaction key won't work with the 'apitest.authorize.net' url.
It's silly that Authorize.Net doesn't allow developers to perform 'test' requests against the 'production' url. It's funny that their developers weren't able to tell you the reason why your requests were being rejected. Maybe it was just too obvious.
So you have two ways to deal with this:
1) Register for a authorize.net developer account to get a login id and transaction key to use against the "test" url. Click the "Request a test account" link near the bottom of this page:
http://developer.authorize.net/
2) Just use the existing developer login id and transaction key that's already included with the script. Yes, they are real and do work.
query regarding Automated Recurring Billing(ARB )
Hello
i am developing a website where Automated Recurring Billing is required.
Here i want to update database whenever payment will happen. in time of subscription i am able to update database.can you please inform me how can i call my php script for updating database in time of next occurrence of payments for the subscription?
Alexis Rocks!
Thank you sooooo much for posting this example. After two weeks of off and on struggles with Authroize.net's sample php code without success, I plugged John's sample code in and within 5 minutes I had tested successfully with my developers account. After another 15 minutes, I had this solution implemented on my site and have tested two transactions of my own, without fail!!
Thanks for the post.
Sam
P.S. The godaddy code is an important piece if you are hosted on godaddy. Don't forget that!
Recurring Billing Control for Authorize.Net
FYI: My company has just released I-Bill IT, a library/control that offers a rich object-model for interfacing with Authorize.net. It is written in C#/.NET, but is also callable from any COM/scripting language on Windows platforms (ASP/vbscript, PHP, etc.). There is sample code for PHP on our website.
As far as I know, it is the *only* library currently out there that supports Authorize.net's Automated Recurring Billing (ARB) feature as well as Advanced Integration Method (AIM). As I said above, it offers a rich object model over the Authorize.net services, making it much easier and faster to add such functionality to your application.
Also, we worked closely with Authorize.net during the development of the control and it is certified by them for both AIM and ARB.
Details
Download Url: http://www.itdevworks.com/download.aspx
Online documentation: http://www.itdevworks.com/Documentation/iBillit/1.0/
If you download the control without a purchased license, it will run in "trial" mode, where you can either submit payments to Authorize.net's test gateways, OR you can submit transactions to the live gateways, but in test mode. There is no timeout on the trial version.
To purchase a license, the cost is $99.00 per server/installation.
I hope this helps someone out.
David Parker
President
IT DevWorks, LLC
http://www.itdevworks.com
Thank but what am I missing?
This class was very useful. It seems to work fantastically when we were in test mode, but when we switched to live mode it validates everything no matter what you enter.
I've seen heated arguments around over the whole ARB not being an actual processor and what have you. Fair enough. I don't really care. All I want is to be able to validate the card before creating an account. By the looks of this API, it would appear as though the validation is handled within this API and this class. Otherwise, why would you even need to submit card info and not just the refId of the account to set up ARB for?
At this point, thanks to authorize.net not having any useful information on this issue nor any reasonable support for integration, I don't care what process I have to go through to get subscriptions working. If anyone has an idea of why I can create an account with bunk info, I'd like to know why and how I might be able to fix the issue.
Thanks for the class!
-Kai
I changed test to false and
I changed test to false and entered our production login and transkey and can still get test card numbers to work but not real transactions. Anyone know what I'm doing wrong? I guess this is the same problem Kai is having.
Validating cards when using ARB
This is in response to Kai's post.
I have encountered this situation with a few clients. More specifically, in cases where an ARB subscription grants access to premium parts of a website, it is not completely validated until sometime later when Authorize.net's servers run their batch jobs to process ARB transactions. If the user enters invalid information, whether maliciously or accidentally, they still gain access to the premium parts of the site. Furthermore, Authorize.net does not notify you in any clear way (that I have seen) that the transaction failed. It probably is included with the end-of-day reports you get, but you would have to explicitly look at every one each day for the failure then go in and manually revoke that user's rights, which is both time consuming and terrible for customer relations.
The solution I have come up with is to submit the first payment as a normal payment transaction through the AIM API so you get an immediate response on the validity of the billing information. Then, if it goes through okay, set up your ARB subscription to start at the next billing cycle, rather than immediately. If the AIM transaction fails, you can inform the user immediately and therefore never give them access in the first place, or perform whatever notification and/or processing your system needs to do.
I hope this helps.
David Parker
President
IT DevWorks, LLC
http://www.itdevworks.com
Problem with CIM
When i use the CIM method for transaction iam getting the error "E00009
The payment gateway account is in Test Mode. The request cannot be processed.".
My account is in test mode but i cant test transaction can some one help
Thanks!
Thanks for the code. Very nice and it works much better than Authorize's own "sample" code. At least yours can be made to work!
For those guys needing more information, the guide is here: http://www.authorize.net/support/ARB_guide.pdf
I sure appreciate it. Now I'm off to customize it!
Start Date must not occur before the submission date.
Hello Everybody,
This example(sample code) was just running well but siddenly its showing me the error as
isSuccessful:
error in payment
isError: 1
getSubscriberID:
getResponse: Start Date must not occur before the submission date.
getResultCode:Error
getString:
Can anybody tell me what is the reason of that?
Thanks,
Srikanta
It is date error
Hey
I wonder if you have given proper dates in the start date field..because I faced the same error before and I fixed it..check it twice anyway
ARB Validation
(in response to Kai)
The ARB system is not an on demand system. If you want to know that a card validates as real and has enough funding to pay for your subscription, then you must run a manual AIM request using
AUTH_ONLYfor the amount you wish to charge. Then if this comes back successful, run your ARB request with the same data. The reason for this is that Authorize.net processes ARB requests in batch form.The time at which Authorize.net processes your ARB requests may vary but it's usually been around 3:00AM for me. You can setup what is called the silent postback URL. This URL is a script that you write that lives on a server you control. When ARBs are processed in the wee hours of the morning, the result of each ARB is sent to your silent postback URL. The data sent to your script will indicate whether an ARB request was actually successful or not. If the ARB request was denied then you can take the appropriate actions to disable that member's account.
Probably the best idea is to do a full
AUTH_CAPTURErequest for the first subscription period and then setup an ARB with the same data to start on the next period. For example, charge the customer's card with AIM for the first month, and make an ARB request that starts next month. If you're doing a free trial period then the first part is free anyway, so it doesn't really matter, you can just use the regular ARB API.ARB occurrence
i am using AUTH_ONLY for card validation after that creating ARB and set silent post url.But i have some problem it does'not give me x_subscription_id for updation ARB when user card expire
Post new comment