Paypal Payout SDK AUTHORIZATION_ERROR In Live Environment

605 Views Asked by At

I've set up the Paypal Payout SDK With Composer.

Paypal assured me that the Payouts-Feature is enabled for my account. I've created a new Live Rest-App and used the Client-ID and the Client-Secret in the PayPalClient Class:

<?php
namespace PaypalPayoutsSDK\Payouts;
use PaypalPayoutsSDK\Core\PayPalHttpClient;
use PaypalPayoutsSDK\Core\ProductionEnvironment;
class PayPalClient {
    public static function client() {
        return new PayPalHttpClient(self::environment());
    }
    public static function environment() {
        $clientId = getenv("CLIENT_ID") ?: "my-client-id";
        $clientSecret = getenv("CLIENT_SECRET") ?: "my-client-secret";
        return new ProductionEnvironment($clientId, $clientSecret);
    }
}
?>

Now I want to make a simple transaction. I've used the samples included with the PayPal Payout SDK an created a payout using the PayPalClient mentionned above:

<?php
require __DIR__ . '/vendor/autoload.php';
use PaypalPayoutsSDK\Payouts\PayPalClient;
use PaypalPayoutsSDK\Payouts\PayoutsPostRequest;
$request = new PayoutsPostRequest();
$body= json_decode(
            '{
                "sender_batch_header":
                {
                  "email_subject": "SDK payouts test txn"
                },
                "items": [
                {
                  "recipient_type": "EMAIL",
                  "receiver": "[email protected]",
                  "note": "Your 4$ payout",
                  "sender_item_id": "Test_txn_12",
                  "amount":
                  {
                    "currency": "USD",
                    "value": "4.00"
                  }
                }]
              }',             
            true);
$request->body = $body;
$client = PayPalClient::client();
$response = $client->execute($request);
?>

However when I execute the file I get the following errors:

Fatal error: Uncaught PayPalHttp\HttpException: {"name":"AUTHORIZATION_ERROR","message":"Authorization error occurred.","debug_id":"d3c2fe720217b","information_link":"https://developer.paypal.com/docs/api/payments.payouts-batch/#errors","links":[]} in /hermes/bosnaweb27a/b1507/dom.mydomain/mydomain/payment/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php:215 Stack trace: #0 /hermes/bosnaweb27a/b1507/dom.mydomain/mydomain/payment/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php(100): PayPalHttp\HttpClient->parseResponse(Object(PayPalHttp\Curl)) #1 /hermes/bosnaweb27a/b1507/dom.mydomain/mydomain/payment/payuser.php(37): PayPalHttp\HttpClient->execute(Object(PaypalPayoutsSDK\Payouts\PayoutsPostRequest)) #2 {main} thrown in /hermes/bosnaweb27a/b1507/dom.mydomain/mydomain/payment/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php on line 215  

The error seems to occur with the HTTPClient. I've already provided the Technical Assistant of Paypal with the same information but he didn't seem to know anything.

What could be the problem here. I'm sure the Client-ID and the Client-Secret are correct, I've already tried to do it with a new REST-APP. Perhaps there's something wrong with my code? Or am I just missing something?

1

There are 1 best solutions below

1
On BEST ANSWER

Your PayPal account will need to be 'Verified' in order to send Payouts. Try adding and confirming a Bank account, or contact PayPal for other possibilities.