Data not saved in database.This is Stripe Api, Code is below How can I save in database through stripe API? If data saved in database than it is correct way to collect payment? Stripe Api payment secure?
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\PaymentLogs;
class PaymentController extends Controller
{
//
public function __construct()
{
//$this->middleware('auth'); // if you want user to be logged in to use this function then uncomment this code.
}
public function handleonlinepay(Request $request){
$input = $request->input();
try {
\Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
// Insert into the database
PaymentLogs::create([
'amount'=> $input['amount'],
'plan'=> $input['plan'],
'charge_id'=>$charge->id,
'stripe_id'=>$unique_id,
'quantity'=>1
]);
return response()->json([
'message' => 'Charge successful, Thank you for payment!',
'state' => 'success'
]);
} catch (\Exception $ex) {
return response()->json([
'message' => 'There were some issue with the payment. Please try again later.',
'state' => 'error'
]);
}
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire