使用Stripe.net,如何从成功的收费响应主体中检索项目?

Using Stripe.net, how to retrieve items from a successful charge response body?

使用 Stripe.net 服务 API (https://github.com/jaymedavis/stripe.net),如何从成功收费的响应正文中检索项目?

充值响应正文成功示例:

{
id: ch_xxxxxxxxxxxxxxxxxxx,
object: "charge",
created: 111111111,
livemode: true,
paid: true,
status: "succeeded",
amount: 33400,
currency: "usd",
refunded: false,
source:
    {
    id: card_xxxxxxxxxxxxxxxxx,
    object: "card",
    last4: "1234",
    brand: "Visa",
    funding: "credit",
    exp_month: 12,
    exp_year: 2010,
    fingerprint: "xxxxxxxxxxxx",
    country: "BR",
    name: "john smith",
    address_line1: "address 1",
    address_line2: null,
    address_city: "senai",
    address_state: null,
    address_zip: "00000",
    address_country: "MY",
    cvc_check: "pass",
    address_line1_check: "unavailable",
    address_zip_check: "unavailable",
    tokenization_method: null,
    dynamic_last4: null,
    metadata:
    {},
    customer: null
}
captured: true,
balance_transaction: "txn_xxxxxxxxxxxxxxxxx",
...

我只是想获取以下值:

address_line1_check: "unavailable",
address_zip_check: "unavailable",

对于那些好奇为什么的人,简单地说,当这两个值是 "unavailable" 时,这意味着银行的信用卡不支持这些反欺诈功能,根据经验,这些费用很可能是确实是骗人的。因此,一旦我检测到它们,我就可以在这些交易上添加一个危险信号。

最好不需要对 Stripe.net API...

进行更改

感谢您的帮助。

当您使用 Stripe.net 创建收费时,它 returns 一个 StripeCharge 对象,其属性用于访问从 Stripe API 返回的值。

例如:

var chargeService = new StripeChargeService();
StripeCharge stripeCharge = chargeService.Create(myCharge);
string status = stripeCharge.Status;

StripeCharge 对象的属性之一是 Source,它是一个 StripeCard。 StripeCard class 具有 AddressLine1Check 和 AddressZipCheck 的属性,它们对应于您想要的 JSON 属性。所以你应该能够像这样获得你想要的值:

string addressLine1Check = stripeCharge.Source.AddressLine1Check;
string addressZipCheck = stripeCharge.Source.AddressZipCheck;

对于 class 定义(查看所有属性)请参阅 https://github.com/jaymedavis/stripe.net/blob/master/src/Stripe/Entities/StripeCharge.cs and https://github.com/jaymedavis/stripe.net/blob/master/src/Stripe/Entities/StripeCard.cs