英文:
How to add metadata to a new subscription in Stripe?
问题
我有这段代码,来自Stripe API文档网站上的示例:
stripe.Key = "my_key"
s, err := sub.New(&stripe.SubParams{
Customer: "test_customer",
Plan: "month-plan",
})
这段代码运行得很好。但是我找不到如何在这个请求中添加元数据,比如 Product: "special-services"
。
我能在创建订阅时一次性完成吗?如果可以,那么该怎么做?
谢谢!
英文:
I have this code, from the examples on Stripe API docs site:
stripe.Key = "my_key"
s, err := sub.New(&stripe.SubParams{
Customer: "test_customer",
Plan: "month-plan",
})
This code works just fine. But I couldn't find how to add metadata to this request, like Product: "special-services"
.
Can I do it in one request on subscription creation, and if so, then how?
Thanks!
答案1
得分: 6
subParams := &stripe.SubParams{
Customer: "test_customer",
Plan: "month-plan",
}
subParams.AddMeta("Product","special-services")
s, err := sub.New(subParams)
stripe.SubParams
嵌入了 stripe.Params
,它具有一个方法 AddMeta
,用于向 map[string]string
添加元数据信息。
英文:
subParams := &stripe.SubParams{
Customer: "test_customer",
Plan: "month-plan",
}
subParams.AddMeta("Product","special-services")
s, err := sub.New(subParams)
stripe.SubParams
embeds stripe.Params
which has a method AddMeta
, which adds meta info to a map[string]string
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论