feat: modified db payment table

This commit is contained in:
IceToast 2021-12-15 11:41:57 +01:00
parent 1d72bac7fa
commit 34a8d566a7
5 changed files with 603 additions and 25 deletions

View file

@ -177,7 +177,7 @@ class PaymentController extends Controller
$payment = Payment::create([
'user_id' => $user->id,
'payment_id' => $response->result->id,
'payer_id' => $laravelRequest->input('PayerID'),
'payment_method' => 'paypal',
'type' => 'Credits',
'status' => $response->result->status,
'amount' => $creditProduct->quantity,
@ -186,7 +186,6 @@ class PaymentController extends Controller
'tax_percent' => $creditProduct->getTaxPercent(),
'total_price' => $creditProduct->getTotalPrice(),
'currency_code' => $creditProduct->currency_code,
'payer' => json_encode($response->result->payer),
]);
//payment notification
@ -236,7 +235,7 @@ class PaymentController extends Controller
$stripeClient = $this->getStripeClient();
$request = $stripeClient->sessions->create([
$request = $stripeClient->checkout->sessions->create([
'line_items' => [
[
'price_data' => [
@ -280,7 +279,6 @@ class PaymentController extends Controller
*/
public function StripeSuccess(Request $request)
{
echo $request->input('product');
/** @var CreditProduct $creditProduct */
$creditProduct = CreditProduct::findOrFail($request->input('product'));
@ -289,12 +287,11 @@ class PaymentController extends Controller
$stripeClient = $this->getStripeClient();
try{
$paymentSession = $stripeClient->sessions->retrieve($request->input('session_id'));
$capturedPaymentIntent = $stripeClient->paymentIntents->capture($paymentSession.payment_intent);
$paymentSession = $stripeClient->checkout->sessions->retrieve($request->input('session_id'));
$capturedPaymentIntent = $stripeClient->paymentIntents->capture($paymentSession->payment_intent);
if ($response->payment_status == "paid") {
if ($capturedPaymentIntent->status == "succeeded") {
//update credits
$user->increment('credits', $creditProduct->quantity);
@ -314,17 +311,16 @@ class PaymentController extends Controller
//store payment
$payment = Payment::create([
'user_id' => $user->id,
'payment_id' => $response->result->id,
'payer_id' => $request->input('PayerID'),
'payment_id' => $capturedPaymentIntent->id,
'payment_method' => 'stripe',
'type' => 'Credits',
'status' => $response->payment_status,
'status' => $capturedPaymentIntent->status,
'amount' => $creditProduct->quantity,
'price' => $creditProduct->price,
'tax_value' => $creditProduct->getTaxValue(),
'tax_percent' => $creditProduct->getTaxPercent(),
'total_price' => $creditProduct->getTotalPrice(),
'tax_percent' => $creditProduct->getTaxPercent(),
'currency_code' => $creditProduct->currency_code,
'payer' => json_encode($response->result->payer),
]);
//payment notification

View file

@ -23,8 +23,7 @@ class Payment extends Model
'id',
'user_id',
'payment_id',
'payer_id',
'payer',
'payment_method',
'status',
'type',
'amount',

View file

@ -17,12 +17,11 @@ class CreatePaymentsTable extends Migration
$table->uuid('id');
$table->foreignId('user_id')->references('id')->on('users');
$table->string('payment_id')->nullable();
$table->string('payer_id')->nullable();;
$table->string('payment_method')->nullable();
$table->string('type')->nullable();;
$table->string('status')->nullable();;
$table->string('amount')->nullable();;
$table->string('price')->nullable();;
$table->text('payer')->nullable();;
$table->timestamps();
});
}

29
public/css/app.css vendored

File diff suppressed because one or more lines are too long

569
public/js/app.js vendored

File diff suppressed because one or more lines are too long