Am using flutterwave as my payment gateway, I want to save an order whenever customer finish making payment. But I can't get pass this error. I don't know what am missing. Thanks for your help. Here is my code.
public function initialize(Request $request)
{
//This initializes payment and redirects to the payment gateway
//The initialize method takes the parameter of the redirect URL
Rave::initialize(route('callback'));
}
When I dd($request->all()) in this initialize method I got all my data.
public function callback(Request $request)
{
// $data = Rave::verifyTransaction(request()->txref);
$resp = $request->resp;
$body = json_decode($resp, true);
$txRef = $body['data']['data']['txRef'];
$data = Rave::verifyTransaction($txRef);
// Insert into orders table
$order = Order::create([
'user_id' => auth()->user() ? auth()->user()->id : null,
'billing_email' => $request->email,
'billing_first_name' => $request->first_name,
'billing_last_name' => $request->last_name,
'billing_address' => $request->address,
'billing_city' => $request->city,
'billing_town' => $request->town,
'billing_postalcode' => $request->postalcode,
'billing_phone' => $request->phone,
'billing_total' => Cart::getTotal(),
'error' => null,
]);
foreach (Cart::getContent() as $item)
{
OrderProduct::create([
'order_id' => $order->id,
'product_id' => $item->model->id,
'quantity' => $item->quantity,
]);
}
}
}
But in this callback method I got null when I dd($data).
And this is my view.
<form method="POST" action="">
@csrf
<div class="form-group">
<label for="email">Email Address</label>
<input type="email" placeholder="Email address" name="email" class="form-control">
</div>
<div class="form-group">
<label for="address">Address</label>
<input type="text" placeholder="Delivery Address" name="address" class="form-control">
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="first_name">First Name</label>
<input type="text" placeholder="First Name" name="first_name" class="form-control">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="second_name">Second Name</label>
<input type="text" placeholder="Second Name" name="last_name" class="form-control">
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="city">City</label>
<input type="text" placeholder="City" name="city" class="form-control">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="town">Town</label>
<input type="text" placeholder="Town" name="town" class="form-control">
</div>
<div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="code">Postal\Zip Code</label>
<input type="text" placeholder="Postal or zip code" name="postalcode" class="form-control">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="phone">Phone</label>
<input type="text" placeholder="Phone number" name="phone" class="form-control">
<div>
</div>
</div>
<input type="hidden" name="currency" value="NGN" />
<input type="hidden" name="country" value="NG" />
<input type="hidden" name="amount" value="" />
<input class="btn btn-success" type="submit" value="Proceed to buy" />
</form>
I don't know what am missing.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire