Got Http response code 403 when accessing https://api...

aghost1
Contributor
Contributor

Hello,

 

I'm using the PayPal SDK lib for PHP and trying to integrate payouts in our system.

I've checked that my sandbox environment and app has enabled payouts but when i try to make a payout following this example I only get the error message "Got Http response code 403 when accessing https://api.sandbox.paypal.com/v1/payments/payouts?sync_mode=true".

 

So I don't know why i get error code 403 forbidden, because I don't get any more information and the settings looks correct. Has anyone else had this issue?

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

MTS_Andre
Moderator
Moderator

Hi, I see, unfortunately the sync_mode is deprecated as in our guide at this link

If you try without the sync_mode it will work

View solution in original post

Login to Me Too
4 REPLIES 4
Solved

MTS_Andre
Moderator
Moderator

Hi, I see, unfortunately the sync_mode is deprecated as in our guide at this link

If you try without the sync_mode it will work

Login to Me Too

aghost1
Contributor
Contributor

Thanks for the info, but in that case it seems the SDK need an update for payouts. Had to change the source code of the PHP SDK in order to remove the sync mode param and even then i still got response code 400. Solved it with writing a custom curl request instead of using the SDK. So if anyone else has this issue in the future following the example, instead of executing  $payout->createSynchronois($apiContext);  use curl example below.

$s = curl_init("https://api.sandbox.paypal.com/v1/payments/payouts");

curl_setopt($s, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payouts");
curl_setopt($s, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $apiContext->getCredential()->getAccessToken(array())));
curl_setopt($s,CURLOPT_POST,true);
curl_setopt($s, CURLOPT_POSTFIELDS, $payout->toJSON());

$result = curl_exec($s);
curl_close($s);

 

Login to Me Too

aghost1
Contributor
Contributor

Actually it worked when i changed the source code to ignore sync_mode, but i still couldnt see what the error (400 this time), which turned out to be unsupported currency error

Login to Me Too

harrisonsmith
Contributor
Contributor

Where did you turn this off? Which file, or what code? 

 

I also tried using the CURL example above:

 

global $apiContext;
$s = curl_init("https://api.sandbox.paypal.com/v1/payments/payouts");
curl_setopt($s, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payouts");
curl_setopt($s, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $apiContext->getCredential()->getAccessToken(array())));
curl_setopt($s,CURLOPT_POST,true);
curl_setopt($s, CURLOPT_POSTFIELDS, $payouts->toJSON([
    'batch_header' => [
        'sender_batch_header' => [
            'email_subject' => 'You\'ve been paid by XXXX';
        ]
    ],
    'payout_item' => [
        'recipient_type' => 'EMAIL',
        'amount' => [
            'value' => '1.00',
            'currency' => 'USD',
        ],
        'note' => 'XXX',
        'receiver' => 'email'
    ]
]));
$result = curl_exec($s);
curl_close($s);

What am I doing wrong?

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.