【问题标题】:Using Stripe.net, how to retrieve items from a successful charge response body?使用 Stripe.net,如何从成功的收费响应正文中检索项目?
【发布时间】:2015-10-07 01:32:07
【问题描述】:

使用 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",

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

如果不需要更改 Stripe.net API 最好...

感谢您的帮助。

【问题讨论】:

    标签: asp.net stripe-payments stripe.net


    【解决方案1】:

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

    例如:

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

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

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

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

    【讨论】:

    • 即使我们没有在令牌中传递信用卡名称和地址,它会返回吗?
    • @CodeIt 不,根据我在帐户的条带日志中看到的,它没有。
    猜你喜欢
    • 2016-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多