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

PayPal: Get capture details

See more PayPal Examples

Use a capture ID to distinguish a completed capture from one still pending or subsequently refunded. An order can have multiple captures.

PayPal documentation

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = 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.
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.AuthToken = "SANDBOX_ACCESS_TOKEN"
$oResp = ObjCreate("Chilkat.HttpResponse")

;  Read the status on the capture itself before treating it as settled.

$oHttp.SetUrlVar("id","CAPTURE_ID")

$bSuccess = $oHttp.HttpNoBody("GET","https://api-m.sandbox.paypal.com/v2/payments/captures/{$id}",$oResp)
If ($bSuccess <> True) Then
    ConsoleWrite("No HTTP response: " & $oHttp.LastErrorText & @CRLF)
    Exit
EndIf

If (($oResp.StatusCode < 200) Or ($oResp.StatusCode >= 300)) Then
    $oErrorInfo = ObjCreate("Chilkat.JsonObject")
    $oErrorInfo.Load($oResp.BodyStr)
    ConsoleWrite("HTTP " & $oResp.StatusCode & " " & $oErrorInfo.StringOf("name") & " " & $oErrorInfo.StringOf("details[0].issue") & @CRLF)
    ConsoleWrite("PayPal debug ID: " & $oErrorInfo.StringOf("debug_id") & @CRLF)
    Exit
EndIf

$oResult = ObjCreate("Chilkat.JsonObject")
Local $bParsed = $oResult.Load($oResp.BodyStr)
If ($bParsed <> True) Then
    ConsoleWrite("Expected a JSON response; HTTP " & $oResp.StatusCode & @CRLF)
    Exit
EndIf

ConsoleWrite("ID: " & $oResult.StringOf("id") & @CRLF)
ConsoleWrite("Status: " & $oResult.StringOf("status") & @CRLF)
ConsoleWrite("Amount: " & $oResult.StringOf("amount.value") & @CRLF)
ConsoleWrite("Currency: " & $oResult.StringOf("amount.currency_code") & @CRLF)