誰能解釋我如何在 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); }誰能幫助我,了解缺少什么?
添加回答
舉報
0/150
提交
取消