#x001w - subscriptions
1 messages ยท Page 1 of 1 (latest)
hi friend, pls
Are you trying to set items.metadata for a subscription? If so, what is the issue?
I had tried to create a sub
but the Items.metadata didn't set
according my above code
Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_FLewZbOizqeQJa
It looks like that request worked, and I do see the metadata on the items. Why do you think it's not working?
you didn't add the metadata to the subscription, but to the items. If you want to add the metadata to the subscription, then you need to use this: https://stripe.com/docs/api/subscriptions/create#create_subscription-metadata
it didn't work?
the code is to create the subscription and is similar to the url you same
sent
the code about the Items, I give two params, one is sub_id another is Metadata
the code can create the sub, but it seem wrong that doesn't create the Metadata at the same time
maybe you should check the event
"evt_1LEx4TD5BdSHt7NMylAD4MEh"
the webhook back didn't attach the metadata
Where do you want to create the metadata? On the subscription? On the subscription.item? On the invoice?
Each of these is different.
I want to create the sub with the metadata at the same time.
Then it should be something like this:
var options = new SubscriptionCreateOptions
{
Customer = "cus_xxx",
Items = new List<SubscriptionItemOptions>
{
new SubscriptionItemOptions
{
Price = "price_xxx",
},
},
Metadata: # add the metadata here, directly on the subscription object
};
I'm sorry I'm a bit lost.
The code you shared at the very beginning is correct and works, I can see the metadata stored in the subscription.item on your account.
Earlier you said you want the metadata directly on the subscription object, so I showed you how to do that.
And now you want it in subscription.item?
it did't store in the subscription.item. Didn't work. I want to know why?
pls check the req_FLewZbOizqeQJa and event evt_1LEx4TD5BdSHt7NMylAD4MEh
or you should try the way I have done subscription with the metadata created
it did't store in the subscription.item. Didn't work. I want to know why?
Why do you say it didn't work? Is it because you don't see it in theinvoice.paidevent?
more than that invoice.paid event and the picture didn't have
The invoice.paid event doesn't have subscription.item in it, so it's expected to not see the metadata. If you want to see it here, you could:
- add the metadata directly to the price ID
- or add the metadata to the subscription itself, and when you receive the event
invoice.paidretrieve the subscription associated with the invoice.
you mean I should do that for two steps? one step is just create the sub, or the another step is attach metadata associated the sub_id?
No I didn't say that.
so I'm very confused
Is this a screenshot of the subscription in the dashboard? If so, you need to add the metadata directly to the subscription (as I showed you earlier) to see the metadata there.
If you're not quite sure why, I can show the problem again. I think this is a bug. Or your documentation doesn't write clearly about some situations, which makes it impossible to create Metadata when creating subscriptions at the same time.
Can you try my suggestion:
var options = new SubscriptionCreateOptions
{
Customer = "cus_xxx",
Items = new List<SubscriptionItemOptions>
{
new SubscriptionItemOptions
{
Price = "price_xxx",
},
},
Metadata: # add the metadata here, directly on the subscription object
};
This will add metadata directly to the subscription, and you will be able to see it in the dashboard.
And when you get invoice.paid event, find the subscription ID in the invoice.subscription property, then retrieve the subscription object, and you will see the metadata.
Would that solve your issue? If not, please let me know exactly what is the issue.
Yes this is just an example, feel free to add DefaultPaymentMethod or anything else
Just make sure to keep the Metadata directly on the subscription object (and not on the item object)
Your code looks okay, but you didn't change the metadata. You need to move it from the items and put it on the subscription directly (see my example above)
Can you copy-paste your code directly here? I'll show you.
params := &stripe.SubscriptionParams{
Customer: stripe.String("cus_xxx"),
DefaultPaymentMethod: stripe.String("pm_xxx"),
Items: []*stripe.SubscriptionItemsParams{
{
Price: stripe.String("price_xxx"),
Metadata: map[string]string{
"subscriber": "whmtest",
"streamer": "philgodlewski",
"period": "monthly",
},
},
},
TrialEnd: stripe.Int64(1657505820),
BillingCycleAnchor: stripe.Int64(1657505820),
}
it's golang code
Can you try something like this? This will add the metadata directly to the subscription:
params := &stripe.SubscriptionParams{
Customer: stripe.String("cus_xxx"),
DefaultPaymentMethod: stripe.String("pm_xxx"),
Items: []*stripe.SubscriptionItemsParams{
{
Price: stripe.String("price_xxx"),
},
},
TrialEnd: stripe.Int64(1657505820),
BillingCycleAnchor: stripe.Int64(1657505820),
Metadata: map[string]string{
"subscriber": "whmtest",
"streamer": "philgodlewski",
"period": "monthly",
},
}
sorry it's wrong
metadata must in Items
SubscriptionParams dosen't have the Metadata object
SubscriptionParams just has the Items
๐ , I'm stepping in for my colleague @undone kiln
Hi, pls help me to solve the problem.
a couple of things
1- https://stripe.com/docs/api/metadata?lang=go here's how you can create Metadata in Go
metadata.put("order_id", "6735");```
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
2- as my colleague explained, you are putting the metadata in the Items Object instead of the Subscription
so you need to move it from the SubscriptionItemParams to the SubscriptionParams object itself
no, I create the sub with the metadata at the same time
I had showed that it's report worng
the SubscriptionParams didn't have the Metadata Object
what version of the Stripe golang library are you using?
github.com/stripe/stripe-go/v72 v72.113.0