stripe/stripe-mock

Subscription create should send back the same amount of subscription item as the number of items

gabkk opened this issue · 1 comments

gabkk commented

Background

  1. Doing testing with the library and creating multiples items in a subscription but it's impossible to test as the number of subscription items that we are getting back is not the same as the number of item sent.

  2. the price ID in the subscription item doesn't match the items send when creating a subscription

Problem

Subscription returned

      {
        application_fee_percent: null,
        automatic_tax: { enabled: false },
        billing_cycle_anchor: 1234567890,
        billing_thresholds: null,
        cancel_at: 1234567890,
        cancel_at_period_end: false,
        canceled_at: 1234567890,
        collection_method: 'charge_automatically',
        created: 1234567890,
        current_period_end: 1234567890,
        current_period_start: 1234567890,
        customer: 'cus_Iu4TLRCBVkD0ili',
        days_until_due: null,
        default_payment_method: null,
        default_source: null,
        default_tax_rates: [],
        discount: null,
        ended_at: 1234567890,
        id: 'sub_Iu4TLg0fF4Qxrbv',
        items: {
          data: [ [Object] ],
          has_more: false,
          object: 'list',
          url: '/v1/subscription_items?subscription=sub_JobD3Yl5PsotYg'
        },
        latest_invoice: null,
        livemode: false,
        metadata: {},
        next_pending_invoice_item_invoice: 1234567890,
        object: 'subscription',
        pause_collection: null,
        pending_invoice_item_interval: null,
        pending_setup_intent: null,
        pending_update: null,
        schedule: null,
        start_date: 1234567890,
        status: 'active',
        transfer_data: null,
        trial_end: 1234567890,
        trial_start: 1234567890
      }

Subscription items

      {
        data: [
          {
            billing_thresholds: null,
            created: 1625753738,
            id: 'si_JobDgytdyTvVy6',
            metadata: {},
            object: 'subscription_item',
            price: [Object],
            quantity: 1,
            subscription: 'sub_JobDz6ebtckn7S',
            tax_rates: []
          }
        ],
        has_more: false,
        object: 'list',
        url: '/v1/subscription_items?subscription=sub_JobD3Yl5PsotYg'
      }

I am actually sending 3 items.

Proposed Solution

  1. Generating the same number of subscriptions items as the number of items provided to subscription.create

  2. Include the price id inside the subscription item instead of an hardcoded one

Hi, so sorry for the delayed response here! I'll be closing this issue as out of scope, as stripe-mock is not intended to faithfully mimic the behavior of the Stripe API. We do not have plans to expand stripe-mock functionality past that of a basic response validation tool, and we recently updated [the README](https://github.com/stripe/stripe-mock#future-plans to explain this.