feat: ♻️ Changed payment Status to "paid" && Updated admin/payment table

This commit is contained in:
IceToast 2021-12-15 12:16:30 +01:00
parent 34a8d566a7
commit 45b7d703a5
2 changed files with 11 additions and 10 deletions

View file

@ -179,7 +179,7 @@ class PaymentController extends Controller
'payment_id' => $response->result->id, 'payment_id' => $response->result->id,
'payment_method' => 'paypal', 'payment_method' => 'paypal',
'type' => 'Credits', 'type' => 'Credits',
'status' => $response->result->status, 'status' => 'paid',
'amount' => $creditProduct->quantity, 'amount' => $creditProduct->quantity,
'price' => $creditProduct->price, 'price' => $creditProduct->price,
'tax_value' => $creditProduct->getTaxValue(), 'tax_value' => $creditProduct->getTaxValue(),
@ -290,7 +290,6 @@ class PaymentController extends Controller
try{ try{
$paymentSession = $stripeClient->checkout->sessions->retrieve($request->input('session_id')); $paymentSession = $stripeClient->checkout->sessions->retrieve($request->input('session_id'));
$capturedPaymentIntent = $stripeClient->paymentIntents->capture($paymentSession->payment_intent); $capturedPaymentIntent = $stripeClient->paymentIntents->capture($paymentSession->payment_intent);
if ($capturedPaymentIntent->status == "succeeded") { if ($capturedPaymentIntent->status == "succeeded") {
//update credits //update credits
@ -314,7 +313,7 @@ class PaymentController extends Controller
'payment_id' => $capturedPaymentIntent->id, 'payment_id' => $capturedPaymentIntent->id,
'payment_method' => 'stripe', 'payment_method' => 'stripe',
'type' => 'Credits', 'type' => 'Credits',
'status' => $capturedPaymentIntent->status, 'status' => 'paid',
'amount' => $creditProduct->quantity, 'amount' => $creditProduct->quantity,
'price' => $creditProduct->price, 'price' => $creditProduct->price,
'tax_value' => $creditProduct->getTaxValue(), 'tax_value' => $creditProduct->getTaxValue(),
@ -388,9 +387,13 @@ class PaymentController extends Controller
->editColumn('tax_value', function (Payment $payment) { ->editColumn('tax_value', function (Payment $payment) {
return $payment->formatToCurrency($payment->tax_value); return $payment->formatToCurrency($payment->tax_value);
}) })
->editColumn('tax_percent', function (Payment $payment) {
return $payment->tax_percent . ' %';
})
->editColumn('total_price', function (Payment $payment) { ->editColumn('total_price', function (Payment $payment) {
return $payment->formatToCurrency($payment->total_price); return $payment->formatToCurrency($payment->total_price);
}) })
->editColumn('created_at', function (Payment $payment) { ->editColumn('created_at', function (Payment $payment) {
return $payment->created_at ? $payment->created_at->diffForHumans() : ''; return $payment->created_at ? $payment->created_at->diffForHumans() : '';
}) })

View file

@ -34,15 +34,14 @@
<thead> <thead>
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>User</th>
<th>Type</th> <th>Type</th>
<th>Amount</th> <th>Amount</th>
<th>Product Price</th> <th>Product Price</th>
<th>Tax</th> <th>Tax Value</th>
<th>Tax(%)</th> <th>Tax Percentage</th>
<th>Total Price</th> <th>Total Price</th>
<th>Payment_ID</th> <th>Payment_ID</th>
<th>Payer_ID</th> <th>Payment Method</th>
<th>Created at</th> <th>Created at</th>
</tr> </tr>
</thead> </thead>
@ -67,7 +66,6 @@
ajax: "{{route('admin.payments.datatable')}}", ajax: "{{route('admin.payments.datatable')}}",
columns: [ columns: [
{data: 'id' , name : 'payments.id'}, {data: 'id' , name : 'payments.id'},
{data: 'user', sortable: false},
{data: 'type'}, {data: 'type'},
{data: 'amount'}, {data: 'amount'},
{data: 'price'}, {data: 'price'},
@ -75,12 +73,12 @@
{data: 'tax_percent'}, {data: 'tax_percent'},
{data: 'total_price'}, {data: 'total_price'},
{data: 'payment_id'}, {data: 'payment_id'},
{data: 'payer_id'}, {data: 'payment_method'},
{data: 'created_at'}, {data: 'created_at'},
], ],
fnDrawCallback: function( oSettings ) { fnDrawCallback: function( oSettings ) {
$('[data-toggle="popover"]').popover(); $('[data-toggle="popover"]').popover();
} },
}); });
}); });
</script> </script>