-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
@@ -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 |
There was a problem hiding this comment.
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????
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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
ef85c3c
to
df971a5
Compare
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:
verify
action and its dependencycreate_jwt
. These methods are using the gateway's BIN lookup service, which is not a standard approach to verifying a card.get_payment_status
andclose_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:
pos_data
object has been extracted to its own method and is now added line-by-line to the requestshipping_data
fields have their own method now.verify
method, as well as the auxiliaryget_payment_status
,close_batch
, andcreate_jwt
methods, have been simplified to conform to Active Merchant standards.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>"
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