Search the Community
Showing results for tags 'paypal'.
-
Olá a todos! Estou tentando sem sucesso consumir a API do PayPal, retorna o erro "HTTP/1.0 400 Bad Request" parece ser pacote mal formado, imagino que tenha alguma coisa (ou muita coisa errada) nos parâmetros que escrevi. Alguém teria algum exemplo de integração com PayPal ou pode me ajudar no código abaixo, hoje estamos tentando seguir a documentação fornecida pelo site do PayPal? //curl -v https://api.sandbox.paypal.com/v1/oauth2/token \ // -H "Accept: application/json" \ // -H "Accept-Language: en_US" \ // -u "client_id:secret" \ // -d "grant_type=client_credentials" //Retirado de: https://developer.paypal.com/docs/api/get-an-access-token-curl/ procedure TFPrincipal.Button3Click(Sender: TObject); var http: TIdHTTP; Handler: TIdSSLIOHandlerSocketOpenSSL; listaDeParametros : TStringStream; UrlConexao : string; slParameters : TStringStream; clienteID, secret : string; ResultadoEnvio : string; begin clienteID := '99999999999999999999999999999999999999999999999999999999999999999999999999999999'; secret := '88888888888888888888888888888888888888888888888888888888888888888888888888888888'; UrlConexao := 'https://api.sandbox.paypal.com/v1/oauth2/token'; Handler := TIdSSLIOHandlerSocketOpenSSL.create; Handler.SSLOptions.Method := sslvTLSv1_2; Handler.SSLOptions.Mode := sslmClient; http := TIdHTTP.Create(Application); http.Request.ContentType := 'application/x-www-form-urlencoded'; http.Request.Accept := 'application/json'; http.Request.AcceptLanguage := 'en_US'; http.Request.BasicAuthentication := true; http.Request.Username := clienteID; http.Request.Password := secret; http.IOHandler := Handler; slParameters := TStringStream.Create('grant_type=client_credentials'); try ResultadoEnvio := http.Post(urlconexao,slParameters ); ShowMessage(ResultadoEnvio); finally slParameters.Free; end; end; Desde já agradeço qualquer dica a respeito.