Content-Length: 308431 | pFad | https://github.com/activemerchant/active_merchant/pull/4383

57 Priority: Refactor gateway integration, add additional fields to request by dsmcclain · Pull Request #4383 · 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

Priority: Refactor gateway integration, add additional fields to request #4383

Merged
merged 1 commit into from
Apr 11, 2022

Conversation

dsmcclain
Copy link
Contributor

@dsmcclain dsmcclain commented Apr 6, 2022

CE-2491

This PR makes significant adjustments to the Priority gateway integration.

I will describe some of the changes below, but I also want to note two areas that warrant additional investigation:

  1. theverify action and its dependency create_jwt. These methods are using the gateway's BIN lookup service, which is not a standard approach to verifying a card.
  2. the get_payment_status and close_batch actions. It's not clear why these actions were implemented, as they are currently being used exclusively to manipulate transactions within the test cases. A merchant going through Spreedly would have no way to take advantage of these actions.

I will open some new tickets to investigate these two areas.

The changes made in this PR include:

  • The pos_data object has been extracted to its own method and is now added line-by-line to the request
  • The various shipping_data fields have their own method now.
  • The verify method, as well as the auxiliary get_payment_status, close_batch, and create_jwt methods, have been simplified to conform to Active Merchant standards.
  • The authorization_from method has been updated to conform to Active Merchant standards. Instead of returning a ruby hash it now returns a string of format "<request_id>|<payment_token>"
  • Handling of gateway responses has been refactored
  • Substantial changes were made to the test files. Instead of including every option in every test case, we are now including the minimum options required to test the behavior in question.
  • There were multiple remote tests which rescued a runtime error, meaning that the transaction being tested would cause an uncaught error in production. The behavior under test has been corrected and tests that rescue errors have been reworked or removed.
  • Test coverage has been added for fields whose presence were not previously tested.

In addition to the above changes, the following fields were removed from requests to the gateway, because they are either not mentioned in the gateway documentation, not necessary for the request, or else described as gateway response fields (meaning that they do not belong in the request):

  • authCode
  • cardAccount.code
  • cardAccount.taxRate
  • cardAccount.entryMode
  • cardAccount.cardId
  • cardAccount.hasContract
  • cardAccount.isCorp
  • cardAccount.isDebit
  • cardAccount.token
  • cardPresent
  • cardPresentType
  • isTicket
  • mxAdvantageEnabled
  • sourceZip
  • purchases.dateCreated
  • purchases.iId
  • purchases.transactionIId
  • purchases.transactionId

The following fields were removed from the gateway adapter because they were actually dead code, meaning they were never even added to requests in the first place (from the add_risk_data method):

  • cvvResponseCode
  • cvvResponse
  • cvvMatch
  • avsResponse
  • avsAddressMatch
  • avsZipMatch

The following fields were removed from requests to the gateway because they were not correctly implemented according to the gateway's documentation and they represent features that are currently not supported by Spreedly's integration with the gateway:

  • shouldVaultCard

Rubocop:
739 files inspected, no offenses detected

Unit:
5147 tests, 75501 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Remote:
Loaded suite test/remote/gateways/remote_priority_test
27 tests, 81 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

@dsmcclain dsmcclain requested a review from a team April 6, 2022 23:23
@@ -207,11 +270,12 @@ def commit(action, params: '', iid: '', card_number: nil, jwt: '')
parse(ssl_post(url(action, params), post_data(params), request_headers))
end
rescue ResponseError => e
parse(e.response.body)
# currently Priority returns a 404 with a message but an empty body on certain calls
Copy link
Contributor

Choose a reason for hiding this comment

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

:confused_parrot: where does the message come from if the body is empty????

Copy link
Contributor Author

@dsmcclain dsmcclain Apr 11, 2022

Choose a reason for hiding this comment

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

Good question.

Apparently the response.message attribute in ruby's net/http library is simply the reason phrase pulled out of the status line of the HTTP response.

So in this case the response has no body but the status line is HTTP/1.1 404 Not Found so response.message ends up being 'Not Found'.

Perhaps my comment would be more accurate if it read currently Priority returns a 404 with no body on certain calls. In those cases we will substitute the response status from response.message.

I will change it.

response = @gateway.authorize(@amount_purchase, @credit_card, @option_spr)
assert_success response
assert_equal 'Approved', response.params['status']
def test_successful_capture
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a minor nitpick, but I think it's conventional to name tests that call multiple methods after both methods, e.g. test_successful_authorize_and_capture

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for this minor but helpful nitpick 😄 . I will change it.

Copy link
Contributor

@therufs therufs left a comment

Choose a reason for hiding this comment

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

Good & thorough work; tests pass! 🎉

I had a suggestion (that might be multiple suggestions) for some cosmetic changes to test names. Otherwise, 🚢

CE-2491

Rubocop:
739 files inspected, no offenses dtected

Unit:
5159 tests, 75564 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Remote:
Loaded suite test/remote/gateways/remote_priority_test
27 tests, 81 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passede
@dsmcclain dsmcclain force-pushed the CE-2491_priority_gsfs branch from ef85c3c to df971a5 Compare April 11, 2022 16:41
@dsmcclain dsmcclain merged commit df971a5 into master Apr 11, 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/4383

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy