Home
> Uncategorized > Managing #stripe disputes in #connected accounts
Managing #stripe disputes in #connected accounts
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;conststring strUrl = “https://api.stripe.com/v1/accounts?limit=100”;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;conststring strUrl = “https://api.stripe.com/v1/disputes?limit=100”;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 strUrl = “https://connect.stripe.com/oauth/deauthorize”;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();}}
Categories: Uncategorized
Comments (0)
Trackbacks (0)
Leave a comment
Trackback