The Commerce Recurring Framework requires us to define a charge callback in hook_commerce_payment_method_info(). This architecture is probably less than ideal as we probably want to be able call from the Commerce Recurring Framework a more general API function to process a payment. I think the commerce_cardonfile module might be a good candidate but perhaps even the commerce_payment module should do this...
But in the interest of getting something working sooner rather than later (there are folks who would like payments to go through), here's my first shot at giving the Commerce Authnet module an integration with the Commerce Recurring Framework. It's not pretty yet but it's close. I still need to test it more as I'm getting weird results, but it may just be that I need to refresh my sandbox.
Comments
Comment #1
R.J. Steinert CreditAttribution: R.J. Steinert commentedFirst pass. Not quite working for me yet but payments are processing. It may be an issue elsewhere in commerce_recurring module.
Comment #2
cosmicdreams CreditAttribution: cosmicdreams commentedI've applied this patch but I still don't see it actually sending payments. I'm trying to debug now.
Comment #3
R.J. Steinert CreditAttribution: R.J. Steinert commentedHm bummer. Check out function commerce_recurring_load_payments_due() in commerce_recurring.rules.inc. For starters, check to see if there are orders being selected when you run Cron. If there aren't any, then it's a configuration issue in your sandbox. I'm looking at one of my recurring orders from three cycles back and it has three payments on it. I'm going to debug why every recurring child order is processed every time.
Comment #4
R.J. Steinert CreditAttribution: R.J. Steinert commentedI just:
- deleted all my test orders
- added a new user
- checked out with a recurring product logged in with the new test user
- changed my server to the Invoice date on the parent order
- ran cron
- saw the child order created
- changed my server to the Payment Due date on the child order
- ran cron
- saw no payment attempted (no orders were collected by commerce_recurring_load_payments_due() as I saw in my debugger)
- changed my server to the day after the Payment Due date on the child order
- ran cron
- Received the following error after cron finished:
"Notice: Undefined offset: 1 in commerce_authnet_cim_cardonfile_charge() (line 1265 of /home/ubuntu/workspace/greenlink-pantheon/sites/all/modules/commerce_authnet/commerce_authnet.module)"
Debugging now...
Comment #5
R.J. Steinert CreditAttribution: R.J. Steinert commentedI found a problem with my last patch, using a value I thought would provide the CID id didn't so now I just take the first Card On File and assume that's what the user wants to use. We'll have to implement some "Default Card On File" functionality later in the Card On File module.
Running this test I'm having success until the last step which is causing duplicate payments:
- deleted all my test orders
- added a new user
- checked out with a recurring product logged in with the new test user
- confirmed a payment was made on the parent order
- changed my server to the day after the Invoice date on the parent order
- ran cron
- confirmed child order was created
- confirmed parent order Next Invoice field increased by interval set in Parent products Billing Interval
- changed my server to the day after the Payment Due date on the child order
- ran cron
- confirm a payment was made on child order
- ran cron again to make sure the same order wasn't picked up again for processing... It was.
So in
The $query->fieldCondition('commerce_recurring_payment', 'value', 0, '='); is not excluding orders that have payments. We have to figure out why.
Comment #6
R.J. Steinert CreditAttribution: R.J. Steinert commentedbug filed on commerce_recurring: #1421848: Document what charge callbacks should return
feature request on commerce_cardonfile: #1421832: Option to define a User's Default Card On File
Comment #7
R.J. Steinert CreditAttribution: R.J. Steinert commentedIt turns out the charge callbacks need to return TRUE to avoid the issue of duplicate payments. The new patch takes this into account. From my testing, this is working now.
Comment #8
BenK CreditAttribution: BenK commentedLooking forward to testing this patch...
Comment #9
vlkff CreditAttribution: vlkff commentedI have implemented the module (a sandbox project for a moment) providing an API to authorize.net ARB and implements ARB as a commerce payment method.
See: http://drupal.org/sandbox/vlkff/1572412
It may be a good (more secure) alternative solution.
Comment #10
scotwith1tI've added this patch to my commerce_authnet, i believe everything else is set up correctly, but i have hundreds of entries in my dblog about
Notice: Undefined index: in commerce_authnet_cim_cardonfile_charge() (line 1268 of /var/www/vhosts/drupal/7/sites/all/modules/commerce_authnet/commerce_authnet.module).
and
Notice: Undefined offset: 0 in commerce_authnet_cim_cardonfile_charge() (line 1268 of /var/www/vhosts/drupal/7/sites/all/modules/commerce_authnet/commerce_authnet.module).
then finally
Error occured whilst processing recurring transaction payment for order 16's - the payment method Authorize.Net CC commerce card on file charge callback reported an error.
not sure where things are going wrong...all the orders are in the orders list but are just in pending at this point...maybe there's also a rule setting that i've not got set up correctly?
Comment #11
scotwith1tWow. So, apparently this has to be turned on at admin/commerce/config/payment-methods/manage/commerce_payment_authnet_aim/edit/3 or similar (your AIM payment rule)...you have to check off "Enable Card on File functionality with this payment method using Authorize.Net CIM." for this to work. Good to know. Hope it will save a few others some trouble/time if they come across this because it wasn't clear to me. Now that I see that, I can probably report back with some useful feedback since my recurring payments oughta go through now! :)
@vlkff, i checked out your sandbox project and it has promise...will save comments for whenever you have a project page for it as this isn't really the appropriate venue.
Comment #12
fdefeyter@gmail.com CreditAttribution: fdefeyter@gmail.com commentedHello there!
I am currently building an e-commerce website with the help of Migrate and Commerce on D7. I went to the Drupalcamp in Gent and that did help a lot...
The thing is my client has recurring products but the clients haven't been billed since 2006 in some cases!
So I need to create automatic orders and send them a mail inviting them to pay.
What do you advice me? Using rules? Or your experience showed that we can "get back in the past" in order to create all those invoices/orders/paiements?
Thanks in advance for your reply ;-)
Comment #13
MedicSean37 CreditAttribution: MedicSean37 commentedSo has this patch been updated in the latest RC1 release?
Comment #14
DevElCuy CreditAttribution: DevElCuy commentedPatch at #7 applies clean on current 7.x.1.x-dev
Comment #15
benjf CreditAttribution: benjf commentedthe patch in #7 applies on RC1, and looks to work - although I've only done the most basic testing at this point.
Thanks!
Comment #16
dwkitchen CreditAttribution: dwkitchen commentedHere is a patch for working with Recurring 2.x (http://drupal.org/node/1935040) and Card on File 2.x (#1950354: 2.x Branch for Entities and Rules for Recurring)
Comment #17
dwkitchen CreditAttribution: dwkitchen commentedThis is now in the 1.x branch and will be in the next dev release.
Comment #18
jpstrikesback CreditAttribution: jpstrikesback commentedLooks like the charge callback didn't survive the merge
Comment #19
Albert Volkman CreditAttribution: Albert Volkman commentedNevermind, crosspost.
Comment #20
Albert Volkman CreditAttribution: Albert Volkman commentedChanging status
Comment #21
dwkitchen CreditAttribution: dwkitchen commentedAdded the call back, back into the payment method info hook
Comment #22
jpstrikesback CreditAttribution: jpstrikesback commentedLooks good from my end, tho I can't test as I'm only using Authnet as a map for another payment gateway implementation.
Comment #23
dwkitchen CreditAttribution: dwkitchen commentedComment #25
archimedes CreditAttribution: archimedes commentedWas this committed in the May 17th 7.x-1.1 release? I didn't see it in the notes, but it was fixed in dev before then.
Comment #26
dwkitchen CreditAttribution: dwkitchen commentedIts the Card on File 2.x update, that sits between Recuring and a payment gateway module.
Comment #27
archimedes CreditAttribution: archimedes commentedSweet, good to know. Thanks!