我在 laravel 5.4 中工作,当我尝试由 Braintree 文档提供的“fake_nonce”类型的字符串时,我的交易是成功的。但是当我尝试获取 paymentMethodNonce 时,它总是给我错误,比如找不到 nonce。有时会出现http错误!!!如果我尝试自己配置它!看看下面我的控制器功能
public function addOrder(Request $request){
$customer = Braintree_Customer::create([
'firstName' => $request->guest_name,
'email' => $request->guest_email,
'phone' => $request->guest_phone
]);
$customer->success;
$customer->customer->id;
$find = Braintree_Customer::find($customer->customer->id);
$nonceFromTheClient = Braintree_PaymentMethodNonce::find($find);
$result = Braintree_Transaction::sale([
'amount' => $request->subtotal,
'paymentMethodNonce' => $nonceFromTheClient,
'options' => [
'submitForSettlement' => True
]
]);
if ($result->success) {
$settledTransaction = $result->transaction;
} else {
print_r($result->errors);
}
Cart::destroy();
return view('guest/track', compact('result'));
}