我有一个网络应用程序,当用户达到某个级别时会向其发送付款 那是处理单笔付款的班级:
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');
}
}
当我尝试付款时:
try{
$output = $payouts->createSynchronous($apiContext, null);
$logger->error(var_export($output, true));
}catch (Exception $ex){
$logger->error($ex->getMessage());
}
我总是得到403 AUTORIZHATION但一个月前一切都很棒!
所以我无法理解问题是什么......我已经在paypal文档中使用php示例代码进行了检查,它就像我的代码一样。
我在我的应用程序中使用symfony框架。 我没有任何问题得到付款,但我无法汇款。
我也尝试升级所有Bundles和symfony本身,但nothink已经改变,同样的问题。 这是贝宝的错误日志:
[25-10-2016 11:21:08] PayPal \ Core \ PayPalHttpConnection:INFO:响应状态:403 [25-10-2016 11:21:08] PayPal \ Core \ PayPalHttpConnection:错误:访问https://api.paypal.com/v1/payments/payouts?sync_mode=true时得到Http响应代码403。 {" name":" AUTHORIZATION_ERROR"," message":"发生了授权错误"," debug_id":&# 34; 3676075eac96e"" information_link":" https://developer.paypal.com/docs/api/payments.payouts-batch/#errors"}
答案 0 :(得分:0)
如果您的凭据有问题,PayPal API的403响应总是如此。您是否检查所需的PayPal帐户是否仍处于活动状态?你的客户ID和秘密ID仍然是合法的吗?