stripe / stripe-mock

stripe-mock is a mock HTTP server that responds like the real Stripe API. It can be used instead of Stripe's testmode to make test suites integrating with Stripe faster and less brittle.
MIT License
1.36k stars 107 forks source link

additional properties are not allowed: automatic_payment_methods #926

Closed Sudakatux closed 1 month ago

Sudakatux commented 1 month ago

Im running stipe-mock with latests: apiVersion: '2024-06-20'

Im making a direct post with the following form data:

amount=12000&currency=usd&automatic_payment_methods%5Benabled%5D=true&payment_method=pm_N3nSweYlJXcFLkB&off_session=true&confirm=true&customer=cus_N3nSwrsmxhPglKR

but the container is failing with "validator 0xc000b3f0e0 failed: additional properties are not allowed: automatic_payment_methods" is automatic_payment_methods[enabled]=true not supported by stripe-mock ?

xavdid-stripe commented 1 month ago

What endpoint are you sending this request to?

macbookandrew commented 1 month ago

I’m seeing this too, when creating a payment intent with this data:

$stripe = new \Stripe\StripeClient('sk_test_Tm42SIKZinsVvyBCHb01UHcI');

$stripe->paymentIntents->create([
  'amount' => 2000,
  'currency' => 'usd',
  'automatic_payment_methods' => [
    'enabled' => true,
    'allow_redirects' => 'never', // or 'always' <------------- this is the problem line
  ],
]);

Docs: https://docs.stripe.com/api/payment_intents/create?lang=php#create_payment_intent-automatic_payment_methods-allow_redirects

macbookandrew commented 1 month ago

Sounds like maybe it just needs to be rebuilt against a newer OpenAPI spec?

macbookandrew commented 1 month ago

Some more information:

Steps to reproduce:

  1. Install and run stripe-mock using Docker
  2. Create a payment intent using automatic_payment_methods.allow_redirects: true
docker run -it -p 12111:12111 stripemock/stripe-mock:latest
Unable to find image 'stripemock/stripe-mock:latest' locally
latest: Pulling from stripemock/stripe-mock
5843afab3874: Pull complete
08aba54b252b: Pull complete
91920f087607: Pull complete
Digest: sha256:a77358595cb30f2c7d48b42e8971f46456486e2cc04f6dc2465ca9057b48dd12
Status: Downloaded newer image for stripemock/stripe-mock:latest
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
stripe-mock 0.110.0
Routing to 234 path(s) and 384 endpoint(s) with 384 validator(s)
Listening for HTTP at address: [::]:12111
Listening for HTTPS at address: [::]:12112
Request: POST /v1/customers
Request data = map[email:schowalter.seamus@example.org name:Jess Nikolaus]
Response: elapsed=9.888ms status=200
Request: POST /v1/payment_intents
Request data = map[amount:1000 automatic_payment_methods:map[allow_redirects:never enabled:true] currency:usd setup_future_usage:off_session statement_descriptor:A really long string t]
Request validation error: validator 0xc000836480 failed: additional properties are not allowed: automatic_payment_methods
Response: elapsed=2.275ms status=400
macbookandrew commented 1 month ago

@xavdid-stripe any ideas on this? Why would cloning the repo and using homebrew work fine, while the docker image apparently has old validation rules?

macbookandrew commented 1 month ago

I wonder if this is due to #432… the main dockerfile includes a build step, while the goreleaser dockerfile doesn’t… @richardm-stripe since you added #432, do you have any ideas on that?

xavdid-stripe commented 1 month ago

I've been looking into this today and I think it all comes back to our OpenAPI updater pipeline getting stuck. This PR should be green and atuo-merged. Instead it's had failing tests and been open for 2 weeks: https://github.com/stripe/stripe-mock/pull/941

I'm not sure why the two installation methods include different versions of the OpenAPI spec, but that would explain the inconsistencies.

I know why the tests are failing on that PR so I'm trying to figure out the right things to tweak to clear up the fixture generation. Will hopefully have that ready soon!

xavdid-stripe commented 1 month ago

I've fixed the upstream fixtures issue internally and the fix should make its way through Stripe CI into the public OpenAPI repo. https://github.com/stripe/stripe-mock/pull/941 should get auto-merged and everything should iron out. Definitely let us know if that's not the case though and sorry for the hassle!

macbookandrew commented 1 month ago

Thanks…does somebody need to tag a new release though? I still see 0.186.0 from May 16 as the latest on Docker Hub and GitHub

xavdid-stripe commented 1 month ago

Looks like that's all set now! Docker and GH releases have been updated.

I'll go ahead and close out, but let us know if there are still OpenAPI staleness issues!