AutoIt Requires Chilkat v11.0.0+
AutoIt
PayPal: Look up a checkout order
See more PayPal Examples
Read intent, order status and the amount requested for each purchase unit. A completed checkout order can contain payment resources with their own statuses; use their IDs to inspect individual captures or authorizations.
Chilkat AutoIt Downloads
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")
; Look up the order itself; its ID does not identify an individual capture.
$oHttp.SetUrlVar("id","ORDER_ID")
$bSuccess = $oHttp.HttpNoBody("GET","https://api-m.sandbox.paypal.com/v2/checkout/orders/{$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("Intent: " & $oResult.StringOf("intent") & @CRLF)
Local $i = 0
While ($i < $oResult.SizeOfArray("purchase_units"))
$oResult.I = $i
ConsoleWrite($oResult.StringOf("purchase_units[i].reference_id") & ": " & $oResult.StringOf("purchase_units[i].amount.value") & " " & $oResult.StringOf("purchase_units[i].amount.currency_code") & @CRLF)
$i = $i + 1
Wend