#piq9117
1 messages · Page 1 of 1 (latest)
Could you share the code how you update the quantity of the subscription currently?
not sure if you're prepared to see this. 😆
let mkPricesWithItems :: [(StripePriceId, Int)] -> [Text] -> [(StripePriceId, Int, Maybe Text)]
mkPricesWithItems [] [] = []
mkPricesWithItems [] _itemIds = []
mkPricesWithItems (stripePriceId : stripePriceIds) [] =
(fst stripePriceId, snd stripePriceId, Nothing) : mkPricesWithItems stripePriceIds []
mkPricesWithItems ((stripePriceId, quantity) : stripePriceIds) (itemId:itemIds) =
(stripePriceId, quantity, Just itemId) : mkPricesWithItems stripePriceIds itemIds
here's the rest
res <-
runStripe stripe span $ do
postSubscriptionsSubscriptionExposedId currentSubscription.subscriptionId $
Just $
mkPostSubscriptionsSubscriptionExposedIdRequestBody
{ ...
postSubscriptionsSubscriptionExposedIdRequestBodyItems =
Just $
mkPricesWithItems stripePriceIds itemIds <&> \(stripePriceId, quantity, itemId) ->
mkPostSubscriptionsSubscriptionExposedIdRequestBodyItems'
{ postSubscriptionsSubscriptionExposedIdRequestBodyItems'Price = Just $ unStripePriceId stripePriceId,
postSubscriptionsSubscriptionExposedIdRequestBodyItems'Id = itemId,
postSubscriptionsSubscriptionExposedIdRequestBodyItems'Quantity = Just quantity
}
}
Could you also share the subscription ID (sub_xxx) that didn't behave as expected?
Are you trying to remove an existing item or reduce the quantity of item?
To remove an existing item, you can set items.deleted on the item you wish to delete when updating the Subscription: https://stripe.com/docs/api/subscriptions/update#update_subscription-items-deleted
sorry. i was trying to get the subscription id. it's sub_1Mfw1fGJhtMpdHF8KrJLMwdz. I want this item price_1MfsYiGJhtMpdHF8bTSKVOVj to be removed from that subscription in the upcoming invoice.
aah. sounds like i can use that flag
Yup! You can indicate deleted flag on the subscription item si_NQnciHBz9wZGs2 (the subscription item of price_1MfsYiGJhtMpdHF8bTSKVOVj) to remove it
that answers my question. thanks! 