Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Now that we have an architecture for payment gateways in place, this can be ported. The maintainers are not currently working on this and we have other priorities, so this is open for anyone who wants to do the work or sponsor the work.
Comment | File | Size | Author |
---|---|---|---|
#15 | interdiff_13-15.txt | 4.48 KB | Nathaniel |
#15 | port_uc_authorizenet_to_d8-2656634-15.patch | 44.69 KB | Nathaniel |
|
Comments
Comment #2
longwaveMarked #2671196: Port Authorize.net payment method to Drupal 8 as duplicate
Comment #4
arkestra CreditAttribution: arkestra as a volunteer commentedI have started to port this over for Drupal 8. Using the attached patch (for the uc_authorizenet submodule), card processing should be possible (including the CIM capture).
Will continue improvements and porting other areas.
Comment #5
TR CreditAttribution: TR commentedPatches need to be made relative to the Ubercart directory, so for example in your patch
should really be
etc.
Comment #6
sarjeet.singh CreditAttribution: sarjeet.singh as a volunteer commentedHi All,
I am working ubercart migration d6 to d8 and we require this module so I have fixed and it is working.
Please review attracted patch and commit it dev branch if its fine.
Thanks
Comment #7
sarjeet.singh CreditAttribution: sarjeet.singh as a volunteer commentedComment #8
TR CreditAttribution: TR commentedThese patches are a step in the right direction, but they are far from complete.
@sarjeet.singh: Why didn't you include the changes from #4 in your patch? If they are needed then they should be included, otherwise they will be overlooked. If they are not needed then you need to explain why.
Here are my comments about the patches so far:
I do think that the existing uc_authorizenet code is almost working, but working and ported completely are two different things. Because I don't have an Authorize.Net account, I can't do any detailed testing of the module - that's what is needed most! It's very important to test every feature of the module, even ones that you don't currently use.
Comment #9
sarjeet.singh CreditAttribution: sarjeet.singh as a volunteer commentedSure @TR, I will finish these issue and provide you new patch ASAP.
Thanks
Comment #10
Nathaniel CreditAttribution: Nathaniel commentedMaking some progress on this. Applied both patches. Attaching an interdiff with #6.
Deleted:
uc_authorizenet_uc_payment_gateway
variable_get shim
Moved to AuthorizeNet.php and renamed:
_uc_authorizenet_cim_profile_create > cimProfileCreate
_uc_authorizenet_cim_profile_create_request > cimProfileCreateRequest
_uc_authorizenet_cim_profile_charge > cimProfileCharge
_uc_authorizenet_cim_profile_charge_request > cimProfileChargeRequest
_uc_authorizenet_cim_profile_get > cimProfileGet
_uc_authorizenet_cim_payment_profile_get > cimPaymentProfileGet
uc_authorizenet_xml_api > xmlApi
_uc_authorizenet_xml_api_wrapper > xmlApiWrapper
_uc_authorizenet_array_to_xml > arrayToXml
_uc_authorize_cim_xml_billto > cimXmlBillTo
_uc_authorize_cim_xml_shipto > cimXmlShipTo
_uc_authorizenet_cim_parse_response > cimParseResponse
_uc_authorizenet_substr_between > substrBetween
_uc_authorizenet_arb_parse_response > arbParseResponse
I’ve tested the default product checkout with Authorize.net payment method on their sandbox. That works fine. I’ve tested with CIM settings “Always create a CIM profile for securely storing CC info for later use.” checked and the CIM profile was created as expected.
I worked on the code for ARB and ARB silent post URL, but I am unable to test ARB at this time since the md5 hash has been deprecated and can no longer be configured in the account settings at authorize.net. Here is a related issue to follow up on: https://www.drupal.org/project/ubercart/issues/3025475
Related article:
https://support.authorize.net/s/article/What-is-the-MD5-Hash-Security-fe...
I'm open to working on any feedback within the next few weeks if anyone is available to review / test.
Comment #11
TR CreditAttribution: TR commentedThanks @Nathaniel! It's looking a lot better, but the main thing is simply having someone like you who can test it and confirm it works.
There're still a lot of small things I see that need to be done, but I think they can be done in stages - i.e. commit the big patch then fix the little things later. The little things are things like service injection, coding standards, and documentation. If you're willing to help test these patches that would help a lot to get things finished.
The only big thing I see is that all the utility functions should be put into a separate class - NOT into the AuthorizeNet plugin. It's just way too messy to put them all into one class. But the bigger reason is that that stuff should really be refactored to use SimpleXML, and having them separated will make the refactoring easier. The existing code was initially written for Drupal 5 by people who did not know PHP very well, and when PHP was much worse at supporting OO code than it is now (still not very good, but better ...) The only good thing to say for the existing code is that it seems to work. But doing our own XML parsing and passing around undocumented arrays is really a very poor way to do things. It's not robust because the parsing doesn't, for example, escape special characters in the text strings (what if someone's name has a '<' in it? Then all the parsing would break), it doesn't handle multibyte strings, it's hard to read and understand therefore easy to hide bugs. It's also not very efficient. Using the built-in SimpleXML classes will greatly reduce our code, make the remaining code simple to read and more robust and maintainable.
I'm willing to do the XML stuff if you're not familiar with SimpleXML, as long as you will test any modifications I make.
But first, lets fix a few things from the patch in #10.
AuthorizeNetController.php:
config.factory
service because it's not used anywhere.request_stack
service, you're always accessing it with$this->requestStack->getCurrentRequest()->request->get()
, which is pretty long and unnecessary. Instead of saving the service in the$requestStack
variable, change the constructor to save$request_stack->getCurrentRequest()->request
in a *protected* class variable named$request
. Then you can use$this->request->get()
everywhere else and it become much more readable.uc_auth_arb_payment
hook touc_authorizenet_arb_payment
. And this hook should be documented in uc_authorizenet.api.php (it is not currently)AuthorizeNet.php:
validateConfigurationForm()
isset()
used anywhere - if you need this, that means some variable isn't getting initialized properly. Configuration variables should always have default values, so I would prefer to have defaults set indefaultConfiguration()
rather than testing withisset()
\Drupal::httpClient()
calls. I don't know why those changes were made, but I think they are a step backwards in terms of clarity. I would appreciate it if you restored those to the original form (usingpost()
etc. instead ofrequest()
)._uc_authorizenet_ ...
into a separate class. I don't care what you name it, as it will be refactored/renamed in the conversion to SimpleXML.uc_authorizenet.module:
General:
t()
, but when you move that code into a class you should check to see if you can change this to$this->t()
. Many base classes, such asControllerBase
, use theStringTranslationTrait
.I'm sure there's more, but this would be a great start. Let me know if you want me to work on the XML stuff - I can get that done over the next week if you are willing to test it.
Comment #12
Nathaniel CreditAttribution: Nathaniel commented@TR thank you for the quick response and thorough review, that is refreshing. Tried to clean it up a bit. Attached a new patch.
It looks like there were some changes in guzzle that are breaking the current
\Drupal::httpClient()
call. Reverting it breaks the functionality, so I tweaked it a bit. Here are a few notes:Some other errors that came up:
TypeError: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, boolean given...
Error: Call to undefined method GuzzleHttp\Psr7\Response::send()...
Any suggestions for accessing the payment method plugin configurations? Or does this look right:
Yes, if you can handle the XML that would be great! Let me know if I can help with any more testing or code changes. It might be nice to have the CIM / ARB functionality in separate files depending on how the re-writes go.
Comment #13
Nathaniel CreditAttribution: Nathaniel commentedFixing some of the coding standards issues introduced in the previous patch.
Comment #14
TR CreditAttribution: TR commentedThanks @Nathaniel. It will take me a day or two to get around to reviewing this in depth. My initial glance shows that you addressed all the things I mentioned (Thanks!). If all looks good after the detailed review I will probably just commit this then submit a new patch to change the helper class to SimpleXML. The only thing that I noticed so far is that you tend to private a lot, whereas in Drupal we discourage the use of private, for various reasons. IMO private should be used in OO code only if you have a really really good reason why a subclass should not touch that variable or method. If you don't have a good reason, protected should be used.
Comment #15
Nathaniel CreditAttribution: Nathaniel commentedThanks for pointing that out. Changed private to protected.
Comment #16
albug CreditAttribution: albug commentedi need some help on ubercart module, i cant enable authorised.net under that module because it Requires: not_yet_ported (missing) i tried to look for the fix but in vain, i would appreciate if can get a fix and steps out to sort it out.