使用Stripe.net,如何从成功的收费回复机构中检索项目?

时间:2015-10-07 01:32:07

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

使用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进行更改,则为最佳...

感谢您的帮助。

1 个答案:

答案 0 :(得分:3)

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

例如:

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

StripeCharge对象的一个​​属性是Source,它是一个StripeCard。 StripeCard类具有AddressLine1Check和AddressZipCheck的属性,这些属性对应于您想要的JSON属性。所以你应该能够得到你想要的值:

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