Skip to content

Commit

Permalink
Merge pull request #810 from rtrv/improve-setup-intent-status
Browse files Browse the repository at this point in the history
Create SetupIntent with another status if payment method is provided
  • Loading branch information
alexmamonchik committed Oct 24, 2023
2 parents 3ac4c02 + 9439564 commit 23b73d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/stripe_mock/request_handlers/setup_intents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ def SetupIntents.included(klass)

def new_setup_intent(route, method_url, params, headers)
id = new_id('si')
status = params[:payment_method] ? 'requires_action' : 'requires_payment_method'

setup_intents[id] = Data.mock_setup_intent(
params.merge(
id: id
id: id,
status: status
)
)

Expand Down
8 changes: 8 additions & 0 deletions spec/shared_stripe_examples/setup_intent_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
expect(setup_intent.status).to eq('requires_payment_method')
end

it 'creates a stripe setup intent with payment method' do
setup_intent = Stripe::SetupIntent.create(payment_method: 'random')

expect(setup_intent.id).to match(/^test_si/)
expect(setup_intent.metadata.to_hash).to eq({})
expect(setup_intent.status).to eq('requires_action')
end

describe "listing setup_intent" do
before do
3.times do
Expand Down

0 comments on commit 23b73d5

Please sign in to comment.