【问题标题】:Add Metadata to stripe on customers添加元数据以对客户进行条带化
【发布时间】:2016-10-02 22:09:55
【问题描述】:

因此,我需要为客户添加一个唯一标识符。通过条带元数据。这就是我现在完全构建它的方式,但是我只是告诉我用户购买了哪个包的最后一部分。

我试着看这里:

Plans to stripe

代码在这里:

  var planType = abonnement.fk_userid != null ? "Business" : "Default";

  planService.Create(new StripePlanCreateOptions()
  {
     Amount = 99 * 100,
     Name = abonnement.mdr + " - (" + planType + ")",
     Currency = "EUR",
     Interval = "month",
     IntervalCount = 6,
     Id = 1,
     Metadata =
     {
         "Pakkeid:" = abonnement.PriceValueUnikId
     }
  }
  );

元数据

出错

赋值的左边必须是变量、属性或 索引器

初始化器成员声明器无效

它是一个字典

【问题讨论】:

  • Metadata 是什么类型?它是字典还是对象?
  • 如果我将鼠标悬停在元数据上,告诉他们它是:字典
  • Metadata = new Dictionary<string, string> { {"Pakkeid", abonnement.PriceValueUnikId } }
  • @Rob 感谢您的评论!我希望你能给我的问题+1。

标签: c# stripe-payments


【解决方案1】:

这是一个示例,展示如何将元数据与Stripe.net 一起使用:https://github.com/jaymedavis/stripe.net#updating-a-bank-account

你应该像这样修改你的代码:

planService.Create(new StripePlanCreateOptions()
{
    Amount = 99 * 100,
    Name = abonnement.mdr + " - (" + planType + ")",
    Currency = "EUR",
    Interval = "month",
    IntervalCount = 6,
    Id = 1,
    Metadata = new Dictionary<string, string>()
    {
        { "Pakkeid", abonnement.PriceValueUnikId }
    }
}
);

【讨论】:

  • 哦,我还没有看到。但是你找到它真是太好了。我给你 +1 分,希望你能给我同样的问题。美好的一天!
  • 但是当我看到你的回答后,我看到它在这里stackoverflow.com/a/1177534/6115825
猜你喜欢
  • 2020-01-08
  • 1970-01-01
  • 2021-10-29
  • 2022-12-06
  • 2016-07-15
  • 2016-11-02
  • 2010-11-27
  • 1970-01-01
相关资源
最近更新 更多