Sample code for 30+ languages & platforms
Unicode C++ 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 Unicode C++ Downloads

Unicode C++
#include <CkHttpW.h>
#include <CkHttpResponseW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    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.
    CkHttpW http;
    http.put_AuthToken(L"SANDBOX_ACCESS_TOKEN");
    CkHttpResponseW resp;

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

    http.SetUrlVar(L"id",L"INVOICE_ID");
    CkJsonObjectW body;
    body.UpdateString(L"subject",L"Reminder: equipment inspection invoice");
    body.UpdateString(L"note",L"Our records show a balance due. Please use the payment link on your invoice.");
    body.UpdateBool(L"send_to_recipient",true);

    success = http.HttpJson(L"POST",L"https://api-m.sandbox.paypal.com/v2/invoicing/invoices/{$id}/remind",body,L"application/json",resp);
    if (success != true) {
        wprintf(L"No HTTP response: %s\n",http.lastErrorText());
        return;
    }

    if ((resp.get_StatusCode() < 200) || (resp.get_StatusCode() >= 300)) {
        CkJsonObjectW errorInfo;
        errorInfo.Load(resp.bodyStr());
        wprintf(L"HTTP %d %s %s\n",resp.get_StatusCode(),errorInfo.stringOf(L"name"),errorInfo.stringOf(L"details[0].issue"));
        wprintf(L"PayPal debug ID: %s\n",errorInfo.stringOf(L"debug_id"));
        return;
    }

    wprintf(L"Reminder accepted; HTTP %d\n",resp.get_StatusCode());
    }