Sample code for 30+ languages & platforms
Rust Requires Chilkat v11.0.0+

PayPal: Remind a customer about an unpaid invoice

See more PayPal Examples

Send a reminder about an outstanding invoice using a short subject and note. PayPal uses the invoice recipient; no new invoice or charge is created.

PayPal documentation

Chilkat Rust Downloads

Rust

// 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();

// Use the ID of the outstanding invoice. PayPal finds the recipient from that invoice.

let _ = http.set_url_var("id", "INVOICE_ID");
let body = chilkat::JsonObject::new();
let _ = body.update_string("subject", "Reminder: equipment inspection invoice");
let _ = body.update_string("note", "Our records show a balance due. Please use the payment link on your invoice.");
let _ = body.update_bool("send_to_recipient", true);

if http.http_json("POST", "https://api-m.sandbox.paypal.com/v2/invoicing/invoices/{$id}/remind", &body, "application/json", &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;
}

println!("Reminder accepted; HTTP {}", resp.status_code());