var json = new StreamReader(context.Request.InputStream).ReadToEnd();
// var mydata = JsonConvert.DeserializeObject<StripeTransfer>(json); var stripeEvent = StripeEventUtility.ParseEvent(json);
StripeTransfer stripeTransfer; switch (stripeEvent.Type) { case "transfer.created": stripeTransfer = Stripe.Mapper<StripeTransfer>.MapFromJson(stripeEvent.Data.Object.ToString()); var transferId = stripeTransfer.Id; stripeTransfer = _stripeManager.GetTransfer(transferId); _stripeManager.ProcessTransfer(stripeTransfer); break;Ok, with the help of a neat little ruby gem called Ultrahook...made local testing of the webhooks a bit easier.
var json = new StreamReader(context.Request.InputStream).ReadToEnd();
var stripeEvent = StripeEventUtility.ParseEvent(json);
StripeTransfer stripeTransfer;
switch (stripeEvent.Type)
{
case "transfer.created":
stripeTransfer = Stripe.Mapper<StripeTransfer>.MapFromJson(stripeEvent.Data.Object.ToString());
string transferId = stripeTransfer.Id;
// do some stuff
for (int i = 0; i < Int32.Parse(stripeEvent.Data.Object["transactions"]["total_count"].ToString()); i++)
{
string chargeId = stripeEvent.Data.Object["transactions"]["data"][i]["id"];
// send ID over to business tier for processing
}
break; Ok, so the above example does not work...well, it does but using total_count errors out with out of range index. For some reason there are only 5 charge objects in my transfer data even though the data's total_count says 17. I suspect it may be intentional on Stripe's side and that I probably need to explicitly request all charges.
Finding assistance with stripe.net has been pretty much impossible but for the record it is a beautiful API. Jayme Davis is a ninja rock star. I'll be working on this today so once had I'll be sure and post the solution.
public IEnumerable<StripeBalanceTransaction> GetChargesByTransferId(string transferId, StripeBalanceTransactionType type) { try { var balanceService = new StripeBalanceService(); var options = new StripeBalanceTransactionListOptions { TransferId = transferId, Type = type.ToString() };
IEnumerable<StripeBalanceTransaction> balanceTransactions = balanceService.List(options);
return balanceTransactions; } catch (StripeException sex) { throw; } catch (Exception ex) { throw; }--
You received this message because you are subscribed to the Google Groups "Stripe API Discussion" group.
To post to this group, send email to api-d...@lists.stripe.com.
Visit this group at http://groups.google.com/a/lists.stripe.com/group/api-discuss/.
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.