locked
issues while integrate a PayPal Account RRS feed

  • Question

  • User944339287 posted

    Hi guys... I had some issues while integrating my PayPal Account in my Web Application (framework 4.0)

    Error Message:
    A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 173.0.82.78:80

    Below is the link I refer to:
    https://developer.paypal.com/docs/api/overview/

    My questions: 
    1) I have generated an access token from my PayPal account, but where do I include this to my code?

        Private Sub checkout()
    
            Dim EndpointUrl As String = "https://api.sandbox.paypal.com/v2/checkout/orders"
            Dim inputData As Object = New With { _
                                .intent = "CAPTURE", _
                                .purchase_units = New List(Of Object) From { _
                                    New With {
                                        .amount = New List(Of Object) From { _
                                            New With {
                                                .currency_code = "MYR", _
                                                .value = "100.00" _
                                                }
                                    }
                                }
                            }
            }
    
            Dim inputJson As String = (New JavaScriptSerializer()).Serialize(inputData)
    
            Dim httpRequest As HttpWebRequest = DirectCast(WebRequest.Create(New Uri(EndpointUrl)), HttpWebRequest)
            httpRequest.Accept = "application/json"
            httpRequest.ContentType = "application/json"
            httpRequest.Method = "POST"
    
            Dim bytes As Byte() = Encoding.UTF8.GetBytes(inputJson)
    
            Using stream As Stream = httpRequest.GetRequestStream()
                stream.Write(bytes, 0, bytes.Length)
                stream.Close()
            End Using
    
            Using httpResponse As HttpWebResponse = DirectCast(httpRequest.GetResponse(), HttpWebResponse)
    
                Using stream As Stream = httpResponse.GetResponseStream()
    
                    'Me.lbl_result.Text = (New StreamReader(stream)).ReadToEnd()
    
                    Try
                        Dim jsonString As String = (New StreamReader(stream)).ReadToEnd()
                        Dim jsonArray As JArray = CType(JsonConvert.DeserializeObject(jsonString), JArray)
    
                        For Each item In jsonArray
                            Response.Write(item("id"))
                            Response.Write(item("status"))
                        Next
    
                    Catch ex As WebException
                        Response.Write(ex.Message)
                    End Try
    
                End Using
    
            End Using
    
        End Sub

    Friday, October 9, 2020 9:14 AM

All replies

  • User1535942433 posted

    Hi kengkit,

    A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 173.0.82.78:80

    Could you post more details of your errors?You could check error logs.It exists many possibilities.

    1.You could check firewall settings on server to enable a blocked port.

    2.Check  whether IP white listing is required.

    3.Antivirus might be blocking the request.

    4.If no luck, install Advanced REST Client tool on Chrome and manually test the request.

    More details,you could refer to below article:

    https://docs.microsoft.com/en-us/aspnet/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/checkout-and-payment-with-paypal

    Best regards,

    Yijing Sun

    Monday, October 12, 2020 2:45 AM
  • User944339287 posted

    Hi.. trying your suggestion 4. hopefully can solve it asap

    Friday, October 23, 2020 5:58 AM