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

fix: correct return of subscription items #814

Conversation

augustoccesar
Copy link
Contributor

@augustoccesar augustoccesar commented Jan 25, 2022

Original PR: #811 . Accidentally closed

Description

Currently, the whole hash is passed to mock_list_object instead of only the values. This generates an incorrect response.

Example

With:

Stripe::SubscriptionItem.create(plan: plan.id, subscription: subscription.id, quantity: 2)
Stripe::SubscriptionItem.create(plan: plan2.id, subscription: subscription.id, quantity: 20)

Then:

Stripe::SubscriptionItem.list(subscription: subscription.id)

Returns:

=> #<Stripe::ListObject:0x1e00> JSON: {
  "object": "list",
  "data": [
    [
      "test_si_7",
      {"id":"test_si_7","object":"subscription_item","created":1504716183,"metadata":{},"plan":{"id":"silver_plan","object":"plan","active":true,"aggregate_usage":null,"amount":1337,"billing_scheme":"per_unit","created":1466698898,"currency":"usd","interval":"month","interval_count":1,"livemode":false,"metadata":{},"nickname":"My Mock Plan","product":"stripe_mock_default_product_id","tiers":null,"tiers_mode":null,"transform_usage":null,"trial_period_days":null,"usage_type":"licensed"},"quantity":2,"subscription":"test_su_4"}
    ],
    [
      "test_si_8",
      {"id":"test_si_8","object":"subscription_item","created":1504716183,"metadata":{},"plan":{"id":"one_more_1_plan","object":"plan","active":true,"aggregate_usage":null,"amount":100,"billing_scheme":"per_unit","created":1466698898,"currency":"usd","interval":"month","interval_count":1,"livemode":false,"metadata":{},"nickname":"My Mock Plan","product":"stripe_mock_default_product_id","tiers":null,"tiers_mode":null,"transform_usage":null,"trial_period_days":null,"usage_type":"licensed"},"quantity":20,"subscription":"test_su_4"}
    ]
  ],
  "url": "/v1/arrays",
  "has_more": false
}

But should return:

=> #<Stripe::ListObject:0x1e00> JSON: {
  "object": "list",
  "data": [
    {"id":"test_si_8","object":"subscription_item","created":1504716183,"metadata":{},"plan":{"id":"one_more_1_plan","object":"plan","active":true,"aggregate_usage":null,"amount":100,"billing_scheme":"per_unit","created":1466698898,"currency":"usd","interval":"month","interval_count":1,"livemode":false,"metadata":{},"nickname":"My Mock Plan","product":"stripe_mock_default_product_id","tiers":null,"tiers_mode":null,"transform_usage":null,"trial_period_days":null,"usage_type":"licensed"},"quantity":20,"subscription":"test_su_4"},
    {"id":"test_si_7","object":"subscription_item","created":1504716183,"metadata":{},"plan":{"id":"silver_plan","object":"plan","active":true,"aggregate_usage":null,"amount":1337,"billing_scheme":"per_unit","created":1466698898,"currency":"usd","interval":"month","interval_count":1,"livemode":false,"metadata":{},"nickname":"My Mock Plan","product":"stripe_mock_default_product_id","tiers":null,"tiers_mode":null,"transform_usage":null,"trial_period_days":null,"usage_type":"licensed"},"quantity":2,"subscription":"test_su_4"}
  ],
  "url": "/v1/hashs",
  "has_more": false
}

Documentation reference

https://stripe.com/docs/api/subscription_items/list?lang=ruby

Currently, the whole hash is passed to mock_list_object instead of only the values. This generates a incorrect response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant