-
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
HPS: add Apple Pay raw cryptogram support #3209
Conversation
Hi @slogsdon Just a heads up. We are looking into this at Spreedly. I'll coordinate through the review and merge process. Thanks! for submitting this feature. |
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.
Looks good overall. Marked some minor feedback separately.
As a potentially sensitive field, it's recommended to scrub out the cryptogram. It'd be good to add it to the scrub
method and verify it in the tests.
@@ -46,6 +65,17 @@ def purchase(money, card_or_token, options={}) | |||
add_details(xml, options) | |||
add_descriptor_name(xml, options) | |||
add_payment(xml, card_or_token, options) | |||
|
|||
if card_or_token.is_a?(NetworkTokenizationCreditCard) |
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.
Could this be factored out as a separate method that gets invoked from both authorize
and purchase
?
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.
Not a problem. I'll get this implemented.
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.
Done via 0beea4d1aee082c944c4c9e6e44946d3000023f5.
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.
Nice!
xml.hps :PaymentData, three_d_secure[:cavv] if three_d_secure[:cavv] | ||
# the gateway only allows a single character for the ECI | ||
xml.hps :ECommerceIndicator, strip_leading_zero(three_d_secure[:eci]) if three_d_secure[:eci] | ||
xml.hps :XID, three_d_secure[:xid] if three_d_secure[:xid] |
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.
Does it make sense to map transaction_id to XID
, if it's available on a NetworkTokenizationCreditCard
?
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.
Ah. I must have missed that on the NetworkTokenizationCreditCard
object. I'll refactor.
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.
Done via 8fe3ace525e0818e5398e3b7be7c0b8ebc6e8942.
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.
Yeah, that attribute is not immediately apparent, kinda buried in there. Refactor looks good.
assert_equal 'Success', response.message | ||
end | ||
|
||
def test_successful_auth_with_apple_pay_raw_cryptogram_with_eci |
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.
Would it be useful to also cover the capture
part of an Apple Pay authorization?
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.
I had copied the test cases from the tests for Stripe. I can add an additional test for capturing an Apple Pay transaction, but it will perform a nearly identical capture as a normal open authorization.
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.
Cool. Just wanted to check if it provides additional coverage specific to this payment method. Sounds like that's not the case, I'm fine as is.
@slogsdon Thank you for pushing the updates. They look good. I think this previous comment of mine got buried among other stuff. Could you please also address this.
|
@shasum Apologies for missing that. Done via d0bdc85f39c8264c9c93ce70e68d5ed230e6756c. |
@slogsdon Awesome. Sorry to nitpick, there's also a scrub test buried under remote tests, do you mind adding an assertion there. Thanks. |
@shasum Not a problem. I've added an additional remote test with the assertion in dc60c6d3d99666239d28ee507c472612540c701b. |
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.
@slogsdon Thank you. Everything looks good to me. I'm going to check with our internal team that works on Active Merchant, in terms of next steps to have this merged.
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.
Have a question about whether we should add some tests for the 3DS options hash, but otherwise looks good to me.
eci: card_or_token.eci, | ||
xid: card_or_token.transaction_id, | ||
}) | ||
elsif options[:three_d_secure] |
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.
Should we test the :three_d_secure
options hash path as well? I didn't see any new or existing tests exercising this logic.
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 catch. That'd be a good thing to add. @slogsdon Thoughts?
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.
Will do.
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.
Done as of 76859d924f9d05cea7aa0115bc219c2a8a0ddacc.
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.
Looks great! Thank you @slogsdon
@bayprogrammer Are we good to go on this?
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.
I noticed one more improvement we could make to strengthen the assertions in the new tests (left suggested changes in comment), but otherwise I think this is good to go.
end.check_request do |method, endpoint, data, headers| | ||
assert_match(/<hps:SecureECommerce>(.*)<\/hps:SecureECommerce>/, data) | ||
assert_match(/<hps:PaymentDataSource>Visa 3DSecure<\/hps:PaymentDataSource>/, data) | ||
end.respond_with(successful_charge_response) |
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.
I would expand the assertions for the new 3DS tests to add something like the following (which verifies the ECI leading-zero-stripping is happening as expected and that the other values from the 3DS options are correctly input into the resultant XML request document):
assert_match(/<hps:PaymentData>#{options[:three_d_secure][:cavv]}<\/hps:PaymentData>/, data)
assert_match(/<hps:ECommerceIndicator>5<\/hps:ECommerceIndicator>/, data)
assert_match(/<hps:XID>#{options[:three_d_secure][:xid]}<\/hps:XID>/, data)
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.
Sounds a good improvement to add coverage around ECI zero stripping and 3DS. @slogsdon Could we have that updated pls. Looks like we are almost there.
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.
Done via cc218668e61a6c53ab0f415de156455e20411e74.
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.
cc21866
to
d14c276
Compare
Unit: 34 tests, 171 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 40 tests, 102 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes activemerchant#3209
d14c276
to
c387d6f
Compare
Unit: 34 tests, 171 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 40 tests, 102 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Closes activemerchant#3209
No description provided.