jaymedavis/stripe.net — pull request #22 by darden88 (2012-04-02 18:57:14+00:00)
Title: New native type parsing for web hook notifications

Implemented parsing for Stripe web hooks so that referenced data will appear as a native Stripe type (StripeCharge, StripeCustomer, etc.).

Implemented new entitities StripeTransfer and StripeTransferSummary, which can appear as referenced entities in a Stripe web hook notification.

There are many ways to parse the json data into a native Stripe type and represent it. In the end I created a new property called StripeType that is an object and also created a void method called ParseStripeType. Another approach that I considered was to change StripeEventData.Object from an auto-property to a regular field and implement the parsing on each set operation. In the end I felt this was the most straightforward.

You're supposed to use the API something like this:

StripeEvent stripeEvent = StripeEventUtility.ParseEvent(json);
var data = stripeEvent.Data;
data.ParseStripeType();

if (data.StripeType is StripeCharge){
var charge = data.StripeType as StripeCharge;
//do something with the charge
}
else if (data.StripeType is StripeCustomer){
var customer = data.StripeType as StripeCustomer;
//do something with the customer
}