【发布时间】:2017-03-07 20:55:04
【问题描述】:
我有一个网络应用程序,当用户达到某个级别时,它会向用户发送付款 那就是处理单次支付的类:
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 但一个月前一切正常!
所以我不明白有什么问题...我已经检查了贝宝文档上的 php 示例代码,它和我的代码一样没问题。
我在我的应用程序中使用 symfony 框架。 我收到付款没有任何问题,但我无法汇款。
我也尝试升级所有 Bundles 和 symfony 本身,但 nothink 已经改变,同样的问题。 这是贝宝的错误日志:
[25-10-2016 11:21:08] PayPal\Core\PayPalHttpConnection:信息:响应状态: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":"3676075eac96e","information_link":"https://developer.paypal.com/docs/api/payments.payouts-batch/#errors"}
【问题讨论】:
标签: php symfony paypal paypal-rest-sdk