webform_civicrm icon indicating copy to clipboard operation
webform_civicrm copied to clipboard

Fix authnet payment failed.

Open puresyntax71 opened this issue 2 years ago • 9 comments

Overview

When using contributions with authorize.net, webform keeps on failing submission. On later versions of CiviCRM, the following error pop ups:

It appears that this transaction is a duplicate. Have you already submitted the form once? If so there may have been a connection problem. Check your email for a receipt from Authorize.net. If you do not receive a receipt within 2 hours you can try your transaction again. If you continue to have problems please contact the site administrator.

On lower versions of CiviCRM, it only says "Payment failed".

Before

Error when using contributions with auth.net.

After

No more error.

Technical Details

The error seem to have started on webform_civicrm 6.1.0.

puresyntax71 avatar Oct 13 '22 15:10 puresyntax71

Can you please clarify what you mean by "The error seem to have started on webform_civicrm 6.1.0"? Any idea which PR?

If this is ensuring webform civicrm works with Authorize.net then that's great - but it will require a test to ensure param confusion gets identified quickly in case this happens again.

KarinG avatar Oct 13 '22 15:10 KarinG

Also which authorize.net is this? Core or extension -and why are there two authorize.net options? @mattwire - I'm sure you know the answer to this one! :-)

KarinG avatar Oct 13 '22 15:10 KarinG

Yeah, seems to have started from this PR https://github.com/colemanw/webform_civicrm/pull/698 although I haven't checked on why since I just went through the merge commits between 6.1.0 and 6.2.1.

Also which authorize.net is this?

This is the core one. I tested it with vanilla Drupal 9.4.5 with webform_civicrm 6.2.1 and CiviCRM 5.53.

Yeah, definiitely need tests.

puresyntax71 avatar Oct 13 '22 15:10 puresyntax71

I have added a test that is a stripped out version of the StripeTest (no verification of contribution). I'm not entirely sure how to set the username and password though.

In, gitlab, we normally used environment variables in the CI/CD although I'm not sure how it works on github.

puresyntax71 avatar Oct 24 '22 19:10 puresyntax71

Great - thank you!

authorize.net must have test accounts that you can use with fake credit cards - that's what you'll want to use for:

      // 'user_name' => 'xxxx',
      // 'password' => 'xxxx',

Also, I do think we need a // Load the Contribution and check the values to evaluate if Status = Completed, if the Amount is correct, etc.

KarinG avatar Oct 25 '22 01:10 KarinG

authorize.net must have test accounts that you can use with fake credit cards - that's what you'll want to use for

Yeah, not sure if there exists one although I can't find any apart from creating sandbox accounts.

I went ahead and refactored the tests. I'm not sure if it's a bit too much change though. I just copied StripeTests to PaymentProcessorBaseTest and used that as a base class for both Stripe and AuthorizeNet to avoid duplicates.

From https://www.drupal.org/project/webform_civicrm/issues/3312157#comment-14747198:

Such tests already exist for iATS Payments, and also for Stripe.

Oh, I didn't realize there were already tests for other payment processors. I thought it was only Stripe, Pay Later, and Dummy.

puresyntax71 avatar Oct 25 '22 08:10 puresyntax71

Hi - I strongly prefer just a new test for authorize.net [that does not touch/modify any other test] so that we can be 100% sure there is no breakage. In future work we'll consolidate and stream line code [remove duplications].

However if authorize.net does not have any standard sandbox we can use then a functional end-to-end test is not possible. In these tests we really need to hear back from the payment processor.

@mattwire - do you happen to have a set of test credentials we can use for authorize.net?

KarinG avatar Oct 25 '22 15:10 KarinG

Yeah, I've updated the test with verification based on StripeTest.

puresyntax71 avatar Oct 26 '22 08:10 puresyntax71

Error message Notice: Undefined index: user_name in CRM_Core_Payment_AuthorizeNet->__construct() (line 68 of /home/runner/drupal/vendor/civicrm/civicrm-core/CRM/Core/Payment/AuthorizeNet.php). 

Without dedicated Auth.net test credentials we can't do end to end testing. Does Skvare have dedicated Sandbox credentials you can put in? If not - then I'm happy to merge just the one-line param variation fix - but of course there would be no future guarantees that Core Auth.net works with WFC.

KarinG avatar Oct 28 '22 14:10 KarinG