PHP (Laravel) - Authorization Error result when using Payouts

moxiefitness
Contributor
Contributor

 

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.

 

Login to Me Too
1 REPLY 1

Colin563
Contributor
Contributor

I had same problem can you please help me out, in fixing this, how can enable my app to use PayOut API?

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.