cancel
Showing results for 
Search instead for 
Did you mean: 

PHP (Laravel) - Authorization Error result when using Payouts

SOLVED
Highlighted

PHP (Laravel) - Authorization Error result when using Payouts

 

I'm trying to use the PayPal Payouts with a sandbox app.

 

Using postman-

1. I get the access_token from https://api.sandbox.paypal.com/v1/oauth2/token using client_id & client secrete

2. Attempt to make a payout posting https://api.sandbox.paypal.com/v1/payments/payouts

  Datatype is json

 

 {
    "sender_batch_header": {
        "sender_batch_id": "5a7a72af05adc",
        "email_subject": "Payout test"
    },
    "items": [
        {
            "recipient_type": "EMAIL",
            "note": "Thank you!",
            "receiver": "--some email not allowed--",
            "sender_item_id": "20180206001",
            "amount": {
                "value": "3.40",
                "currency": "USD"
            }
        }
    ]
}

 

 

Response :

 

{
    "name": "AUTHORIZATION_ERROR",
    "debug_id": "8fece29112011",
    "message": "Authorization error occurred.",
    "information_link": "https://developer.paypal.com/docs/api/payments.payouts-batch/#errors"
}

 

 

Same thing happens when I do it in Laravel :

 

        $payout = new Payout();
        $sender_batch_header = new PayoutSenderBatchHeader();
        $sender_item = new PayoutItem();

        // Payout amount
        $amount = new Currency();
        $amount->setValue('3.4');
        $amount->setCurrency('USD');

        // Set batch header
        $sender_batch_header->setSenderBatchId(uniqid())
            ->setEmailSubject('Payout test');


        // Set the item
        $sender_item->setRecipientType('EMAIL')
            ->setNote('Thank you ')
            ->setReceiver($request['email'])
            ->setSenderItemId('20180206001')
            ->setAmount($amount);

        // Set up the payout
        $payout->setSenderBatchHeader($sender_batch_header)
            ->addItem($sender_item);


        $request = clone $payout;

        try {
            $output = $payout->create( null, $this->apiContext);
            return $output;
        } catch (PayPalConnectionException $ex) {
            return $ex->getData();
        }

And the exception data is: 

 {"name":"AUTHORIZATION_ERROR","debug_id":"7bb53dcdde651","message":"Authorization error occurred.","information_link":"https://developer.paypal.com/docs/api/payments.payouts-batch/#errors"}

 

I have made sure that Payouts is enabled in the sandbox application, and the email accounts I'm using exist in the sandbox accounts as well.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

Re: PHP (Laravel) - Authorization Error result when using Payouts

Hi, from the CAL id in your logs I see that the API caller account in Sandbox was not enabled for Payouts and also the account was not verified. I did both, try now and let me know, should work fine.

3 REPLIES
Moderator

Re: PHP (Laravel) - Authorization Error result when using Payouts

Hi, from the CAL id in your logs I see that the API caller account in Sandbox was not enabled for Payouts and also the account was not verified. I did both, try now and let me know, should work fine.

Re: PHP (Laravel) - Authorization Error result when using Payouts

Thank you, it's working great now! 

 

Just for future reference, I found how to enable the sandbox app now. Does the destination account need to be verified? I thought test accounts are automatically verified.

 

Thank you!

Moderator

Re: PHP (Laravel) - Authorization Error result when using Payouts

Happy it now works. In Sandbox, test accounts, while creating the account if you select YES on "Bank Verified Account" then your test account will be verified. Better to create a verified test account as you will be sure that the payout is received.