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

HPS: add Apple Pay raw cryptogram support #3209

Merged
merged 1 commit into from
Jul 9, 2019

Conversation

slogsdon
Copy link
Contributor

@slogsdon slogsdon commented May 7, 2019

No description provided.

@shasum
Copy link
Contributor

shasum commented Jun 19, 2019

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.

@shasum shasum self-requested a review June 19, 2019 15:08
Copy link
Contributor

@shasum shasum left a 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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done via 0beea4d1aee082c944c4c9e6e44946d3000023f5.

Copy link
Contributor

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]
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done via 8fe3ace525e0818e5398e3b7be7c0b8ebc6e8942.

Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@shasum shasum added the gateway/feature Adds a new feature to an existing gateway label Jun 20, 2019
@jknipp jknipp requested a review from a team June 21, 2019 16:05
@shasum
Copy link
Contributor

shasum commented Jun 21, 2019

@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.

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.

@slogsdon
Copy link
Contributor Author

@shasum Apologies for missing that. Done via d0bdc85f39c8264c9c93ce70e68d5ed230e6756c.

@shasum
Copy link
Contributor

shasum commented Jun 21, 2019

@slogsdon Awesome. Sorry to nitpick, there's also a scrub test buried under remote tests, do you mind adding an assertion there. Thanks.

@slogsdon
Copy link
Contributor Author

@shasum Not a problem. I've added an additional remote test with the assertion in dc60c6d3d99666239d28ee507c472612540c701b.

Copy link
Contributor

@shasum shasum left a 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.

Copy link
Contributor

@bayprogrammer bayprogrammer left a 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]
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done as of 76859d924f9d05cea7aa0115bc219c2a8a0ddacc.

Copy link
Contributor

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?

Copy link
Contributor

@bayprogrammer bayprogrammer left a 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)
Copy link
Contributor

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)

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done via cc218668e61a6c53ab0f415de156455e20411e74.

Copy link
Contributor

@bayprogrammer bayprogrammer left a comment

Choose a reason for hiding this comment

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

🎉 @slogsdon @shasum Thanks so much for the revisions. Looks great!

@shasum shasum force-pushed the hps-add-apple-pay-raw branch from cc21866 to d14c276 Compare July 9, 2019 19:42
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
@shasum shasum force-pushed the hps-add-apple-pay-raw branch from d14c276 to c387d6f Compare July 9, 2019 19:56
@shasum shasum merged commit c387d6f into activemerchant:master Jul 9, 2019
whitby3001 pushed a commit to whitby3001/active_merchant that referenced this pull request Sep 3, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gateway/feature Adds a new feature to an existing gateway
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants