We have full support for Auth.net CIM, this issue as a fresh start to working on integration for Auth.net ARB recurring fees.

For previous discussion on the authorize.net integration see: #454952: Get uc_authorizenet CIM working with version 2.x

Comments

butler360’s picture

Glad to see this is going to be moving forward.

duellj’s picture

Has worked started on fixing this issue? If not, I'm working on getting a semi working implementation of the ARB handler for uc_recurring and can post patches as I go.

univate’s picture

I have added some code in modules/uc_recurring.uc_authorizenet.inc which adds partial support for auth.net ARB.

There is one line you can uncomment to start testing what is there and it should setup the recurring payments as is. But there is currently not support for handling the renewals and recording them in ubercart.

duellj’s picture

Status: Active » Needs work
StatusFileSize
new6.78 KB

Attached is the beginning of a working version of ARB recurring fee handler. I was able to successfully create, update, and delete recurring payments. Probably needs a little polishing up and testing, but everything appears to be working (other uc_recurring bugs notwithstanding).

univate’s picture

I think you should disable/remove the edit menu, as changing the recurring fee in uc_recurring will not actually change the amount renewed by auth.net, so this option shouldn't be shown to users

+    'menu' => array(
+      'edit' => UC_RECURRING_MENU_DEFAULT,

How are you planning to handle the "silent posts" so the renewals can be tracked?

duellj’s picture

Isn't the edit menu used to update credit card info for recurring fees?

By "silent posts", do you mean the recurring fee triggers that happen on the ubercart side? Currently, the script assumes that ARB is working, so the "renew callback" always tracks the payment and returns TRUE.

univate’s picture

No 'edit' for recurring fees is about changing the recurring order (amount, intervals etc...), uc_recurring has nothing to do with credit cards, there are other ways to pay for things without credit cards so that is a payment gateway thing not a uc_recurring thing.

In your code you have implemented the user operation to update credit card info using the 'update' menu item.

My understanding of ARB is that you setup the recurring payment at auth.net and then they do everything and charge the same amount at the specified intervals. But when a payment is processed for a renewal they send a message back to your site, this should be passed to uc_recurring by calling "uc_recurring_renew" so that everything that should happen at a renewal will be done by uc_recurring.

At the moment renewals aren't going to be registered in uc_recurring - as far as I can tell. Since uc_recurring doesn't trigger them, ARB triggers them.

Although having said that... because there is already code in the core uc_authorizenet module for handling ARB, I'm not entirely sure what will happen on a renewal.

duellj’s picture

No 'edit' for recurring fees is about changing the recurring order (amount, intervals etc...), uc_recurring has nothing to do with credit cards, there are other ways to pay for things without credit cards so that is a payment gateway thing not a uc_recurring thing.

Ahh, sorry, I was getting the "update" and "edit" links confused. I'll take out the "edit" link.

... because there is already code in the core uc_authorizenet module for handling ARB, I'm not entirely sure what will happen on a renewal.

There is already code in uc_authorizenet to handle the silent posts, and it looks like it saves the renewal using uc_recurring_fees_save(), which isn't a function anymore, not uc_recurring_renew, so it needs to be changed. Should this code live in uc_recurring.uc_authorizenet.inc? uc_recurring.module would have to hold the menu info, or else include a menu hook in uc_recurring.uc_authorizenet.inc (or maybe integrated into hook_recurring_info() ?).

univate’s picture

Whats in uc_authorizenet at the moment is related to the old uc_recurring-1.0, I don't think we can just break that - this is the main reason I haven't spent much time on this specific issue (not sure what is the best way to deal with the potential conflict)

duellj’s picture

Is there an issue to remove the recurring code from uc_authorizenet, since it's being moved to uc_recurring? I was unable to find one, so I'm unsure about what's happening on that front.

This might be a hack, but we could snipe the authnet/silent-post menu to use our own code using hook_menu_alter(). It wouldn't "break" the existing code.

At any rate, uc_authorizenet.module is going to have to change before this will work, since it's still using outdated hooks. For example, it implements hook_recurring_fee(), but without the $op parameter, so it calls uc_authorizenet_arb_create() for every hook_recurring_fee() call.

univate’s picture

This might be a hack, but we could snipe the authnet/silent-post menu to use our own code using hook_menu_alter(). It wouldn't "break" the existing code.

This is the type of thing I was thinking of also. Although the other thing I really want to avoid is having payment gateway specific stuff in uc_recurring and to include hooks like hook_menu_alter() you need the code to be part of the actual module, it wont work if its in the current *.inc file with all the other authorizenet specific stuff.

I have discussed this same problem for the Paypal WPS implementation: #569298: Create Paypal WPS recurring fee handler, in that case I have been thinking it is going to be easier/cleaner to have a separate module for paypal recurring. That could be an option here.

The other idea I can think of is having a number of wrappers functions for various hooks in uc_recurring which then loads the include files and attempts to call the hooks in those files - but I really hate that idea, mainly because I just don't want specific gateway code in uc_recurring, especially hosting gateways (e.g. Auth.net ARB and Paypal WPS) which I am just not as interested in as you are always going to be limited in the functionality that can be implemented with these. I want uc_recurring focus on full featured recurring subscription/billing systems and for that the focus needs to be on triggered gateways like Auth.net CIM which just store the credit card and we can trigger when and how much each payment is.

Actually maybe we could create a separate module to dealing with these two hosted recurring gateways (ARB and Paypal) to implement all these little hacks and extra hooks? - uc_recurring_hosted (this module could just go in the modules directory in uc_recurring)

As for the other hooks in uc_authorizenet that shouldn't be an issue as all the hooks I think have changed so the old ones shouldn't be called unless you have uc_recurring-1.0 installed.

univate’s picture

Also is not exactly the case...

Is there an issue to remove the recurring code from uc_authorizenet, since it's being moved to uc_recurring?

Ideally I would prefer to see payment method/gateway modules look after their own code and it shouldn't be up to uc_recurring to maintain their interfaces and protocols. It was just realized that trying to get large patches (of new feature) into ubercart at this stage when they are trying to get the stable version 2.0 out is going to be difficult, especially when the uc_recurring api may still need some tweaking and changing.

So the idea is that the payment specific code for core ubercart modules should all reside in the modules directory in uc_recurring so if and when we needed to merge it back we just have to copy over the code in those *.inc files and hand back maintenance of the code to those gateways.

duellj’s picture

I've been debating whether or not to just scrap ARB and go with CIM, since it's already implemented. I've got a project that needs recurring fees, and CIM seems like a better option.

The uc_recurring_hosted module seems like the better option, and it can be retired once paypal and authorize.net start implementing their own uc_recurring 2.x code. I didn't realize that it was a temporary solution to have gateway specific code in uc_recurring.

As for the other hooks in uc_authorizenet that shouldn't be an issue as all the hooks I think have changed so the old ones shouldn't be called unless you have uc_recurring-1.0 installed.

There's still an implementation of hook_recurring_fee() in uc_authorizenet.module that always calls uc_authorizenet_arb_create(), so that's a problem.

univate’s picture

Anyone interested in getting Auth ARB support in uc_recurring-2.x please read/test and support this issue in ubercart:
#592420: Move UC Recurring Fees code out of Authorize.Net module

Without this patch being committed it is going to be very difficult to ever get ARB working in uc_recurring 2.x due to the conficts with existing ARB/recurring code in ubercart/uc_authorizenet modules.

deggertsen’s picture

Subscribe.

Can anybody sum up where we're at in getting Authorize.net recurring payments working here? What currently needs to be tested/worked on? It would be nice to have a small outline of steps that still need to be taken so that I can easily see where I may be able to help in any way.

Thanks.

univate’s picture

Firstly if you can use Authorize.net CIM (instead of ARB), that is working and because it is more features already then ARB will ever be able to support.

If you still need ARB:
1) We need to convince the ubercart guys to commit the issue here: #592420: Move UC Recurring Fees code out of Authorize.Net module or people will need to patch ubercart with that patch in the meantime.
2) There is some code in the uc_recurring/modules/uc_recurring.uc_authorizenet.inc that was copied across from the core ubercart module.
3) The patch in #4 above is probably a little further along (although I haven't tested it myself).
4) We need to implement the following hook to handle the silent posts from authorize.net which need to call the uc_recurring_renew function:

hook_uc_auth_arb_payment();

5) All this needs to be tested.

duellj’s picture

4) We need to implement the following hook to handle the silent posts from authorize.net which need to call the uc_recurring_renew function:

hook_uc_auth_arb_payment();

This hook would have to live in uc_authorizenet.module, no? uc_recurring.uc_authorizenet.inc wouldn't be included during a silent post request, and you probably don't want it to live in uc_recurring.module, since it's gateway specific code.

deggertsen’s picture

I've been testing the patch in #592420: Move UC Recurring Fees code out of Authorize.Net module and the patch in #4 here and everything appears to be working as it should. I'll let you know if I find any problems.

univate’s picture

@duellj, correct and that is what I was talking about in #11 - we could try and get it into the uc_authorize module or create another module just for these hosting gateways (like uc_authorizenet and uc_paypal) that need these extra hooks. I personally think it should be in the gateway as well, although the ubercart guys are not really accepting any new features so the easier solution is doing it in uc_recurring project.

@deggertsen, what it won't be doing is registering or showing the renewals, thats what the silent post that we need to sort is about.

duellj’s picture

Status: Needs work » Needs review
StatusFileSize
new7.95 KB

Attached is the patch from #4 updated to include an additional module, uc_recurring_hosted, that doesn't do much besides providing an implementation of hook_uc_auth_arb_payment(). Was there anything else that needed to be in uc_recurring_hosted.module for the authorize.net ARB implementation?

Jackinloadup’s picture

subscribe

univate’s picture

+++ uc_recurring.uc_authorizenet.inc	8 Oct 2009 04:26:47 -0000
@@ -40,7 +40,17 @@ function uc_recurring_uc_authorizenet_re
+    'process callback' => 'uc_recurring_authorizenet_arb_process',
+    'cancel callback' => 'uc_recurring_authorizenet_arb_cancel',
+    'menu' => array(
+      'edit' => UC_RECURRING_MENU_DEFAULT,
+      'update' => array(
+        'title' => 'Update Account Details',
+        'page arguments' => array('uc_recurring_authorizenet_arb_update_form'),
+        'file' => 'modules/uc_recurring.uc_authorizenet.inc',
+      ),
+      'cancel' => UC_RECURRING_MENU_DEFAULT,
+    ),
     'own handler' => TRUE,
   );

I think the recurring info stuff for ARB probably should just go into the new module. Probably most of the ARB stuff may as well be in the hosted module and there also should be a module_exists('uc_authorizenet') around this as you wont be able to use it unless authorize module is enabled.

The 'edit' menu item needs to be deleted or use UC_RECURRING_MENU_DISABLE as changing the recurring fee in ubercart is not possible with ARB as it wont update what ARB is doing - if ARB has this feature we need to add a create its own form.

+++ uc_recurring.uc_authorizenet.inc	8 Oct 2009 04:26:47 -0000
@@ -348,7 +358,121 @@ function uc_recurring_authorizenet_arb_p
+
+  // Let other modules act on the canceled fee.
+  if (!empty($fee)) {
+    module_invoke_all('uc_arb_cancel', $fee);
+  }

We can delete this, uc_recurring has its own cancel hooks and CA triggers.

+++ uc_recurring_hosted/uc_recurring_hosted.module	8 Oct 2009 04:26:50 -0000
@@ -0,0 +1,27 @@
+  $fee = db_fetch_array(db_query("SELECT rfid FROM {uc_recurring_users} WHERE fee_handler = 'uc_authorizenet' AND data = '%s'", $post['x_subscription_id']));

The data field in the uc_recurring_users table should be an serialized array, so a quick hack would be to have something like... "data LIKE '%%s%'".

A cleaner solution would be to create a database table for the ARB_id -> recurring_fee relationship.

+function uc_recurring_hosted_uc_autho_arb_payment($post) {

Extra 'o' in there.

This review is powered by Dreditor.

duellj’s picture

StatusFileSize
new19.79 KB

This patch address the issues in #22.

there also should be a module_exists('uc_authorizenet') around this as you wont be able to use it unless authorize module is enabled.

Would the check for uc_authnet_arb_mode be enough, like it currently does in the uc_recurring.uc_authorizenet.inc hook_recurring_info()?

The 'edit' menu item needs to be deleted or use UC_RECURRING_MENU_DISABLE as changing the recurring fee in ubercart is not possible with ARB as it wont update what ARB is doing - if ARB has this feature we need to add a create its own form.

ARB doesn't allow you to change the interval length or unit, but it does allow you to change the amount, so it would have to be a custom form. I can add that in if needed.

+++ uc_recurring_hosted/uc_recurring_hosted.module 8 Oct 2009 04:26:50 -0000
@@ -0,0 +1,27 @@
+  $fee = db_fetch_array(db_query("SELECT rfid FROM {uc_recurring_users} WHERE fee_handler = 'uc_authorizenet' AND data = '%s'", $post['x_subscription_id']));

The data field in the uc_recurring_users table should be an serialized array, so a quick hack would be to have something like... "data LIKE '%%s%'".

This was copied over straight from uc_authorizenet.pages.inc, so it looks like it's another bug with the uc_authorizenet module.

A cleaner solution would be to create a database table for the ARB_id -> recurring_fee relationship.

I ended up creating a new database table to store the relationship; hooray for the cleaner solution!

duellj’s picture

StatusFileSize
new20.02 KB

Sorry, last patch didn't correctly create the new directory. Fixed in this one

univate’s picture

I don't really have a lot of time to fully test the recurring part, but it looks good and appears to work, so I have committed it. I did notice a couple of small issues which i fixed before committing.

Probably should also remind anyone that you need the patch here: #592420: Move UC Recurring Fees code out of Authorize.Net module for uc_recurring to track the renewals.

I would like to leave this issue open as I would like some feedback on how we can allow people to migrate from 1.0 to 2.0 that are already using ARB without existing recurring payments failing.

amitaibu’s picture

Status: Needs review » Needs work
+  $fee = db_fetch_object(db_query("SELECT rfid FROM {uc_recurring_hosted} WHERE subscription_id = '%s'", $post['x_subscription_id']));

Would be nicer if it was an API function, so any "hosted" module can use it without querying the db tables itself.

+ * @return
+ *   TRUE if recurring fee setup

Dot (.) missing.

+        // 'faxNumber' => '',

Remove.

+  uc_order_comment_save($order_id, 0, t('Authorize.Net: Subscription @subscription_id cancelled.', array('@subscription_id' => $subscription_id)), 'admin');

Not related specificaly to this patch, but hook should probably return apart of TRUE/ FALSE also &$messages, so uc_recurring will take care of writing the comments.

+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Update'),
+    '#suffix' => l(t('Cancel'), 'user/'. $user->uid),
+  );

You should use confirm_form for that, and not use #suffix.

+    drupal_set_message('Account updated.');
+    $form_state['redirect'] = 'user/'. $form_state['values']['uid'];
+  }
+  else {
+    drupal_set_message('Account update failed.', 'error');

t() missing in drupal_set_message().

duellj’s picture

StatusFileSize
new2.26 KB

Here's a patch that fixes a couple of the issues from #26. Checkout the newest version from CVS, since the main part of this patch has been committed, and now includes a lot of the paypal callbacks.

Not related specificaly to this patch, but hook should probably return apart of TRUE/ FALSE also &$messages, so uc_recurring will take care of writing the comments.

This should be a separate patch, since it affects all recurring payment gateways.

You should use confirm_form for that, and not use #suffix.

I question whether we need a cancel link here or not. What is needed is help text explaining what exactly is being done with this form (which is updating the users credit card info for the recurring fee).

duellj’s picture

Status: Needs work » Needs review
univate’s picture

Status: Needs review » Needs work

I've committed the patch in #27.

I'm leaving this in "needs work" while the following are resolved:
1) #592420: Move UC Recurring Fees code out of Authorize.Net module
2) consider what upgrade path is available going from 1.0 to 2.x
3) confirmation that ARB renewals are being handled and new orders are created in ubercart on each renewal.

mcaden’s picture

So I got a hacked version of 2.x working a while back. I got it working, tested it and everything was peachy - I told my client it was done and moved on. Now my client says he's concerned about not getting the billing he expected and has me double-check. I go in and look and my tests were the only thing in there. Nothing is currently working any more. I try and make a new ARB order and I get an error:

Authorize.Net: Recurring fee for failed.
E00003 - The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:totalOccurrences' element is invalid - The value '-1' is invalid according to its datatype 'Short' - The MinInclusive constraint failed.

Any progress on getting a clean, non-hack version of 2.x working? I need it to be ARB and I need 2.x because I need the drupal orders triggering role renewals.

I ask because I noticed the concerns mentioned in the previous post about separating uc_recurring stuff from auth.net appears to have been resolved.

mcaden’s picture

Any update on this?

univate’s picture

My understanding is that ARB generally works, it just needs that patch to ubercart to remove the uc_recurring-1.0 specific stuff that I mentioned in #29.

Anyone who wants this completely working without any patches should be pushing the ubercart guys to get that patch committed.

univate’s picture

univate’s picture

univate’s picture

mcaden’s picture

So with a fresh ubercart 2.x, uc_recurring 2.x, and the patch from #592420: Move UC Recurring Fees code out of Authorize.Net module that should do it?

Do I need uc_recurring 2.x-alpha or 2.x-dev?

BenK’s picture

Subscribing...

mcaden’s picture

Meh, finally able to talk the client into subscribing to CIM. Works like a charm.

deggertsen’s picture

Yeah, CIM works great. ARB is a little less expensive I think though so it would be nice if we could get it working...

univate’s picture

I did some basic testing it my patch above to the ubercart uc_authorizenet module did appear to work. Is it not working for you? Can people interested in this gateway start commenting on the ubercart issue so we can at least get the conflicting code out of uc_authorisenet to move this issue forward.

I do not care about this gateway as I don't use it, I have tried to do the work to get it working, someone needs to take up the cause and convince the ubercart guys to commit the patch.

univate’s picture

I did some basic testing on my patch above to ubercart's uc_authorizenet module and it did appear to work when I tried it. Is it not working for others? I would ask that anyone actually interested in this gateway start commenting on the ubercart issue so we can at least get the conflicting code out of uc_authorizenet to move this issue forward.

I do not care about this gateway as I don't use it, I have tried to do the work to get it working, someone needs to take up the cause and convince the ubercart guys to commit the patch.

univate’s picture

I did some basic testing on my patch above to ubercart's uc_authorizenet module and it did appear to work when I tried it. Is it not working for others? I would ask that anyone actually interested in this gateway start commenting on the ubercart issue so we can at least get the conflicting code out of uc_authorizenet to move this issue forward.

I do not care about this gateway as I don't use it, I have tried to do the work to get it working, someone needs to take up the cause and convince the ubercart guys to commit the patch.

butler360’s picture

Everything is working for me. How would I go about helping convince the Ubercart guys to commit this patch?

univate’s picture

Status: Needs work » Needs review

Good news, the ubercart patch has been committed to ubercart-2.x-dev, I haven't tested the current state of this module myself (don't have ARB account myself), so if anyone can confirm everything still works that would be great.

What I also would like to find out is if anyone is trying to upgrade from uc_recurring-1.0 and what we might need to do to support an upgrade for sites with active ARB accounts.

deggertsen’s picture

I'm still getting these errors:

End-user sees this when submitting payment. First payment goes through but apparently recurring payments aren't being setup.

Your order cannot be completed, because we could not process your recurring payment.
Please review your payment details and contact us to complete your order if the problem persists.

In the admin comments on the orders I get this.

07/15/2010
10:48:49 AM - Authorize.Net: ARB subscription created - 7163382
07/15/2010
10:48:50 AM - Authorize.Net: Recurring fee for failed.
E00012 - You have submitted a duplicate of Subscription 7163382. A duplicate subscription will not be created.

In this case it looks like it is trying to create the recurring fee twice but failing for the second one. In this particular order the person ordered two of the same product and a different recurring fee should be applied to each.

The other problem I get is this:

07/14/2010
3:23:35 PM - Authorize.Net: ARB subscription created - 7157477
07/14/2010
3:23:35 PM - Authorize.Net: Recurring fee for failed.
E00003 - The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:expirationDate' element is invalid - The value '2012-006' is invalid according to its datatype 'String' - The actual length is greater than the MaxLength value.

Not sure what the problem is with this one. Something about the expiration date? But 2012 should be a good expiration date unless the 006 shows that somehow an extra 0 is being thrown into the beginning of the month which I believe would cause a problem.

The 2nd of the two problems has happened the most and the error message that is being produced is causing people to go back in and reorder which charges them each time for the initial payment. Looking at Authorize.net I see that it is succeeding in creating a recurring payment for each order but it's running into problems when multiple recurring billing items need to be created in one order.

So I guess my conclusion is that this may need to be a separate issue in that I think that everything is working as long as only one recurring billing product is in the cart at checkout but that if there are multiple recurring billing products it breaks it.

Thanks.

univate’s picture

StatusFileSize
new777 bytes

This appears to be missing from the authorize.net ARB code, so I have added it. It is required for other hosted gateways like paypal. The patch I committed is below.

Hopefully someone who uses this gateway can do some actual testing.

deggertsen’s picture

@univate. I assume that doesn't solve my problem in #45 right? What exactly does this patch do that was missing? Something about the rfid... I will try to test it if I know what it is supposed to change.

Thanks

univate’s picture

No idea... I don't use this gateway, so can't really help with anything to do with this or most other specific gateways issues.

univate’s picture

Status: Needs review » Fixed

I am going to close issue since I believe the implementation works.

The issue that is still outstanding is:
#893812: Authorize.net ARB upgrade process for 1.0 -> 2.0

Any other bugs lets open new issues, so that can be specifically addressed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.