从 Stripe 客户 ID 中检索卡片详细信息

Retrieve Card Detail from Stripe Customer Id

您好,我正在使用条纹流程进行付款,并且我正在从下面的代码中生成条纹客户 ID。

  StripeCustomerId = CreateStripeCustomer(fname, lname, Email, objStripeRequestOptions);

还有

IEnumerable<StripeCard> AllStripeCardResponse = cardService.List(StripeCustomerId);
string strLast4 = CardNumber.Replace(" ", "").Substring(CardNumber.Replace(" ", "").Length - 4);
dynamic ExistingCard = (from x in AllStripeCardResponse where x.Last4 == strLast4 & x.ExpirationMonth == Convert.ToInt32(Month.Trim()) & x.ExpirationYear == Convert.ToInt32(Year.Trim()) select x).ToList();

它将现有卡作为 0

任何人都可以告诉我如何从生成的 Stripe 客户 ID 中获取卡号、姓名、到期月份和年份等卡详细信息吗?

您无法检索完整的卡信息。
您可以从客户 API.
中存在的源对象中获取一些信息 检索来源将为您提供卡号的最后 4 位数字和有效期。

    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4ol‌fQ2");

    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4ol‌​fQ2");

    var customerService = new StripeCustomerService();
    StripeCustomer customer = customerService.Get("cus_BwS21a7fAH22uk");

,作为对客户的回应,您将拥有来源属性。请查看返回的 JSON 响应。它包含源列表(添加的卡片列表。)

你会得到与此类似的示例对象,在这里你可以看到卡片的最后 4 位数字作为对象返回,在我的例子中是 1111

#<Stripe::ListObject:0x5ea1a78> JSON: {
  "object": "list",
  "data": [
    {"id":"card_1BY6nrCaMyPmWTcG3uosK2up","object":"card","address_city":null,"address_country":null,"address_line1":null,"address_line1_check":null,"address_line2":null,"address_state":null,"address_zip":null,"address_zip_check":null,"brand":"Visa","country":"US","customer":"cus_BvylB8PAVap2JQ","cvc_check":"pass","dynamic_last4":null,"exp_month":12,"exp_year":2017,"fingerprint":"yE1mPcIGvqTYGcxQ","funding":"unknown","last4":"1111","metadata":{},"name":null,"tokenization_method":null}
  ],
  "has_more": false,
  "total_count": 1,
  "url": "/v1/customers/cus_BvylB8PAVap2JQ/sources"
}

另见下文

var stripecard = "cus_BwS21a7fAH22uk";
StripeCustomer customer;
StripeConfiguration.SetApiKey(ConfigurationManager.AppSettings["StripeApiKey"].ToString());
var customerService = new StripeCustomerService();
customer = customerService.Get(stripecard);
ViewBag.last4card = customer.Sources.Data[0].Card.Last4.ToString();
ViewBag.ExpMonth = customer.Sources.Data[0].Card.ExpirationMonth.ToString();
ViewBag.ExpYear = customer.Sources.Data[0].Card.ExpirationYear.ToString();
ViewBag.Name = customer.Sources.Data[0].Card.Name.ToString();