Rust Requires Chilkat v11.0.0+
Rust
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 Rust Downloads
// 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.
let http = chilkat::Http::new();
http.set_auth_token("SANDBOX_ACCESS_TOKEN");
let resp = chilkat::HttpResponse::new();
let since = chilkat::DateTime::new();
let _ = since.set_from_current_system_time();
let _ = since.add_days(-30);
let query = chilkat::JsonObject::new();
let _ = query.update_string("update_time_after", &since.get_as_timestamp(false).unwrap_or_default());
let _ = query.update_int("page_size", 50);
let mut page = 1;
let mut more = true;
while more {
let _ = query.update_int("page", page);
if http.http_params("GET", "https://api-m.sandbox.paypal.com/v1/customer/disputes", &query, &resp).is_err() {
println!("No HTTP response: {}", http.last_error_text());
return;
}
if (resp.status_code() < 200) || (resp.status_code() >= 300) {
let error_info = chilkat::JsonObject::new();
let _ = error_info.load(&resp.body_str());
println!("HTTP {} {} {}", resp.status_code(), error_info.string_of("name").unwrap_or_default(), error_info.string_of("details[0].issue").unwrap_or_default());
println!("PayPal debug ID: {}", error_info.string_of("debug_id").unwrap_or_default());
return;
}
let result = chilkat::JsonObject::new();
if result.load(&resp.body_str()).is_err() {
println!("Expected a JSON response; HTTP {}", resp.status_code());
return;
}
let mut i = 0;
while i < result.size_of_array("items") {
result.set_i(i);
if result.string_of_equals("items[i].status", "WAITING_FOR_SELLER_RESPONSE", true) {
println!("{} {}", result.string_of("items[i].dispute_id").unwrap_or_default(), result.string_of("items[i].reason").unwrap_or_default());
if result.has_member("items[i].seller_response_due_date") {
println!("Respond by {}", result.string_of("items[i].seller_response_due_date").unwrap_or_default());
}
}
i = i + 1;
}
let mut has_next = false;
let mut link_index = 0;
while link_index < result.size_of_array("links") {
result.set_i(link_index);
if result.string_of_equals("links[i].rel", "next", true) {
has_next = true;
}
link_index = link_index + 1;
}
more = has_next;
page = page + 1;
}