问题描述:

I have a web application that send payment to the user when they reach some level

That's the class that handle a single payment:

public function pagaSingoloAction(Request $request, $id_richiesta)

{

$richiesta_pagamento = $this->getDoctrine()->getRepository("AppBundle:RichiestaPagamento")->find($id_richiesta);

if ($richiesta_pagamento)

{

$logger = $this->get('logger');

$em = $this->getDoctrine()->getManager();

$tassa = $this->get('application.settings')->ritornaImpostazioneDaNome("percentuale_tasse_pagamenti_richieste");

if (!$tassa)

$tassa = 0;

$totale_richiesta_aggiornato = $richiesta_pagamento->getTotale();

$totale_tassa_decurtata_network = 0;

if ($tassa != 0)

{

$totale_tassa_decurtata_network = (($tassa / 100) * $totale_richiesta_aggiornato);

$totale_richiesta_aggiornato = $totale_richiesta_aggiornato - $totale_tassa_decurtata_network;

}

$imp = new ImpostazioniApplicazione($this->getDoctrine());

$apiContext = new ApiContext(new OAuthTokenCredential(

$imp->getPaypalAppId(),

$imp->getPaypalAppSecret()

));

$apiContext->setConfig(array(

'mode' => $this->getParameter('paypal_mode'),

'log.LogEnabled' => true,

'log.FileName' => 'PayPal.log',

'log.LogLevel' => 'FINE'

));

$logger->info("SETTATA CONFIGURAZIONE API CONTEXT");

$payouts = new Payout();

$sender_batch_header = new PayoutSenderBatchHeader();

$sender_batch_header->setSenderBatchId(uniqid())

->setEmailSubject("New payment from request!");

$sender_item = new PayoutItem();

$sender_item->setRecipientType('EMAIL')

->setNote("Payment request n. " . $richiesta_pagamento->getId())

->setReceiver($richiesta_pagamento->getEmailPaypal())

->setSenderItemId(uniqid())

->setAmount(new Currency('{

"value" : "'. $totale_richiesta_aggiornato .'",

"currency" : "EUR"

}'));

$payouts->setSenderBatchHeader($sender_batch_header)

->addItem($sender_item);

$output = "";

try{

$output = $payouts->createSynchronous($apiContext, null);

$logger->error(var_export($output, true));

}catch (Exception $ex){

$logger->error($ex->getMessage());

}

$payout_item = $output->getItems()[0];

if ($payout_item->getTransactionStatus() == "SUCCESS")

{

//ITS ALL OK

}

return $this->render('pagamento_singolo_richiesta/singolo_pagamento_dettagli.html.twig', array(

'pagamento' => $pagamento_singolo,

));

}

else{

return $this->render('pagamento_singolo_richiesta/pagamento_errore.html.twig');

}

}

When i try to make payment:

try{

$output = $payouts->createSynchronous($apiContext, null);

$logger->error(var_export($output, true));

}catch (Exception $ex){

$logger->error($ex->getMessage());

}

I always get 403 AUTORIZHATION but a month ago all works great!

So i can't understand what's the problem... I have checked with php sample code on paypal documentation and it's all ok like my code.

I use symfony framework in my application.

I get payment without any problem but i can't send money.

I have also tried to upgrade all Bundles and symfony itself but nothink has changed, same problem.

That's the paypal error log:

[25-10-2016 11:21:08] PayPal\Core\PayPalHttpConnection : INFO: Response Status : 403

[25-10-2016 11:21:08] PayPal\Core\PayPalHttpConnection : ERROR: Got Http response code 403 when accessing https://api.paypal.com/v1/payments/payouts?sync_mode=true. {"name":"AUTHORIZATION_ERROR","message":"Authorization error occurred","debug_id":"3676075eac96e","information_link":"https://developer.paypal.com/docs/api/payments.payouts-batch/#errors"}

网友答案:

The 403-response from PayPal API is always if there is something wrong with your credentials. Have you check if the desired PayPal-account is still active? And your client ID en secret ID are still legit?

相关阅读:
Top