猿问

Braintree 中的托管字段给出错误“无法确定付款方式”PHP Laravel

谁能解释我如何在 Laravel 中使用托管字段进行有效的 Braintree 付款。我试图自己查看文档,但无法使其正常工作。


我在控制器中创建了要发送到视图的令牌,例如:


$gateway = new \Braintree\Gateway([

            'environment' => config('services.braintree.environment'),

            'merchantId' => config('services.braintree.merchantId'),

            'publicKey' => config('services.braintree.publicKey'),

            'privateKey' => config('services.braintree.privateKey')

        ]);

$paypalToken = $gateway->ClientToken()->generate();


return view('checkout')->with(['paypalToken' => $paypalToken]);

这是我处理付款的方法:


        $gateway = new \Braintree\Gateway([

            'environment' => config('services.braintree.environment'),

            'merchantId' => config('services.braintree.merchantId'),

            'publicKey' => config('services.braintree.publicKey'),

            'privateKey' => config('services.braintree.privateKey')

        ]);

        $nonce = $request->payment_method_nonce;


        $result = $gateway->transaction()->sale([

            'amount' => round(getNumbers()->get('newTotal') / 100, 2),

            'paymentMethodNonce' => $nonce,

            'options' => [

              'submitForSettlement' => True

            ]

          ]);



        if ($result->success) {

            $transaction = $result->transaction;

            $order = $this->addToOrdersTablesPaypal(

                $email,

                $firstName.' '.$lastName,

                null

            );


            return redirect()->route('confirmation.index')->with('success_message', 'Thank you! Your payment has been successfully accepted!');

        } else {

            $order = $this->addToOrdersTablesPaypal(

                $email,

                $firstName.' '.$firstName,

                $result->message

            );


            return back()->withErrors('An error occurred with the message: '.$result->message);

        }

谁能帮助我,了解缺少什么?


噜噜哒
浏览 132回答 1
1回答

牧羊人nacy

我解决了它,我实际上找到了一种解决方法,我必须为托管字段创建一个控制器,并且它有效。
随时随地看视频慕课网APP
我要回答