Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

654
Views
Paypal PHP SDK: PayPalConnectionException: Código de respuesta 401

Hola he estado trabajando con paypal php sdk .

Recibo el siguiente error al intentar crear un pago

PayPalConnectionException
Obtuve el código de respuesta Http 401 al acceder a https://api.sandbox.paypal.com/v1/oauth2/token .

Estoy seguro de que los valores de $clientId y $clientSecret son correctos.

Ejecutándose en modo sandbox , aún en fase de desarrollo.

¿Se ha topado alguien con esto?

Mi código (sin información privada)

 use PayPal\Api\Amount; use PayPal\Api\Item; use PayPal\Api\ItemList; use PayPal\Api\Payer; use PayPal\Api\PayerInfo; use PayPal\Api\Payment; use PayPal\Api\RedirectUrls; use PayPal\Api\Transaction as PayPalTransaction; use PayPal\Auth\OAuthTokenCredential; use PayPal\Exception\PayPalConnectionException; use PayPal\Rest\ApiContext; //$transaction represents a Transaction object stored in database //$product represents a Product object stored in database $payer = (new Payer()) ->setPaymentMethod('paypal') ; $itemList = new ItemList(); $itemList->addItem( (new Item) ->setName($product->getName()) ->setDescription($product->getName()) ->setSku($product->getSku()) ); $amount = (new Amount()) ->setCurrency($transaction->getCurrency()) ->setTotal($transaction->getTotal()) ; $ppTransaction = (new PayPalTransaction()) ->setItemList($itemList) ->setAmount($amount) ->setReferenceId($transaction->getId()) ; $redirectUrls = (new RedirectUrls()) ->setReturnUrl('http://.../S') ->setCancelUrl('http://.../F') ; $apiContext = new ApiContext( new OAuthTokenCredential( $clientId, $clientSecret ) ); $payment = (new Payment()) ->setIntent('sale') ->setPayer($payer) ->setRedirectUrls($redirectUrls) ->setTransactions([$ppTransaction]) ; $payment->create($apiContext); return $payment->getId();

Un volcado de la solicitud curl de paypal subyacente es el siguiente:

 [ "url" => "https://api.sandbox.paypal.com/v1/oauth2/token" "method" => "POST" "headers" => array:3 [ 0 => "User-Agent: PayPalSDK/PayPal-PHP-SDK 1.11.0 (platform-ver=7.0.7; bit=64; os=Linux_4.4.57-18.3-default; machine=x86_64; crypto-lib-ver=1.0.2j-fips; curl=7.37.0)" 1 => "Authorization: Basic xxx=" 2 => "Accept: */*" ] "data" => "grant_type=client_credentials" ]
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

este problema podría (probablemente) no estar relacionado con el SDK como tal.

El código de error 401, indica " errores de autenticación ".

Como esto es difícil de depurar, puede verificar lo siguiente:

  1. ¿Tiene su cuenta elegibilidad para una función específica? Intente verificar el estado de su cuenta y el soporte de moneda/país

  2. ¿Puedes ejecutar una prueba directa a través de curl?

curl -v -u "client_id:secret" "https://api.sandbox.paypal.com/v1/oauth2/token" -X POST -d "response_type=token&grant_type=client_credentials"

  1. Verifique los archivos de configuración de su SDK, no asuma que las configuraciones predeterminadas están bien; verifique si hay posibles culpables allí

  2. ¿Y están seguros de que han configurado correctamente el SDK en modo "sandbox" en lugar de en vivo (que podría ser el predeterminado)? Consulte: https://github.com/paypal/PayPal-PHP-SDK/wiki/Going-Live

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!