Home > Uncategorized > Managing #stripe disputes in #connected accounts

Managing #stripe disputes in #connected accounts

stripe

If you run a platform in Stripe, then you are ultimately accountable for the accounts that you connect on the platform. So if you get a few bad apples, you need to find a way to weed them out.

Lets start with some code to list all connected accounts:

publicstaticstring ListAllConnectedAccounts()
{
var wc = new WebClient();
string strResult;
try
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
var myCreds = new NetworkCredential(SecretKey, “”);
wc.Credentials = myCreds;
wc.Headers[“Content-Type”] = “application/x-www-form-urlencoded”;
strResult = wc.DownloadString(strUrl);
}
catch (WebException ex)
{
strResult = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
}
return strResult;
}
When this runs, then you get a list of all your connected accounts in a Json Object. I use Newtonsoft.Json to parse this.
Then, once you get your list of accounts, you’ll want to see which ones have open disputes, so for each account, then you run this code:
publicstaticstring ListCustomerDisputes(string stripeAccount)
{
var wc = new WebClient();
try
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
var myCreds = new NetworkCredential(SecretKey, “”);
wc.Credentials = myCreds;
wc.Headers[“Stripe-Account”] = stripeAccount;
wc.Headers[“Content-Type”] = “application/x-www-form-urlencoded”;
return wc.DownloadString(strUrl);
}
catch (WebException ex)
{
return new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
}
}
Once this returns – you can examine each of these accounts manually. Some accounts have disputes through no fault of their own – a big account is bound to have at least a few disputes, but when you find a really bad account, you can close your connection to it with this code:
public static string DeAuthorize(string stripeAccount)
{
/*
-u sk_xxxxxx: \
-d client_id=ca_xxxxxxx \
-d stripe_user_id=acct_1BkSmpCTl4PWCQPr*/
var wc = new WebClient();
var strClientId = ConfigurationManager.AppSettings[“stripe_client_id”];
try
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
String userName = SecretKey;
String passWord = “”;
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(userName + “:” + passWord));
wc.Headers[HttpRequestHeader.Authorization] = “Basic ” + credentials;
var strPostData = “client_id=” + strClientId;
strPostData += “&stripe_user_id=” + stripeAccount;
wc.Headers[“Content-Type”] = “application/x-www-form-urlencoded”;
return wc.UploadString(strUrl,strPostData);
}
catch (WebException ex)
{
returnnew StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
}
}
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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: