NgeniusController.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Http\Controllers\Payment;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\CustomerPackage;
  5. use App\Models\CombinedOrder;
  6. use App\Utility\NgeniusUtility;
  7. use Session;
  8. class NgeniusController extends Controller
  9. {
  10. public function pay()
  11. {
  12. if (Session::get('payment_type') == 'cart_payment') {
  13. $combined_order = CombinedOrder::findOrFail(Session::get('combined_order_id'));
  14. $amount = round($combined_order->grand_total * 100);
  15. //will be redirected
  16. NgeniusUtility::make_payment(route('ngenius.cart_payment_callback'),"cart_payment",$amount);
  17. } elseif (Session::get('payment_type') == 'wallet_payment') {
  18. $amount = round(Session::get('payment_data')['amount'] * 100);
  19. //will be redirected
  20. NgeniusUtility::make_payment(route('ngenius.wallet_payment_callback'),"wallet_payment",$amount);
  21. } elseif (Session::get('payment_type') == 'customer_package_payment') {
  22. $customer_package = CustomerPackage::findOrFail(Session::get('payment_data')['customer_package_id']);
  23. $amount = round($customer_package->amount * 100);
  24. //will be redirected
  25. NgeniusUtility::make_payment(route('ngenius.customer_package_payment_callback'),"customer_package_payment",$amount);
  26. } elseif (Session::get('payment_type') == 'seller_package_payment') {
  27. $seller_package = \App\Models\SellerPackage::findOrFail(Session::get('payment_data')['seller_package_id']);
  28. $amount = round($seller_package->amount * 100);
  29. //will be redirected
  30. NgeniusUtility::make_payment(route('ngenius.seller_package_payment_callback'),"seller_package_payment",$amount);
  31. }
  32. $seller_package_id = Session::get('payment_data')['seller_package_id'];
  33. $seller_package = \App\Models\SellerPackage::findOrFail($seller_package_id);
  34. }
  35. public function cart_payment_callback()
  36. {
  37. if (request()->has('ref')) {
  38. return NgeniusUtility::check_callback(request()->get('ref'),"cart_payment");
  39. }
  40. }
  41. public function wallet_payment_callback()
  42. {
  43. if (request()->has('ref')) {
  44. return NgeniusUtility::check_callback(request()->get('ref'),"wallet_payment");
  45. }
  46. }
  47. public function customer_package_payment_callback()
  48. {
  49. if (request()->has('ref')) {
  50. return NgeniusUtility::check_callback(request()->get('ref'),"customer_package_payment");
  51. }
  52. }
  53. public function seller_package_payment_callback()
  54. {
  55. if (request()->has('ref')) {
  56. return NgeniusUtility::check_callback(request()->get('ref'),"seller_package_payment");
  57. }
  58. }
  59. }