Content-Length: 328556 | pFad | https://github.com/activemerchant/active_merchant/pull/4413

B6 Vantiv: Read saleResponse duplicate attribute by mashton · Pull Request #4413 · activemerchant/active_merchant · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vantiv: Read saleResponse duplicate attribute #4413

Merged

Conversation

mashton
Copy link

@mashton mashton commented May 3, 2022

The LitleGateway parse method reads elements and their text values, but does not read any of the elements attributes. Here we read one very specific attribute (probably not worth generalizing just yet). Here we're interested in a Litle saleResponse that may or may not have the attribute duplicate='true'. All Litle saleResponses will include duplicate: true/false.

Note on testing: Remote test for this feature is missing. It looks like the testvantivcnp api does not return the duplicate attribute the same way the production api does. Additionally, something seems to have changed in the testvantivcnp api such that existing remote tests fail. PR coming soon with fixes for existing tests.

CE-2506

Local:
5175 tests, 75684 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Remote:
See note.

Linting:
739 files inspected, no offenses detected

@dsmcclain dsmcclain requested a review from a team May 3, 2022 21:53
Copy link
Contributor

@dsmcclain dsmcclain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One request for change that is probably unnecessary but more of a best practices sort of thing.

doc = Nokogiri::XML(xml).remove_namespaces!

parsed['duplicate'] = doc.at_xpath('//saleResponse')['duplicate'] == 'true' if kind == :sale
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One worry I have here is that if doc.at_xpath('//saleResponse') returns nil then calling ['duplicate'] on it will cause ruby to say NoMethodError: undefined method '[]' for nil:NilClass and then we are returning a sad 500 to the customer.

It looks like we make assumptions like this elsewhere in the parse method, and it could very well be that saleResponse is ALWAYS there when kind == :sale, but I would still feel better if we protected against a nil here. Something like:

parsed['duplicate'] = doc.at_xpath('//saleResponse').try(:[], 'duplicate') == 'true' if kind == :sale

@@ -727,6 +743,25 @@ def successful_purchase_response
)
end

def duplicate_purchase_response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nicely done

@mashton mashton requested a review from dsmcclain May 4, 2022 17:07
Copy link
Contributor

@dsmcclain dsmcclain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I am getting a failure on test_unsuccessful_xml_schema_validation in the litle unit tests. Looks like we still need the if kind == :sale check.

@mashton
Copy link
Author

mashton commented May 5, 2022

I sure wish there was a better way to check for xml validation errors than parse.empty?, which is what caught us up on this last one. It seems like a bug waiting to happen. But it looks like a Litle/Vantiv overhaul is overdue anyway, since their API version has just about doubled since this was put together.

@dsmcclain
Copy link
Contributor

I sure wish there was a better way to check for xml validation errors than parse.empty?, which is what caught us up on this last one. It seems like a bug waiting to happen. But it looks like a Litle/Vantiv overhaul is overdue anyway, since their API version has just about doubled since this was put together.

Agree 100%. The parse method in this gateway is unnecessarily brittle.

@dsmcclain dsmcclain self-requested a review May 5, 2022 15:15
Copy link
Contributor

@dsmcclain dsmcclain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run bundle exec rake test:local I get a linting error now.

Once that is fixed, rebase with master and squash down to one commit. Then add an entry to the changelog (at the bottom of the == HEAD section), and at that point you are good to merge.

I am approving so that you don't have to tag me for re-review on a linting fix, but don't hesitate to reach out if you have questions about the merge process 🙂 Please don't forget to fix the linting error before merging

For posterity: I am getting 13 failing remote tests on this branch, same as master

@mashton mashton force-pushed the CE-2506_vantiv_gsrf_duplicate branch 2 times, most recently from 407ded0 to abf7cfd Compare May 6, 2022 12:49
The LitleGateway parse method reads elements and their text values, but does not read any of the elements attributes. Here we read one very specific attribute (probably not worth generalizing just yet). Here we're interested in a litle saleResponse that may or may not have the attribute "duplicate='true'". All AM litle saleResposnes will include duplicate: true/false.

Note on testing: Remote test for this feature is missing. It looks like the testvantivcnp api does not return the duplicate attribute the same way the production api does. Additionally, something seems to have changed in the testvantivcnp api such that existing remote tests fail. PR coming soon with fixes for existing tests.

CE-2506

Local:
5175 tests, 75684 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Remote:
13 failed tests, same as master. See note above.

Linting:
739 files inspected, no offenses detected
@mashton mashton force-pushed the CE-2506_vantiv_gsrf_duplicate branch from abf7cfd to 35c00e4 Compare May 6, 2022 13:12
@mashton mashton merged commit 35c00e4 into activemerchant:master May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/activemerchant/active_merchant/pull/4413

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy