C# Requires Chilkat v11.0.0+
C#
PayPal: Find disputes awaiting a seller response
See more PayPal Examples
Scan cases updated in the past 30 days and page through the results. Show each case waiting on the seller and its response deadline when PayPal includes one in the summary.
Chilkat C# Downloads
bool success = false;
// See Unlock Chilkat before making requests.
// For the merchant's internal backoffice application. Load the sandbox token
// from the merchant's credential store. Keep it out of publicly distributed apps.
// See Get a PayPal access token.
Chilkat.Http http = new Chilkat.Http();
http.AuthToken = "SANDBOX_ACCESS_TOKEN";
Chilkat.HttpResponse resp = new Chilkat.HttpResponse();
Chilkat.CkDateTime since = new Chilkat.CkDateTime();
since.SetFromCurrentSystemTime();
since.AddDays(-30);
Chilkat.JsonObject query = new Chilkat.JsonObject();
query.UpdateString("update_time_after",since.GetAsTimestamp(false));
query.UpdateInt("page_size",50);
int page = 1;
bool more = true;
while ((more == true)) {
query.UpdateInt("page",page);
success = http.HttpParams("GET","https://api-m.sandbox.paypal.com/v1/customer/disputes",query,resp);
if (success != true) {
Debug.WriteLine("No HTTP response: " + http.LastErrorText);
return;
}
if ((resp.StatusCode < 200) || (resp.StatusCode >= 300)) {
Chilkat.JsonObject errorInfo = new Chilkat.JsonObject();
errorInfo.Load(resp.BodyStr);
Debug.WriteLine("HTTP " + Convert.ToString(resp.StatusCode) + " " + errorInfo.StringOf("name") + " " + errorInfo.StringOf("details[0].issue"));
Debug.WriteLine("PayPal debug ID: " + errorInfo.StringOf("debug_id"));
return;
}
Chilkat.JsonObject result = new Chilkat.JsonObject();
bool parsedResult = result.Load(resp.BodyStr);
if (parsedResult != true) {
Debug.WriteLine("Expected a JSON response; HTTP " + Convert.ToString(resp.StatusCode));
return;
}
int i = 0;
while ((i < result.SizeOfArray("items"))) {
result.I = i;
if (result.StringOfEquals("items[i].status","WAITING_FOR_SELLER_RESPONSE",true) == true) {
Debug.WriteLine(result.StringOf("items[i].dispute_id") + " " + result.StringOf("items[i].reason"));
if (result.HasMember("items[i].seller_response_due_date") == true) {
Debug.WriteLine("Respond by " + result.StringOf("items[i].seller_response_due_date"));
}
}
i = i + 1;
}
bool hasNext = false;
int linkIndex = 0;
while ((linkIndex < result.SizeOfArray("links"))) {
result.I = linkIndex;
if (result.StringOfEquals("links[i].rel","next",true) == true) {
hasNext = true;
}
linkIndex = linkIndex + 1;
}
more = hasNext;
page = page + 1;
}