Welcome Guest, Not a member yet? Register   Sign In
How to accept recurring payments in a subscription site?
#1

[eluser]Kevin Smith[/eluser]
Hey CI folks,

Forgive me for asking something that's probably been asked before, but I'm fairly new, and I can't find the answer. It doesn't appear that there's a library or anything pre-made for handling recurring payments, so I'm assuming that most of you roll your own if you need it. I'm working on developing an application with a friend in our spare time, and I'm using this time to learn CI since we don't really have a deadline. Can anyone help point me in the right direction for putting the pieces together to roll my own subscription-based membership? I'm already using DX_Auth with good results to get the membership part of the site together, but I'm not sure how to integrate recurring payments.

Thanks in advance for any help that might be offered!
#2

[eluser]bretticus[/eluser]
Often, reoccurring payments can be handled by the payment gateway provider directly. What you ask (a CI library for payments) is such a narrow field of development that it's not really a CI issue at all. CI is a framework for generic development. That is probably why nobody answered this post before me. You might have more success looking in forums that deal with payments such as oscommerce or zencart.
#3

[eluser]Colin Williams[/eluser]
If the merchant can handle it, good. Otherwise you just need a cron script to run every so often to filter through the members and charge the ones that are due.
#4

[eluser]Kevin Smith[/eluser]
So what we're doing here in a software-as-a-service kind of thing. And I know it's typically bad practice to store the user's credit card numbers on our server, so I was thinking I'd have to use something like Authorize.Net's CIM, which stores the user's CC numbers on their end and handles the recurring billing.

I suppose I was really wondering if anyone had experience with this sort of thing and if they could give me some places to start in my development. Has anyone used Authorize.Net's CIM to do recurring billing before?

(I don't need an entire web store, so I think OSCommerce and Zencart would be overkill.)
#5

[eluser]pistolPete[/eluser]
[quote author="hearsay" date="1237341533"]I suppose I was really wondering if anyone had experience with this sort of thing and if they could give me some places to start in my development. Has anyone used Authorize.Net's CIM to do recurring billing before?
[/quote]

http://ellislab.com/forums/viewreply/533592/
#6

[eluser]bretticus[/eluser]
I have used it to do a normal sale. and I just looked through the manual. reoccurring billing is easy it seems:

x_recurring_billing
Optional
The recurring billing status
TRUE, FALSE,
T, F,
YES, NO,
Y, N,
Indicates whether the transaction is a recurring billing transaction.

(the guide can be found at http://www.authorize.net/support/AIM_guide.pdf)

In other words you just send an extra key/value pair to https://secure.authorize.net/gateway/transact.dll but I don't remember how this is encoded. However, I used this class for my project. Worked fine:

http://www.zend.com//code/codex.php?ozid=619&single=1

I stuck it in my libraries folder and used it liek this:

Code:
//load authorizenet
                        $this->load->library('authorizenet');
                                            
                        
                        // setup gateway trans
                        $this->authorizenet->isTestOnly = false;
                        $this->authorizenet->useTestGateway = false;
                        $this->authorizenet->charDelimit = "|";
                        $this->authorizenet->setLoginId(DCS_AUTHNET_X_LOGIN);
                        $this->authorizenet->setTransKey(DCS_AUTHNET_X_TRAN_KEY);
                        $this->authorizenet->setAddress($bill_address);
                        $this->authorizenet->setCardNumber(card_number_clean($cardnum));                
                        $this->authorizenet->setCity($bill_city);                
                        $this->authorizenet->setCountry("United States");                
                        $this->authorizenet->setCustomerEmail($bill_email);            
                        $this->authorizenet->setExpireDate(date("my", strtotime("$month/1/$year")));
                        $this->authorizenet->setFirstName($bill_first);
                        $this->authorizenet->setLastName($bill_last);
                        $this->authorizenet->setPhone($bill_phone);
                        $this->authorizenet->setState($bill_state);
                        $this->authorizenet->setZip($bill_zip);    
                        $this->authorizenet->setCustomerID($user_data->PersonID);
                        $this->authorizenet->setInvoiceID($randnum);
$this->authorizenet->setAmount(sprintf(".2f",$total));
                        $this->authorizenet->setDescription("Purchase by $bill_first $bill_last for " . sprintf(".2f",$total));
                    
                        if ( $this->authorizenet->process() !== false ) {//...
#7

[eluser]bretticus[/eluser]
I should also mention I used the php curl library instead on calling a shell command, if you want to go that route, see snippet below (this replaces the exec command under process)

Code:
// ... in constructor ...
$this->gatewayUrl = "https://secure.authorize.net/gateway/transact.dll";
$this->gatewayUrl_test = "https://test.authorize.net/gateway/transact.dll";
//... in process()
$ch = ( $this->useTestGateway ) ? curl_init( $this->gatewayUrl_test ) : curl_init( $this->gatewayUrl );
        curl_setopt( $ch, CURLOPT_HEADER,         0 );
        curl_setopt( $ch, CURLOPT_POSTFIELDS,     $data ); // set the fields to post
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );       // make sure we get the response back        
        $returnString = curl_exec( $ch );                          // execute the post
          curl_close($ch);
#8

[eluser]bretticus[/eluser]
I know you asked about CIM (and no haven't used it) and I am over-posting here, but I realized how many changes I made to that Authorizenet class from long ago and thought I'd better include mine with changes in case you decide to go the AIM route instead (might as well get money in your merchant account.)




Theme © iAndrew 2016 - Forum software by © MyBB