【问题标题】:Retrieve Card Detail from Stripe Customer Id从 Stripe 客户 ID 中检索卡详细信息
【发布时间】:2018-05-21 20:31:59
【问题描述】:

您好,我正在使用 Stripe 流程进行付款,并且我正在生成 Stripe 客户 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 中获取卡号、姓名、到期月份等卡详细信息?

【问题讨论】:

    标签: asp.net stripe-payments payment-gateway payment-processing


    【解决方案1】:

    您无法检索整个卡片信息。
    您可以从客户 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();
    

    【讨论】:

    • 你能帮我,同时提供如何检索 4 位数卡号和有效期的代码
    • 我刚刚编辑了我的答案以包含代码 sn-p。检查一下
    • 您好,我遇到了一个问题,因为找不到别名条纹。我正在用 c# 编写这段代码
    • 我认为你应该更新你的答案,同时寻找代码为 StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2"); var customerService = new StripeCustomerService(); StripeCustomer 客户 = customerService.Get("cus_BwQOSZOt21ocuh");
    • StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2"); StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2"); var customerService = new StripeCustomerService(); StripeCustomer 客户 = customerService.Get("cus_BwS21a7fAH22uk");作为对客户的回应,您将具有来源属性。请查看返回的 JSON 响应。它包含源列表(添加的卡片列表。)
    猜你喜欢
    • 2020-03-28
    • 1970-01-01
    • 2016-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-10
    • 2020-04-24
    • 2021-04-12
    相关资源
    最近更新 更多