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.38k stars 110 forks source link

Create products does not retain metadata #425

Closed raldred closed 11 months ago

raldred commented 1 year ago

When creating products, the metadata passed is not retained and returned in the create response, other attributes are.

Request

curl http://localhost:12111/v1/products -i -H "Stripe-Version: 2017-08-15" -X POST -u sk_test_123: -d "name=Test Product" -d "description=Nice product" -d "metadata[product_id]=123"

Response

HTTP/1.1 200 OK
Content-Type: application/json
Request-Id: req_123
Stripe-Mock-Version: 0.164.0
Date: Mon, 05 Jun 2023 11:53:21 GMT
Content-Length: 452

{
  "active": true,
  "created": 1234567890,
  "default_price": "price_1Mxz5rArWMVfByDXuT0hhAka",
  "description": "Nice product",
  "id": "prod_Ko4C6mNeV3zf7BH",
  "images": [],
  "livemode": false,
  "metadata": {},
  "name": "Test Product",
  "object": "product",
  "package_dimensions": null,
  "shippable": null,
  "statement_descriptor": null,
  "tax_code": null,
  "unit_label": null,
  "updated": 1234567890,
  "url": null
}
richardm-stripe commented 1 year ago

~Hello @raldred. This is expected. stripe-mock is intended only for very basic sanity checks and always returns hardcoded responses. It does not mirror the input of requests on responses.~

~See the README: https://github.com/stripe/stripe-mock/blob/master/README.md~

~If you need more sophisticated behavior, we recommend you define your own mocks.~

(I am just wrong, I did not realize stripe-mock had this behavior. I am investigating.)

richardm-stripe commented 1 year ago

Hello @raldred. I don't think changing this is something we will prioritize. Needing metadata to be mirrored on the response seems like it is exiting the realm of the "basic sanity check" use case that stripe-mock serves, and resembles more of a real test case, which I think you should define your own mocks for, or else use test mode and hit the stripe servers.

Although we won't prioritize it, I'll leave this issue open. I'm not against generalizing the mirroring behavior to support map[string]string and would accept a well-tested pull request.

raldred commented 1 year ago

Hey @richardm-stripe, thanks for the prompt response. Yeh I appreciate that, as you say, if you start supporting more than just basic responses, it's growing the scope of what is intended by this tool.

I guess I hoped it would be a simple one. It's not super important, so feel free to close as wontfix.