|
@@ -27,6 +27,7 @@ use PayPalHttp\HttpException;
|
|
|
|
|
|
class PaymentController extends Controller
|
|
class PaymentController extends Controller
|
|
{
|
|
{
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @return Application|Factory|View
|
|
* @return Application|Factory|View
|
|
*/
|
|
*/
|
|
@@ -45,7 +46,10 @@ class PaymentController extends Controller
|
|
public function checkOut(Request $request, PaypalProduct $paypalProduct)
|
|
public function checkOut(Request $request, PaypalProduct $paypalProduct)
|
|
{
|
|
{
|
|
return view('store.checkout')->with([
|
|
return view('store.checkout')->with([
|
|
- 'product' => $paypalProduct
|
|
|
|
|
|
+ 'product' => $paypalProduct,
|
|
|
|
+ 'taxvalue' => $paypalProduct->getTaxValue(),
|
|
|
|
+ 'taxpercent' => $paypalProduct->getTaxPercent(),
|
|
|
|
+ 'total' => $paypalProduct->getTotalPrice()
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -65,8 +69,20 @@ class PaymentController extends Controller
|
|
"reference_id" => uniqid(),
|
|
"reference_id" => uniqid(),
|
|
"description" => $paypalProduct->description,
|
|
"description" => $paypalProduct->description,
|
|
"amount" => [
|
|
"amount" => [
|
|
- "value" => $paypalProduct->price,
|
|
|
|
- "currency_code" => strtoupper($paypalProduct->currency_code)
|
|
|
|
|
|
+ "value" => $paypalProduct->getTotalPrice(),
|
|
|
|
+ 'currency_code' => strtoupper($paypalProduct->currency_code),
|
|
|
|
+ 'breakdown' =>[
|
|
|
|
+ 'item_total' =>
|
|
|
|
+ [
|
|
|
|
+ 'currency_code' => strtoupper($paypalProduct->currency_code),
|
|
|
|
+ 'value' => $paypalProduct->price,
|
|
|
|
+ ],
|
|
|
|
+ 'tax_total' =>
|
|
|
|
+ [
|
|
|
|
+ 'currency_code' => strtoupper($paypalProduct->currency_code),
|
|
|
|
+ 'value' => $paypalProduct->getTaxValue(),
|
|
|
|
+ ]
|
|
|
|
+ ]
|
|
]
|
|
]
|
|
]
|
|
]
|
|
],
|
|
],
|
|
@@ -76,6 +92,8 @@ class PaymentController extends Controller
|
|
'brand_name' => config('app.name', 'Laravel'),
|
|
'brand_name' => config('app.name', 'Laravel'),
|
|
'shipping_preference' => 'NO_SHIPPING'
|
|
'shipping_preference' => 'NO_SHIPPING'
|
|
]
|
|
]
|
|
|
|
+
|
|
|
|
+
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
@@ -161,6 +179,9 @@ class PaymentController extends Controller
|
|
'status' => $response->result->status,
|
|
'status' => $response->result->status,
|
|
'amount' => $paypalProduct->quantity,
|
|
'amount' => $paypalProduct->quantity,
|
|
'price' => $paypalProduct->price,
|
|
'price' => $paypalProduct->price,
|
|
|
|
+ 'tax_value' => $paypalProduct->getTaxValue(),
|
|
|
|
+ 'tax_percent' => $paypalProduct->getTaxPercent(),
|
|
|
|
+ 'total_price' => $paypalProduct->getTotalPrice(),
|
|
'currency_code' => $paypalProduct->currency_code,
|
|
'currency_code' => $paypalProduct->currency_code,
|
|
'payer' => json_encode($response->result->payer),
|
|
'payer' => json_encode($response->result->payer),
|
|
]);
|
|
]);
|
|
@@ -199,7 +220,7 @@ class PaymentController extends Controller
|
|
*/
|
|
*/
|
|
public function cancel(Request $request)
|
|
public function cancel(Request $request)
|
|
{
|
|
{
|
|
- return redirect()->route('store.index')->with('success', 'Payment was Cannceled');
|
|
|
|
|
|
+ return redirect()->route('store.index')->with('success', 'Payment was Canceled');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -216,7 +237,13 @@ class PaymentController extends Controller
|
|
return $payment->user->name;
|
|
return $payment->user->name;
|
|
})
|
|
})
|
|
->editColumn('price', function (Payment $payment) {
|
|
->editColumn('price', function (Payment $payment) {
|
|
- return $payment->formatCurrency();
|
|
|
|
|
|
+ return $payment->formatToCurrency($payment->price);
|
|
|
|
+ })
|
|
|
|
+ ->editColumn('tax_value', function (Payment $payment) {
|
|
|
|
+ return $payment->formatToCurrency($payment->tax_value);
|
|
|
|
+ })
|
|
|
|
+ ->editColumn('total_price', function (Payment $payment) {
|
|
|
|
+ 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() : '';
|