Visual FoxPro Requires Chilkat v11.0.0+
Visual FoxPro
PayPal: Get refund details
See more PayPal Examples
Use the refund ID returned by the capture refund operation. A pending refund is not final. Preserve the refund ID separately from the capture ID.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loHttp
LOCAL loResp
LOCAL loErrorInfo
LOCAL loResult
LOCAL lnParsed
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')
* The refund operation returns a new ID. It differs from both the capture and the
* order ID.
loHttp.SetUrlVar("id","REFUND_ID")
lnSuccess = loHttp.HttpNoBody("GET","https://api-m.sandbox.paypal.com/v2/payments/refunds/{$id}",loResp)
IF (lnSuccess <> 1) THEN
? "No HTTP response: " + loHttp.LastErrorText
RELEASE loHttp
RELEASE loResp
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 loErrorInfo
CANCEL
ENDIF
loResult = CreateObject('Chilkat.JsonObject')
lnParsed = loResult.Load(loResp.BodyStr)
IF (lnParsed <> 1) THEN
? "Expected a JSON response; HTTP " + STR(loResp.StatusCode)
RELEASE loHttp
RELEASE loResp
RELEASE loErrorInfo
RELEASE loResult
CANCEL
ENDIF
? "ID: " + loResult.StringOf("id")
? "Status: " + loResult.StringOf("status")
? "Amount: " + loResult.StringOf("amount.value")
? "Currency: " + loResult.StringOf("amount.currency_code")
RELEASE loHttp
RELEASE loResp
RELEASE loErrorInfo
RELEASE loResult