【问题标题】:Can I get the returned credit card details after creating a Stripe customer that includes a source (credit card)?创建包含来源(信用卡)的 Stripe 客户后,能否获取退回的信用卡详细信息?
【发布时间】:2021-09-09 15:58:27
【问题描述】:

使用 Stripe 创建新客户,如下所示,我以令牌 ID 的形式向客户添加来源(信用卡)。创建客户后,我可以看到返回了源 ID,但没有返回数据。

问题 - 是否可以让客户获取数据,这样我就不必执行来自 Stripe 的另一个请求来获取卡详细信息?

这是一个简单的例子

StripeConfiguration.ApiKey = "sk_test_1234";
var options = new CustomerCreateOptions {
       Email = "email,
       Name = "name,
       Source = "12345" // card token number here
};
var service = new CustomerService();
customer = service.Create(options);

这是我在客户返回时看到的。 您可以看到 defaultSourceId(卡),但 DefaultSource 为空。如果它返回详细信息(品牌、lastfour、exp 月、exp 年等)会很好,否则我必须再次调用 Stripe 以获取卡详细信息。

【问题讨论】:

    标签: c# stripe-payments


    【解决方案1】:

    在创建或检索客户时,默认情况下不再包含客户的来源:https://stripe.com/docs/api/customers/object#customer_object-sources

    如果您仍想检索来源列表,则必须扩展您的客户创建调用:https://stripe.com/docs/api/expanding_objects

    例如:

    StripeConfiguration.ApiKey = "sk_test_1234";
    var options = new CustomerCreateOptions {
           Email = "email,
           Name = "name,
           Source = "12345" // card token number here
    };
    // Request the full list of sources attached to this customer
    options.AddExpand("sources");
    
    var service = new CustomerService();
    customer = service.Create(options);
    

    【讨论】:

      猜你喜欢
      • 2016-08-08
      • 1970-01-01
      • 2020-03-28
      • 2018-05-21
      • 2014-02-20
      • 1970-01-01
      • 2011-06-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多