Home > Uncategorized > Stripe – Special case transfers in C# / .NET

Stripe – Special case transfers in C# / .NET

If you run a platform on Stripe, where you take payments from consumers, and pay sellers,
then you can find plenty of examples of how to accept a payment, but here’s how to pay out
a seller using the balance in your Stripe account.

You need to have the seller connected to your platform, and have a account reference for them.

This example transfers £1 GBP from your platform account to a connected seller account.

public string MakeTransfer()
{
WebClient wc = new WebClient();
var strResult = “”;
try
{
NetworkCredential myCreds = new NetworkCredential(“sk_test_….”, “”);
wc.Credentials = myCreds;
var strUrl = “https://api.stripe.com/v1/transfers”;
var strPostdata = “amount=100”;
strPostdata += “&currency=GBP”;
strPostdata += “&destination=acct_….”;
wc.Headers[“Content-Type”] = “application/x-www-form-urlencoded”;
strResult = wc.UploadString(strUrl, strPostdata);
}
catch (WebException exception)
{
if (exception.Response != null)
{
var responseStream = exception.Response.GetResponseStream();
if (responseStream != null)
{
using (var reader = new StreamReader(responseStream))
{
strResult = reader.ReadToEnd();
}
}
}
}
return strResult;
}
}

A Json response would be:

{
“id”: “tr_…”,
“object”: “transfer”,
“created”: 1431422943,
“date”: 1431422943,
“livemode”: false,
“amount”: 100,
“currency”: “gbp”,
“reversed”: false,
“status”: “pending”,
“type”: “stripe_account”,
“reversals”: {
“object”: “list”,
“total_count”: 0,
“has_more”: false,
“url”: “/v1/transfers/tr_……/reversals”,
“data”: []
},
“balance_transaction”: “txn_…..”,
“destination”: “acct_…..”,
“destination_payment”: “py_….”,
“description”: null,
“failure_message”: null,
“failure_code”: null,
“amount_reversed”: 0,
“metadata”: {},
“statement_descriptor”: null,
“recipient”: null,
“source_transaction”: null,
“application_fee”: null
}

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: