#piq9117

1 messages · Page 1 of 1 (latest)

brave bobcatBOT
chilly crest
#

Could you share the code how you update the quantity of the subscription currently?

opaque pilot
#

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
                        }
              }
chilly crest
#

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?

opaque pilot
#

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

chilly crest
#

Yup! You can indicate deleted flag on the subscription item si_NQnciHBz9wZGs2 (the subscription item of price_1MfsYiGJhtMpdHF8bTSKVOVj) to remove it

opaque pilot
#

that answers my question. thanks! PU_PeepoLeaveWave