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

PayPal: Add shipment tracking to a captured order

See more PayPal Examples

Use the order ID in the URL and the capture ID for this shipment in the body. Send the carrier and tracking number from your shipping record. Set notify_payer according to how your business sends shipping notices.

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')

*  Replace both PayPal IDs and the sample tracking number with values from the same
*  shipped order.
loHttp.SetUrlVar("id","ORDER_ID")
loBody = CreateObject('Chilkat.JsonObject')
loBody.UpdateString("capture_id","CAPTUREID")
loBody.UpdateString("tracking_number","1Z999AA10123456784")
loBody.UpdateString("carrier","UPS")
loBody.UpdateBool("notify_payer",0)

lnSuccess = loHttp.HttpJson("POST","https://api-m.sandbox.paypal.com/v2/checkout/orders/{$id}/track",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

? "PayPal accepted tracking for this order. HTTP " + STR(loResp.StatusCode)

RELEASE loHttp
RELEASE loResp
RELEASE loBody
RELEASE loErrorInfo