Skip to content

Instantly share code, notes, and snippets.

@ptgamr
Last active July 13, 2017 05:25
Show Gist options
  • Save ptgamr/d6dc007be2fb82c556e11250a28b1b63 to your computer and use it in GitHub Desktop.
Save ptgamr/d6dc007be2fb82c556e11250a28b1b63 to your computer and use it in GitHub Desktop.
Stripe Bug

I have successfully applied the following coupon on the subscription: sub_B11QoX8cG4AjeW

ID: scoutingtagging-chf-month
Amount off: CHF 90.00 CHF off
Duration: once
Valid: true

Now I want to switch all the subscribed plans to yearly plan, with prorate = true.

The upcoming invoice doesn't seem to return the correct proration items:

stripe.invoices.retrieveUpcoming(
    'cus_B11QxiyQHkGzmI',
    'sub_B11QoX8cG4AjeW',
    { 
      subscription: 'sub_B11QoX8cG4AjeW',
      subscription_items: [
        { id: 'si_1AezNfBHxc8EdGrxyahMO3p5', plan: 'starter-chf-year-1' },
        { id: 'si_1AezNfBHxc8EdGrxUeIGuYgP', plan: 'advancedsearch-chf-year-1' },
        { id: 'si_1AezNfBHxc8EdGrx03cnFrdO', plan: 'scouting-chf-year-1' },
        { id: 'si_1AezNfBHxc8EdGrxF9S1QkM8', plan: 'tagging-chf-year-1' } 
      ],
      subscription_prorate: true
    }
)

The strange thing is the proration items seems to have the discount applied to every single item: (which it shouldn't, because this is one time coupon, and it apply to subscription as a whole)

"Unused time on Tagging (with CHF 90.00 off) after 13 Jul 2017",
"Unused time on Scouting (with CHF 90.00 off) after 13 Jul 2017",
"Unused time on Advanced Search (with CHF 90.00 off) after 13 Jul 2017"
"Unused time on Starter (with CHF 90.00 off) after 13 Jul 2017"

Results JSON for references:

{
    "object": "invoice",
    "amount_due": 604406,
    "application_fee": null,
    "attempt_count": 0,
    "attempted": false,
    "charge": null,
    "closed": false,
    "currency": "chf",
    "customer": "cus_B11QxiyQHkGzmI",
    "date": 1499922274,
    "description": null,
    "discount": null,
    "ending_balance": null,
    "forgiven": false,
    "lines": {
      "object": "list",
      "data": [
        {
          "id": "ii_1AezV8BHxc8EdGrxKRa08nm7",
          "object": "line_item",
          "amount": -4699,
          "currency": "chf",
          "description": "Unused time on Tagging (with CHF 90.00 off) after 13 Jul 2017",
          "discountable": false,
          "livemode": false,
          "metadata": {
            
          },
          "period": {
            "start": 1499922274,
            "end": 1502600211
          },
          "plan": {
            "id": "tagging-chf-month-1",
            "object": "plan",
            "amount": 13700,
            "created": 1499767901,
            "currency": "chf",
            "interval": "month",
            "interval_count": 1,
            "livemode": false,
            "metadata": {
              "tagging": "true",
              "videoMinutesPercentage": "0.5",
              "sort": "40",
              "type": "package",
              "texts": "[]"
            },
            "name": "Tagging",
            "statement_descriptor": null,
            "trial_period_days": null
          },
          "proration": true,
          "quantity": 1,
          "subscription": "sub_B11QoX8cG4AjeW",
          "subscription_item": "si_1AezNfBHxc8EdGrxF9S1QkM8",
          "type": "invoiceitem"
        },
        {
          "id": "ii_1AezV8BHxc8EdGrxV0y5WiIS",
          "object": "line_item",
          "amount": -4699,
          "currency": "chf",
          "description": "Unused time on Scouting (with CHF 90.00 off) after 13 Jul 2017",
          "discountable": false,
          "livemode": false,
          "metadata": {
            
          },
          "period": {
            "start": 1499922274,
            "end": 1502600211
          },
          "plan": {
            "id": "scouting-chf-month-1",
            "object": "plan",
            "amount": 13700,
            "created": 1499767901,
            "currency": "chf",
            "interval": "month",
            "interval_count": 1,
            "livemode": false,
            "metadata": {
              "scouting": "true",
              "sort": "30",
              "type": "package",
              "texts": "[]"
            },
            "name": "Scouting",
            "statement_descriptor": null,
            "trial_period_days": null
          },
          "proration": true,
          "quantity": 1,
          "subscription": "sub_B11QoX8cG4AjeW",
          "subscription_item": "si_1AezNfBHxc8EdGrx03cnFrdO",
          "type": "invoiceitem"
        },
        {
          "id": "ii_1AezV8BHxc8EdGrxwaLYOBEJ",
          "object": "line_item",
          "amount": 0,
          "currency": "chf",
          "description": "Unused time on Advanced Search (with CHF 90.00 off) after 13 Jul 2017",
          "discountable": false,
          "livemode": false,
          "metadata": {
            
          },
          "period": {
            "start": 1499922274,
            "end": 1502600211
          },
          "plan": {
            "id": "advancedsearch-chf-month-1",
            "object": "plan",
            "amount": 1100,
            "created": 1499767901,
            "currency": "chf",
            "interval": "month",
            "interval_count": 1,
            "livemode": false,
            "metadata": {
              "advancedSearch": "true",
              "sort": "10",
              "type": "package",
              "texts": "[]"
            },
            "name": "Advanced Search",
            "statement_descriptor": null,
            "trial_period_days": null
          },
          "proration": true,
          "quantity": 1,
          "subscription": "sub_B11QoX8cG4AjeW",
          "subscription_item": "si_1AezNfBHxc8EdGrxUeIGuYgP",
          "type": "invoiceitem"
        },
        {
          "id": "ii_1AezV8BHxc8EdGrxVH0DDpNc",
          "object": "line_item",
          "amount": -20896,
          "currency": "chf",
          "description": "Unused time on Starter (with CHF 90.00 off) after 13 Jul 2017",
          "discountable": false,
          "livemode": false,
          "metadata": {
            
          },
          "period": {
            "start": 1499922274,
            "end": 1502600211
          },
          "plan": {
            "id": "starter-chf-month-1",
            "object": "plan",
            "amount": 29900,
            "created": 1499767900,
            "currency": "chf",
            "interval": "month",
            "interval_count": 1,
            "livemode": false,
            "metadata": {
              "videoMinutes": "120",
              "videoDownloads": "false",
              "playerRequest": "true",
              "playerTrading": "true",
              "sort": "20",
              "texts": "[\"Platform\",\"Quick Search\",\"Communication external\",\"Communication internal\",\"Mobile Communication Apps for staff and players\",\"Player Requests\",\"Player Trading\"]"
            },
            "name": "Starter",
            "statement_descriptor": null,
            "trial_period_days": null
          },
          "proration": true,
          "quantity": 1,
          "subscription": "sub_B11QoX8cG4AjeW",
          "subscription_item": "si_1AezNfBHxc8EdGrxyahMO3p5",
          "type": "invoiceitem"
        },
        {
          "id": "sub_B11QoX8cG4AjeW",
          "object": "line_item",
          "amount": 322900,
          "currency": "chf",
          "description": null,
          "discountable": true,
          "livemode": false,
          "metadata": {
            "lastUpdatedBy": "000000000000000000000004",
            "organizationId": "55c8d10fa7a84b636d94adc7",
            "organizationType": "team"
          },
          "period": {
            "start": 1499922274,
            "end": 1531458274
          },
          "plan": {
            "id": "starter-chf-year-1",
            "object": "plan",
            "amount": 322900,
            "created": 1499767898,
            "currency": "chf",
            "interval": "year",
            "interval_count": 1,
            "livemode": false,
            "metadata": {
              "videoMinutes": "1440",
              "videoDownloads": "false",
              "playerRequest": "true",
              "playerTrading": "true",
              "sort": "20",
              "texts": "[\"Platform\",\"Quick Search\",\"Communication external\",\"Communication internal\",\"Mobile Communication Apps for staff and players\",\"Player Requests\",\"Player Trading\"]"
            },
            "name": "Starter",
            "statement_descriptor": null,
            "trial_period_days": null
          },
          "proration": false,
          "quantity": 1,
          "subscription": null,
          "subscription_item": "si_1AezNfBHxc8EdGrxyahMO3p5",
          "type": "subscription"
        },
        {
          "id": "sub_B11QoX8cG4AjeW",
          "object": "line_item",
          "amount": 12000,
          "currency": "chf",
          "description": null,
          "discountable": true,
          "livemode": false,
          "metadata": {
            "lastUpdatedBy": "000000000000000000000004",
            "organizationId": "55c8d10fa7a84b636d94adc7",
            "organizationType": "team"
          },
          "period": {
            "start": 1499922274,
            "end": 1531458274
          },
          "plan": {
            "id": "advancedsearch-chf-year-1",
            "object": "plan",
            "amount": 12000,
            "created": 1499767901,
            "currency": "chf",
            "interval": "year",
            "interval_count": 1,
            "livemode": false,
            "metadata": {
              "advancedSearch": "true",
              "sort": "10",
              "type": "package",
              "texts": "[]"
            },
            "name": "Advanced Search",
            "statement_descriptor": null,
            "trial_period_days": null
          },
          "proration": false,
          "quantity": 1,
          "subscription": null,
          "subscription_item": "si_1AezNfBHxc8EdGrxUeIGuYgP",
          "type": "subscription"
        },
        {
          "id": "sub_B11QoX8cG4AjeW",
          "object": "line_item",
          "amount": 149900,
          "currency": "chf",
          "description": null,
          "discountable": true,
          "livemode": false,
          "metadata": {
            "lastUpdatedBy": "000000000000000000000004",
            "organizationId": "55c8d10fa7a84b636d94adc7",
            "organizationType": "team"
          },
          "period": {
            "start": 1499922274,
            "end": 1531458274
          },
          "plan": {
            "id": "scouting-chf-year-1",
            "object": "plan",
            "amount": 149900,
            "created": 1499767901,
            "currency": "chf",
            "interval": "year",
            "interval_count": 1,
            "livemode": false,
            "metadata": {
              "scouting": "true",
              "sort": "30",
              "type": "package",
              "texts": "[]"
            },
            "name": "Scouting",
            "statement_descriptor": null,
            "trial_period_days": null
          },
          "proration": false,
          "quantity": 1,
          "subscription": null,
          "subscription_item": "si_1AezNfBHxc8EdGrx03cnFrdO",
          "type": "subscription"
        },
        {
          "id": "sub_B11QoX8cG4AjeW",
          "object": "line_item",
          "amount": 149900,
          "currency": "chf",
          "description": null,
          "discountable": true,
          "livemode": false,
          "metadata": {
            "lastUpdatedBy": "000000000000000000000004",
            "organizationId": "55c8d10fa7a84b636d94adc7",
            "organizationType": "team"
          },
          "period": {
            "start": 1499922274,
            "end": 1531458274
          },
          "plan": {
            "id": "tagging-chf-year-1",
            "object": "plan",
            "amount": 149900,
            "created": 1499767901,
            "currency": "chf",
            "interval": "year",
            "interval_count": 1,
            "livemode": false,
            "metadata": {
              "tagging": "true",
              "videoMinutesPercentage": "0.5",
              "sort": "40",
              "type": "package",
              "texts": "[]"
            },
            "name": "Tagging",
            "statement_descriptor": null,
            "trial_period_days": null
          },
          "proration": false,
          "quantity": 1,
          "subscription": null,
          "subscription_item": "si_1AezNfBHxc8EdGrxF9S1QkM8",
          "type": "subscription"
        }
      ],
      "has_more": false,
      "total_count": 8,
      "url": "\/v1\/invoices\/upcoming\/lines?customer=cus_B11QxiyQHkGzmI&subscription=sub_B11QoX8cG4AjeW&subscription_prorate=true"
    },
    "livemode": false,
    "metadata": {
      
    },
    "next_payment_attempt": 1499925874,
    "paid": false,
    "period_end": 1499922274,
    "period_start": 1499922274,
    "receipt_number": null,
    "starting_balance": 0,
    "statement_descriptor": null,
    "subscription": "sub_B11QoX8cG4AjeW",
    "subscription_proration_date": 1499922274,
    "subtotal": 604406,
    "tax": null,
    "tax_percent": null,
    "total": 604406,
    "webhooks_delivered_at": null
  }

Remove old items, adding new plan still not working correctly:

stripe.invoices.retrieveUpcoming(
    'cus_B0lIGLlrrfdVyE',
    'sub_B0lJCvwPWOYcLm',
    { 
      subscription: 'sub_B0lJCvwPWOYcLm',
      subscription_items:[
        { id: 'si_1AejmSBHxc8EdGrxbEAdYWlA', deleted: true },
        { id: 'si_1Aekb4BHxc8EdGrx9BwOKTe9', deleted: true },
        { id: 'si_1Aekb4BHxc8EdGrx96uejsne', deleted: true }
        { plan: 'pro-chf-year-1' },
        { plan: 'scouting-chf-year-1' },
        { plan: 'tagging-chf-year-1' }
      ],
      subscription_prorate: true
    }
)

Return wrong results:

{"object":"invoice","amount_due":807761,"application_fee":null,"attempt_count":0,"attempted":false,"charge":null,"closed":false,"currency":"chf","customer":"cus_B0lIGLlrrfdVyE","date":1499869005,"description":null,"discount":null,"ending_balance":null,"forgiven":false,"lines":{"object":"list","data":[{"id":"ii_1AeldxBHxc8EdGrxzF0kQZS9","object":"line_item","amount":-13663,"currency":"chf","description":"Unused time on Tagging after 12 Jul 2017","discountable":false,"livemode":false,"metadata":{},"period":{"start":1499869005,"end":1502540244},"plan":{"id":"tagging-chf-month-1","object":"plan","amount":13700,"created":1499767901,"currency":"chf","interval":"month","interval_count":1,"livemode":false,"metadata":{"tagging":"true","videoMinutesPercentage":"0.5","sort":"40","type":"package","texts":"[]"},"name":"Tagging","statement_descriptor":null,"trial_period_days":null},"proration":true,"quantity":1,"subscription":"sub_B0lJCvwPWOYcLm","subscription_item":"si_1Aekb4BHxc8EdGrx96uejsne","type":"invoiceitem"},{"id":"ii_1AeldxBHxc8EdGrxdYeaADXO","object":"line_item","amount":-13663,"currency":"chf","description":"Unused time on Scouting after 12 Jul 2017","discountable":false,"livemode":false,"metadata":{},"period":{"start":1499869005,"end":1502540244},"plan":{"id":"scouting-chf-month-1","object":"plan","amount":13700,"created":1499767901,"currency":"chf","interval":"month","interval_count":1,"livemode":false,"metadata":{"scouting":"true","sort":"30","type":"package","texts":"[]"},"name":"Scouting","statement_descriptor":null,"trial_period_days":null},"proration":true,"quantity":1,"subscription":"sub_B0lJCvwPWOYcLm","subscription_item":"si_1Aekb4BHxc8EdGrx9BwOKTe9","type":"invoiceitem"},{"id":"ii_1AeldxBHxc8EdGrxZ9MtBMIV","object":"line_item","amount":-69713,"currency":"chf","description":"Unused time on Pro after 12 Jul 2017","discountable":false,"livemode":false,"metadata":{},"period":{"start":1499869005,"end":1502540244},"plan":{"id":"pro-chf-month-1","object":"plan","amount":69900,"created":1499767899,"currency":"chf","interval":"month","interval_count":1,"livemode":false,"metadata":{"videoMinutes":"960","videoDownloads":"true","playerRequest":"true","playerTrading":"true","advancedSearch":"true","sort":"40","inclusivePackages":"advancedsearch-chf-month-1","texts":"[\"Platform\",\"Quick Search\",\"Advanced Search\",\"Communication external\",\"Communication internal\",\"Mobile Communication Apps for staff and players\",\"Player Requests\",\"Player Trading\"]"},"name":"Pro","statement_descriptor":null,"trial_period_days":null},"proration":true,"quantity":1,"subscription":"sub_B0lJCvwPWOYcLm","subscription_item":"si_1AejmSBHxc8EdGrxbEAdYWlA","type":"invoiceitem"},{"id":"sub_B0lJCvwPWOYcLm","object":"line_item","amount":754900,"currency":"chf","description":null,"discountable":true,"livemode":false,"metadata":{"lastUpdatedBy":"000000000000000000000004","organizationId":"55c8d10fa7a84b636d94adc7","organizationType":"team"},"period":{"start":1499869005,"end":1531405005},"plan":{"id":"pro-chf-year-1","object":"plan","amount":754900,"created":1499767898,"currency":"chf","interval":"year","interval_count":1,"livemode":false,"metadata":{"videoMinutes":"11520","videoDownloads":"true","playerRequest":"true","playerTrading":"true","advancedSearch":"true","sort":"40","inclusivePackages":"advancedsearch-chf-year-1","texts":"[\"Platform\",\"Quick Search\",\"Advanced Search\",\"Communication external\",\"Communication internal\",\"Mobile Communication Apps for staff and players\",\"Player Requests\",\"Player Trading\"]"},"name":"Pro","statement_descriptor":null,"trial_period_days":null},"proration":false,"quantity":1,"subscription":null,"subscription_item":"si_1AeldxBHxc8EdGrxchoPWYT4","type":"subscription"},{"id":"sub_B0lJCvwPWOYcLm","object":"line_item","amount":149900,"currency":"chf","description":null,"discountable":true,"livemode":false,"metadata":{"lastUpdatedBy":"000000000000000000000004","organizationId":"55c8d10fa7a84b636d94adc7","organizationType":"team"},"period":{"start":1499869005,"end":1531405005},"plan":{"id":"scouting-chf-year-1","object":"plan","amount":149900,"created":1499767901,"currency":"chf","interval":"year","interval_count":1,"livemode":false,"metadata":{"scouting":"true","sort":"30","type":"package","texts":"[]"},"name":"Scouting","statement_descriptor":null,"trial_period_days":null},"proration":false,"quantity":1,"subscription":null,"subscription_item":"si_1AeldxBHxc8EdGrxzvTz5cmx","type":"subscription"}],"has_more":false,"total_count":5,"url":"/v1/invoices/upcoming/lines?customer=cus_B0lIGLlrrfdVyE&subscription=sub_B0lJCvwPWOYcLm&subscription_prorate=true"},"livemode":false,"metadata":{},"next_payment_attempt":1499872605,"paid":false,"period_end":1499869005,"period_start":1499869005,"receipt_number":null,"starting_balance":0,"statement_descriptor":null,"subscription":"sub_B0lJCvwPWOYcLm","subscription_proration_date":1499869005,"subtotal":807761,"tax":null,"tax_percent":null,"total":807761,"webhooks_delivered_at":null}

Why it is wrong: result.lines.data contains only 5 items, while it should be 6 - one is still missing :(

However, changing subscription items to new plan works, the result is as expected (switch from monthly to yearly)

stripe.invoices.retrieveUpcoming(
    'cus_B0lIGLlrrfdVyE',
    'sub_B0lJCvwPWOYcLm',
    { 
      subscription: 'sub_B0lJCvwPWOYcLm',
      subscription_items:[
        { id: 'si_1AejmSBHxc8EdGrxbEAdYWlA', plan: 'pro-chf-year-1' },
        { id: 'si_1Aekb4BHxc8EdGrx9BwOKTe9', plan: 'scouting-chf-year-1' },
        { id: 'si_1Aekb4BHxc8EdGrx96uejsne', plan: 'tagging-chf-year-1' }
      ],
      subscription_prorate: true
    }
)

Results: (correct)

{"object":"invoice","amount_due":957648,"application_fee":null,"attempt_count":0,"attempted":false,"charge":null,"closed":false,"currency":"chf","customer":"cus_B0lIGLlrrfdVyE","date":1499868652,"description":null,"discount":null,"ending_balance":null,"forgiven":false,"lines":{"object":"list","data":[{"id":"ii_1AelYGBHxc8EdGrxB3d3T8bU","object":"line_item","amount":-13665,"currency":"chf","description":"Unused time on Tagging after 12 Jul 2017","discountable":false,"livemode":false,"metadata":{},"period":{"start":1499868652,"end":1502540244},"plan":{"id":"tagging-chf-month-1","object":"plan","amount":13700,"created":1499767901,"currency":"chf","interval":"month","interval_count":1,"livemode":false,"metadata":{"tagging":"true","videoMinutesPercentage":"0.5","sort":"40","type":"package","texts":"[]"},"name":"Tagging","statement_descriptor":null,"trial_period_days":null},"proration":true,"quantity":1,"subscription":"sub_B0lJCvwPWOYcLm","subscription_item":"si_1Aekb4BHxc8EdGrx96uejsne","type":"invoiceitem"},{"id":"ii_1AelYGBHxc8EdGrxDxzHn7N3","object":"line_item","amount":-13665,"currency":"chf","description":"Unused time on Scouting after 12 Jul 2017","discountable":false,"livemode":false,"metadata":{},"period":{"start":1499868652,"end":1502540244},"plan":{"id":"scouting-chf-month-1","object":"plan","amount":13700,"created":1499767901,"currency":"chf","interval":"month","interval_count":1,"livemode":false,"metadata":{"scouting":"true","sort":"30","type":"package","texts":"[]"},"name":"Scouting","statement_descriptor":null,"trial_period_days":null},"proration":true,"quantity":1,"subscription":"sub_B0lJCvwPWOYcLm","subscription_item":"si_1Aekb4BHxc8EdGrx9BwOKTe9","type":"invoiceitem"},{"id":"ii_1AelYGBHxc8EdGrxQeiHehMb","object":"line_item","amount":-69722,"currency":"chf","description":"Unused time on Pro after 12 Jul 2017","discountable":false,"livemode":false,"metadata":{},"period":{"start":1499868652,"end":1502540244},"plan":{"id":"pro-chf-month-1","object":"plan","amount":69900,"created":1499767899,"currency":"chf","interval":"month","interval_count":1,"livemode":false,"metadata":{"videoMinutes":"960","videoDownloads":"true","playerRequest":"true","playerTrading":"true","advancedSearch":"true","sort":"40","inclusivePackages":"advancedsearch-chf-month-1","texts":"[\"Platform\",\"Quick Search\",\"Advanced Search\",\"Communication external\",\"Communication internal\",\"Mobile Communication Apps for staff and players\",\"Player Requests\",\"Player Trading\"]"},"name":"Pro","statement_descriptor":null,"trial_period_days":null},"proration":true,"quantity":1,"subscription":"sub_B0lJCvwPWOYcLm","subscription_item":"si_1AejmSBHxc8EdGrxbEAdYWlA","type":"invoiceitem"},{"id":"sub_B0lJCvwPWOYcLm","object":"line_item","amount":754900,"currency":"chf","description":null,"discountable":true,"livemode":false,"metadata":{"lastUpdatedBy":"000000000000000000000004","organizationId":"55c8d10fa7a84b636d94adc7","organizationType":"team"},"period":{"start":1499868652,"end":1531404652},"plan":{"id":"pro-chf-year-1","object":"plan","amount":754900,"created":1499767898,"currency":"chf","interval":"year","interval_count":1,"livemode":false,"metadata":{"videoMinutes":"11520","videoDownloads":"true","playerRequest":"true","playerTrading":"true","advancedSearch":"true","sort":"40","inclusivePackages":"advancedsearch-chf-year-1","texts":"[\"Platform\",\"Quick Search\",\"Advanced Search\",\"Communication external\",\"Communication internal\",\"Mobile Communication Apps for staff and players\",\"Player Requests\",\"Player Trading\"]"},"name":"Pro","statement_descriptor":null,"trial_period_days":null},"proration":false,"quantity":1,"subscription":null,"subscription_item":"si_1AejmSBHxc8EdGrxbEAdYWlA","type":"subscription"},{"id":"sub_B0lJCvwPWOYcLm","object":"line_item","amount":149900,"currency":"chf","description":null,"discountable":true,"livemode":false,"metadata":{"lastUpdatedBy":"000000000000000000000004","organizationId":"55c8d10fa7a84b636d94adc7","organizationType":"team"},"period":{"start":1499868652,"end":1531404652},"plan":{"id":"scouting-chf-year-1","object":"plan","amount":149900,"created":1499767901,"currency":"chf","interval":"year","interval_count":1,"livemode":false,"metadata":{"scouting":"true","sort":"30","type":"package","texts":"[]"},"name":"Scouting","statement_descriptor":null,"trial_period_days":null},"proration":false,"quantity":1,"subscription":null,"subscription_item":"si_1Aekb4BHxc8EdGrx9BwOKTe9","type":"subscription"},{"id":"sub_B0lJCvwPWOYcLm","object":"line_item","amount":149900,"currency":"chf","description":null,"discountable":true,"livemode":false,"metadata":{"lastUpdatedBy":"000000000000000000000004","organizationId":"55c8d10fa7a84b636d94adc7","organizationType":"team"},"period":{"start":1499868652,"end":1531404652},"plan":{"id":"tagging-chf-year-1","object":"plan","amount":149900,"created":1499767901,"currency":"chf","interval":"year","interval_count":1,"livemode":false,"metadata":{"tagging":"true","videoMinutesPercentage":"0.5","sort":"40","type":"package","texts":"[]"},"name":"Tagging","statement_descriptor":null,"trial_period_days":null},"proration":false,"quantity":1,"subscription":null,"subscription_item":"si_1Aekb4BHxc8EdGrx96uejsne","type":"subscription"}],"has_more":false,"total_count":6,"url":"/v1/invoices/upcoming/lines?customer=cus_B0lIGLlrrfdVyE&subscription=sub_B0lJCvwPWOYcLm&subscription_prorate=true"},"livemode":false,"metadata":{},"next_payment_attempt":1499872252,"paid":false,"period_end":1499868652,"period_start":1499868652,"receipt_number":null,"starting_balance":0,"statement_descriptor":null,"subscription":"sub_B0lJCvwPWOYcLm","subscription_proration_date":1499868652,"subtotal":957648,"tax":null,"tax_percent":null,"total":957648,"webhooks_delivered_at":null}

Hello there,

I tried to remove & add items to subscription, but the upcomingInvoice call doesn't behave correctly. Is this a bug in Stripe?

Retrieve UpcomingInvoice Params:

{
  subscription: 'sub_At50DVMkrfF04u',
  subscription_items: [
    { plan: 'scouting-chf-month-1' },
    { plan: 'tagging-chf-month-1' },
    { id: 'si_1AXIqTCIUmg8SZ9N8aHF5NS9', deleted: true }
  ],
  subscription_prorate: true
}

As you can see I add 2 plans, and remove 1 item. The returned Upcoming Invoice does not contain line item for tagging-chf-month-1 plan (But It does contain scouting-chf-month-1 plan)

{
  "object": "invoice",
  "amount_due": 76182,
  "application_fee": null,
  "attempt_count": 0,
  "attempted": false,
  "charge": null,
  "closed": false,
  "currency": "chf",
  "customer": "cus_At50ekypRooTjP",
  "date": 1500682009,
  "description": null,
  "discount": null,
  "ending_balance": null,
  "forgiven": false,
  "lines": {
    "object": "list",
    "data": [
      {
        "id": "ii_1AXJr1CIUmg8SZ9N0SC8UqDQ",
        "object": "line_item",
        "amount": -1098,
        "currency": "chf",
        "description": "Unused time on Advanced Search after 22 Jun 2017",
        "discountable": false,
        "livemode": false,
        "metadata": {},
        "period": {
          "start": 1498093887,
          "end": 1500682009
        },
        "plan": {
          "id": "advanced-search-chf-month-1",
          "object": "plan",
          "amount": 1100,
          "created": 1498087621,
          "currency": "chf",
          "interval": "month",
          "interval_count": 1,
          "livemode": false,
          "metadata": {
            "advancedSearch": "true",
            "type": "package",
            "texts": "[]"
          },
          "name": "Advanced Search",
          "statement_descriptor": null,
          "trial_period_days": null
        },
        "proration": true,
        "quantity": 1,
        "subscription": "sub_At50DVMkrfF04u",
        "subscription_item": "si_1AXIqTCIUmg8SZ9N8aHF5NS9",
        "type": "invoiceitem"
      },
      {
        "id": "ii_1AXJr1CIUmg8SZ9NZJPmwUZO",
        "object": "line_item",
        "amount": 13680,
        "currency": "chf",
        "description": "Remaining time on Scouting after 22 Jun 2017",
        "discountable": false,
        "livemode": false,
        "metadata": {},
        "period": {
          "start": 1498093887,
          "end": 1500682009
        },
        "plan": {
          "id": "scouting-chf-month-1",
          "object": "plan",
          "amount": 13700,
          "created": 1498087621,
          "currency": "chf",
          "interval": "month",
          "interval_count": 1,
          "livemode": false,
          "metadata": {
            "scouting": "true",
            "type": "package",
            "texts": "[]"
          },
          "name": "Scouting",
          "statement_descriptor": null,
          "trial_period_days": null
        },
        "proration": true,
        "quantity": 1,
        "subscription": "sub_At50DVMkrfF04u",
        "subscription_item": "si_1AXJr1CIUmg8SZ9N9Ba5Moqk",
        "type": "invoiceitem"
      },
      {
        "id": "sub_At50DVMkrfF04u",
        "object": "line_item",
        "amount": 49900,
        "currency": "chf",
        "description": null,
        "discountable": true,
        "livemode": false,
        "metadata": {
          "lastUpdatedBy": "000000000000000000000004",
          "organizationId": "55c8d10fa7a84b636d94adc7"
        },
        "period": {
          "start": 1500682009,
          "end": 1503360409
        },
        "plan": {
          "id": "basic-chf-month-1",
          "object": "plan",
          "amount": 49900,
          "created": 1498087620,
          "currency": "chf",
          "interval": "month",
          "interval_count": 1,
          "livemode": false,
          "metadata": {
            "videoMinutes": "480",
            "videoDownloads": "false",
            "playerRequest": "true",
            "playerTrading": "true",
            "texts": "[\"Platform\",\"Quick Search\",\"Communication external\",\"Communication internal\",\"Mobile Communication Apps for staff and players\",\"Player Requests\",\"Player Trading\"]"
          },
          "name": "Basic",
          "statement_descriptor": null,
          "trial_period_days": null
        },
        "proration": false,
        "quantity": 1,
        "subscription": null,
        "subscription_item": "si_1AXIqTCIUmg8SZ9N1uT8v9JV",
        "type": "subscription"
      },
      {
        "id": "sub_At50DVMkrfF04u",
        "object": "line_item",
        "amount": 13700,
        "currency": "chf",
        "description": null,
        "discountable": true,
        "livemode": false,
        "metadata": {
          "lastUpdatedBy": "000000000000000000000004",
          "organizationId": "55c8d10fa7a84b636d94adc7"
        },
        "period": {
          "start": 1500682009,
          "end": 1503360409
        },
        "plan": {
          "id": "scouting-chf-month-1",
          "object": "plan",
          "amount": 13700,
          "created": 1498087621,
          "currency": "chf",
          "interval": "month",
          "interval_count": 1,
          "livemode": false,
          "metadata": {
            "scouting": "true",
            "type": "package",
            "texts": "[]"
          },
          "name": "Scouting",
          "statement_descriptor": null,
          "trial_period_days": null
        },
        "proration": false,
        "quantity": 1,
        "subscription": null,
        "subscription_item": "si_1AXJr1CIUmg8SZ9N9Ba5Moqk",
        "type": "subscription"
      }
    ],
    "has_more": false,
    "total_count": 4,
    "url": "/v1/invoices/upcoming/lines?customer=cus_At50ekypRooTjP&subscription=sub_At50DVMkrfF04u&subscription_prorate=true"
  },
  "livemode": false,
  "metadata": {},
  "next_payment_attempt": 1500685609,
  "paid": false,
  "period_end": 1500682009,
  "period_start": 1498090009,
  "receipt_number": null,
  "starting_balance": 0,
  "statement_descriptor": null,
  "subscription": "sub_At50DVMkrfF04u",
  "subscription_proration_date": 1498093887,
  "subtotal": 76182,
  "tax": null,
  "tax_percent": null,
  "total": 76182,
  "webhooks_delivered_at": null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment