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

Visual FoxPro
LOCAL lnSuccess
LOCAL loHttp
LOCAL loResp
LOCAL loBody
LOCAL loErrorInfo

lnSuccess = 0

*  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.
loHttp = CreateObject('Chilkat.Http')
loHttp.AuthToken = "SANDBOX_ACCESS_TOKEN"
loResp = CreateObject('Chilkat.HttpResponse')

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

loHttp.SetUrlVar("id","INVOICE_ID")
loBody = CreateObject('Chilkat.JsonObject')
loBody.UpdateString("subject","Reminder: equipment inspection invoice")
loBody.UpdateString("note","Our records show a balance due. Please use the payment link on your invoice.")
loBody.UpdateBool("send_to_recipient",1)

lnSuccess = loHttp.HttpJson("POST","https://api-m.sandbox.paypal.com/v2/invoicing/invoices/{$id}/remind",loBody,"application/json",loResp)
IF (lnSuccess <> 1) THEN
    ? "No HTTP response: " + loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loResp
    RELEASE loBody
    CANCEL
ENDIF

IF ((loResp.StatusCode < 200) OR (loResp.StatusCode >= 300)) THEN
    loErrorInfo = CreateObject('Chilkat.JsonObject')
    loErrorInfo.Load(loResp.BodyStr)
    ? "HTTP " + STR(loResp.StatusCode) + " " + loErrorInfo.StringOf("name") + " " + loErrorInfo.StringOf("details[0].issue")
    ? "PayPal debug ID: " + loErrorInfo.StringOf("debug_id")
    RELEASE loHttp
    RELEASE loResp
    RELEASE loBody
    RELEASE loErrorInfo
    CANCEL
ENDIF

? "Reminder accepted; HTTP " + STR(loResp.StatusCode)

RELEASE loHttp
RELEASE loResp
RELEASE loBody
RELEASE loErrorInfo