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

StripePI: Update Stored Credentials #5236

Merged
merged 1 commit into from
Sep 11, 2024
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 @@ -35,6 +35,7 @@
* Adyen: Enable multiple legs within airline data [jcreiff] #5249
* SafeCharge: Add card holder verification fields [yunnydang] #5252
* Iveri: Add AuthorisationReversal for Auth Void [almalee24] #5233
* Stripe PI: Update Stored Credentials [almalee24] #5236

== Version 1.137.0 (August 2, 2024)
* Unlock dependency on `rexml` to allow fixing a CVE (#5181).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def add_stored_credential_transaction_type(post, options = {})

card_options = post[:payment_method_options][:card]
card_options[:stored_credential_transaction_type] = stored_credential_type
card_options[:mit_exemption].delete(:network_transaction_id) if stored_credential_type == 'setup_on_session'
card_options[:mit_exemption].delete(:network_transaction_id) if %w(setup_on_session stored_on_session).include?(stored_credential_type)
end

def initial_transaction_stored_credential(post, stored_credential)
Expand Down
19 changes: 19 additions & 0 deletions test/remote/gateways/remote_stripe_payment_intents_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,25 @@ def test_succeeds_with_initial_cit_3ds_required
assert_equal 'requires_action', purchase.params['status']
end

def test_succeeds_with_subsequent_cit_3ds_required
assert purchase = @gateway.purchase(@amount, @visa_card, {
currency: 'USD',
execute_threed: true,
confirm: true,
stored_credential_transaction_type: true,
stored_credential: {
initiator: 'cardholder',
reason_type: 'recurring',
initial_transaction: false,
network_transaction_id: '1098510912210968'
}
})
assert_success purchase
assert_equal 'succeeded', purchase.params['status']
assert purchase.params.dig('charges', 'data')[0]['captured']
assert purchase.params.dig('charges', 'data')[0]['payment_method_details']['card']['network_transaction_id']
end

def test_succeeds_with_mit
assert purchase = @gateway.purchase(@amount, @visa_card, {
currency: 'USD',
Expand Down
8 changes: 6 additions & 2 deletions test/unit/gateways/stripe_payment_intents_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -913,11 +913,13 @@ def test_succesful_purchase_with_subsequent_cit
stored_credential: {
initial_transaction: false,
initiator: 'cardholder',
reason_type: 'installment'
reason_type: 'installment',
network_transaction_id: '1098510912210968'
}
})
end.check_request do |_method, _endpoint, data, _headers|
assert_match('payment_method_options[card][stored_credential_transaction_type]=stored_on_session', data)
assert_not_match('payment_method_options[card][mit_exemption][network_transaction_id]=1098510912210968', data)
end.respond_with(successful_create_intent_response)
end

Expand All @@ -930,11 +932,13 @@ def test_succesful_purchase_with_mit_recurring
stored_credential: {
initial_transaction: false,
initiator: 'merchant',
reason_type: 'recurring'
reason_type: 'recurring',
network_transaction_id: '1098510912210968'
}
})
end.check_request do |_method, _endpoint, data, _headers|
assert_match('payment_method_options[card][stored_credential_transaction_type]=stored_off_session_recurring', data)
assert_match('payment_method_options[card][mit_exemption][network_transaction_id]=1098510912210968', data)
end.respond_with(successful_create_intent_response)
end

Expand Down
Loading