dongliu1883 2019-03-10 15:19
浏览 270

Paypal集成php身份验证失败

I am trying to integrate Paypal into my website, but when I go live and try to execute my payment after the client is validated I get the following transaction error:

name "AUTHENTICATION_FAILURE"
message "Authentication failed due to invalid authentication credentials or a missing Authorization header."

But it had work 2 times before and then not again.

Code to create transaction:

public function genererPaiement(Inscription $inscri) {


    $apiContext = Paiement::getContexte();

    $payer = new Payer();
    $payer->setPaymentMethod('paypal');

    $items = array();
    $items[0] = $inscri->getCircuit()->getItem();
    $i = 1;
    foreach ($inscri->getOptionInscris() as $option) {
        $items[$i] = $option->getItem();
        $i++;
    }

    $itemList = new ItemList();

    $total = 0;
    for ($j = 0; $j < $i; $j++) {
        $total += floatval($items[$j]->getPrice()) * intval($items[$j]->getQuantity());
        $itemList->addItem($items[$j]);
    }

    $amount = new Amount();
    $amount->setCurrency('EUR')
        ->setTotal($total);

    $transaction = new Transaction();
    $transaction->setAmount($amount);
    $transaction->setItemList($itemList)
        ->setDescription("Paiement route thermale cycliste.")
        ->setInvoiceNumber($this->course->getId());

    $baseURL = Paiement::getBaseURL();
    $redirectURL = new RedirectUrls();
    $redirectURL->setReturnUrl($baseURL.'/engagement/'.$this->course->getId().'/'.$inscri->getId().'/true')
        ->setCancelUrl($baseURL.'/engagement/'.$this->course->getId().'/'.$inscri->getId().'/false');

    $payement = new Payment();
    $payement->setIntent('sale')
        ->setPayer($payer)
        ->setRedirectUrls($redirectURL)
        ->setTransactions(array($transaction))
        ->create($apiContext);

    return $payement->getApprovalLink();

}

Code to execute:

public function payer($idEng, $idInscrit)
{
    $paymentId = $_GET['paymentId'];
    $apiContext = Paiement::getContexte();

    $payment = Payment::get($paymentId, $apiContext);

    $execution = new PaymentExecution();
    $execution->setPayerId($_GET['PayerID']);

    $result = $payment->execute($execution, $apiContext);

    $em = $this->getDoctrine()->getManager();
    $onglets = $em->getRepository(Onglets::class)->findOnglets();

    $eng = $em->getRepository(Engagement::class)->find($idEng);

    $page = $em->getRepository(Pages::class)->find(3);

    $inscri = $em->getRepository(Inscription::class)->find($idInscrit);

    $inscri->setPayer(true);

    return $this->render('engagement/index.html.twig', [
        "page" => $page,
        "onglets" => $onglets,
    ]);
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器