#karuppasamy

1 messages ยท Page 1 of 1 (latest)

shell basinBOT
cerulean dawn
flat thorn
#

here i add qty?

cerulean dawn
#

You can omit the price parameter, unless you're changing the plan/price

flat thorn
#

What is order id .need to give?

cerulean dawn
#

You can ignore that, that's just an example of updating metadata

flat thorn
#

ok

#

[HttpPost("UpdateUserQty")]
public async Task<IActionResult> UpdateUserQty()
{
StripeConfiguration.ApiKey = "sk_test_51N51ZTLabf7E4J4FuPH1pxZdNzvTJ6dtddryJCVeZZe9pLj09nMY9lrKiNfxeCzZIXOSCNg24gcLYDGC3Q65bJ3T00wro9neHs";

        var options = new SubscriptionUpdateOptions
        {
            Metadata = new Dictionary<string, string>
              {
                 { "quantity", "5" } // Add quantity value here
              },
        };
        var service = new SubscriptionService();
        service.Update(
          "sub_1NQ2X1Labf7E4J4FIUQ0oywa",
          options);

        return Ok();
    }
#

can you please check is that correct

cerulean dawn
#

No, you don't need a metadata dictionary. The example from the first screenshot is closer to what you need

flat thorn
#

can u give code for where add qty in my code

#

[HttpPost("UpdateUserQty")]
public async Task<IActionResult> UpdateUserQty()
{
StripeConfiguration.ApiKey = "sk_test_51N51ZTLabf7E4J4FuPH1pxZdNzvTJ6dtddryJCVeZZe9pLj09nMY9lrKiNfxeCzZIXOSCNg24gcLYDGC3Q65bJ3T00wro9neHs";

var options = new SubscriptionUpdateOptions
{
    Quantity = 5 // Set the desired quantity here
};

var service = new SubscriptionService();
service.Update(
    "sub_1NQ2X1Labf7E4J4FIUQ0oywa",
    options);

return Ok();

}

cerulean dawn
#

We don't write code, no. Using the docs I've shared you should be able to piece it together

flat thorn
#

is that correcr

#

correct

cerulean dawn
#

No, you need to use SubscriptionItemOptions

flat thorn
#

StripeConfiguration.ApiKey = "sk_test_51N51ZTLabf7E4J4FuPH1pxZdNzvTJ6dtddryJCVeZZe9pLj09nMY9lrKiNfxeCzZIXOSCNg24gcLYDGC3Q65bJ3T00wro9neHs";

        var options = new SubscriptionItemUpdateOptions
        {
            Quantity = 5 // Set the desired quantity here
        };

        var service = new SubscriptionItemService();
        service.Update(
            "sub_1NQ2X1Labf7E4J4FIUQ0oywa", // Replace with the subscription item ID
            options);
cerulean dawn
#

Your parameters are still wrong:

var options = new SubscriptionUpdateOptions
{
  Items = new List<SubscriptionItemOptions>
  {
    new SubscriptionItemOptions
    {
      Id = subscription.Items.Data[0].Id,
      Quantity = 6,
    },
  },
};
subscription = service.Update(subscription.Id, options);
flat thorn
#

Id = subscription.Items.Data[0].Id,

is that susbcription id?

cerulean dawn
#

No, the si_xxx ID of the item you want to update the quantity on

flat thorn
#

where to get si_xxx in dahsboard

cerulean dawn
#

You don't, you get it via the API from the Subscription object

flat thorn
#

getting error in subscription

#

anything i need to import?

cerulean dawn
#

I don't see an error?

flat thorn
#

please check my screenshot showing red color

#

error showing subscription does not show current context

cerulean dawn
#

Well, do you have a subscription variable in your code?

flat thorn
#

StripeConfiguration.ApiKey = "sk_test_51N51ZTLabf7E4J4FuPH1pxZdNzvTJ6dtddryJCVeZZe9pLj09nMY9lrKiNfxeCzZIXOSCNg24gcLYDGC3Q65bJ3T00wro9neHs";

        var service = new SubscriptionService();
        var subscription = service.Get("sub_1NQ2X1Labf7E4J4FIUQ0oywa");

        var options = new SubscriptionUpdateOptions
        {
            Items = new List<SubscriptionItemOptions>
{
    new SubscriptionItemOptions
    {
        Id = subscription.Items.Data[0].Id, // Replace with the ID of the subscription item you want to update
        Quantity = 6 // Set the desired quantity here
    }
}
        };

        subscription = service.Update(subscription.Id, options);



    

        return Ok();
cerulean dawn
#

Have you done as the comments suggests?

Replace with the ID of the subscription item you want to update

#

You need to retrieve the si_xxx ID in your code yourself

flat thorn
#

how do i check if the qty is updated or not

cerulean dawn
#

You'd check the response of the API request

flat thorn
#

can check it dashboard ?

#

i mean log

cerulean dawn
#

Sure

flat thorn
#

can u give screen or link to check this

#

stripe dashbaord

cerulean dawn
#

You'd visit the Dashboard page for the Subscription

flat thorn
#

This one?

cerulean dawn
#

You can see the related logs from there

flat thorn
#

where i do check how many qty assigned for this subscription in dashboard

shell basinBOT
bleak summit
#

๐Ÿ‘‹ stepping in here

#

If you look at the Subscription's page in the Dashboard you can see the quantity of each item

flat thorn
#

Not able to find it

#

can u give correct URL