VB.NET Requires Chilkat v11.0.0+
VB.NET
PayPal: Void an unused authorization
See more PayPal Examples
Release an unused hold with the authorization ID. A fully captured authorization cannot be voided; refund its capture instead. A successful void can have an empty response body.
Chilkat VB.NET Downloads
Dim success As Boolean = 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.
Dim http As New Chilkat.Http
http.AuthToken = "SANDBOX_ACCESS_TOKEN"
Dim resp As New Chilkat.HttpResponse
' Use the original authorization ID to release the hold; do not send an amount.
http.SetUrlVar("id","AUTHORIZATION_ID")
' Create and persist this key once per business operation. On a timeout,
' retry the same request with its saved key, not a newly generated one.
Dim crypt As New Chilkat.Crypt2
Dim requestId As String = crypt.GenerateUuid()
http.SetRequestHeader("PayPal-Request-Id",requestId)
success = http.HttpNoBody("POST","https://api-m.sandbox.paypal.com/v2/payments/authorizations/{$id}/void",resp)
If (success <> True) Then
Debug.WriteLine("No HTTP response: " & http.LastErrorText)
Exit Sub
End If
If ((resp.StatusCode < 200) Or (resp.StatusCode >= 300)) Then
Dim errorInfo As New Chilkat.JsonObject
errorInfo.Load(resp.BodyStr)
Debug.WriteLine("HTTP " & resp.StatusCode & " " & errorInfo.StringOf("name") & " " & errorInfo.StringOf("details[0].issue"))
Debug.WriteLine("PayPal debug ID: " & errorInfo.StringOf("debug_id"))
Exit Sub
End If
Debug.WriteLine("Authorization void accepted; HTTP " & resp.StatusCode)