0

I'm working in laravel 5.4 My transactions are successfull when I try a 'fake_nonce' type of string provided by the braintree docs. But when I tried to get the paymentMethodNonce it always gives me error like nonce not found. And sometimes http error!!! If I try to configure it by myself! Take a look at my controller function below

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'));
}
Danish Tahir
  • 107
  • 11

1 Answers1

0

$nonceFromTheClient = Braintree_PaymentMethodNonce::find($find);

Your using the wrong nonce, this nonce must come from the DropIn ui and not be generated on your code.

Please check the onPaymentMethodReceived() method provided in the JS SDK.

Please check this reference

Reyan Tropia
  • 140
  • 1
  • 10