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

Stripe PI: add request_three_d_secure to setup_intent #4365

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* DecidirPlus: Add `establishment_name`, `aggregate_data`, `sub_payments`, `card_holder_identification_type`, `card_holder_identification_number`, `card_door_number`, and `card_holder_birthday` fields [ajawadmirza] #4361
* DecidirPlus: Update `error_code_from` to get error reason id [ajawadmirza] #4364
* Dlocal: Add three_ds mpi support [cristian] #4345
* Stripe PI: Add `request_three_d_secure` field for `create_setup_intent` [aenand] #4365

== Version 1.125.0 (January 20, 2022)
* Wompi: support gateway [therufs] #4173
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def create_setup_intent(payment_method, options = {})
add_metadata(post, options)
add_return_url(post, options)
add_fulfillment_date(post, options)
request_three_d_secure(post, options)
post[:on_behalf_of] = options[:on_behalf_of] if options[:on_behalf_of]
post[:usage] = options[:usage] if %w(on_session off_session).include?(options[:usage])
post[:description] = options[:description] if options[:description]
Expand Down
34 changes: 34 additions & 0 deletions test/remote/gateways/remote_stripe_payment_intents_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,40 @@ def test_create_setup_intent_with_setup_future_usage
end
end

def test_create_setup_intent_with_request_three_d_secure
[@three_ds_credit_card, @three_ds_authentication_required_setup_for_off_session].each do |card_to_use|
assert authorize_response = @gateway.create_setup_intent(card_to_use, {
address: {
email: '[email protected]',
name: 'John Doe',
line1: '1 Test Ln',
city: 'Durham',
tracking_number: '123456789'
},
currency: 'USD',
confirm: true,
execute_threed: true,
return_url: 'https://example.com',
request_three_d_secure: 'any'
})

assert_equal 'requires_action', authorize_response.params['status']
assert_match 'https://hooks.stripe.com', authorize_response.params.dig('next_action', 'redirect_to_url', 'url')

assert_equal 'any', authorize_response.params.dig('payment_method_options', 'card', 'request_three_d_secure')

# since we cannot "click" the stripe hooks URL to confirm the authorization
# we will at least confirm we can retrieve the created setup_intent and it contains the structure we expect
setup_intent_id = authorize_response.params['id']

assert si_reponse = @gateway.retrieve_setup_intent(setup_intent_id)
assert_equal 'requires_action', si_reponse.params['status']

assert_not_empty si_reponse.params.dig('latest_attempt', 'payment_method_details', 'card')
assert_nil si_reponse.params.dig('latest_attempt', 'payment_method_details', 'card', 'network_transaction_id')
end
end

def test_retrieving_error_for_non_existant_setup_intent
assert si_reponse = @gateway.retrieve_setup_intent('seti_does_not_exist')
assert_nil si_reponse.params['status']
Expand Down