Dashboard sipadu mbip
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

PaymentController.php 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use Illuminate\Support\Facades\Auth;
  6. use Illuminate\Support\Facades\Input;
  7. use LynX39\LaraPdfMerger\Facades\PdfMerger;
  8. use Validator;
  9. use Session;
  10. use Config;
  11. use File;
  12. use Carbon\Carbon;
  13. use PDF;
  14. use App\SiteSetting;
  15. use App\Model\Staff;
  16. use App\Model\StaffDetail;
  17. use App\Model\User;
  18. use App\Model\UserDetail;
  19. use App\Model\Module\Roles;
  20. use App\Model\Module\Department;
  21. use App\Model\Module\DeedLaw;
  22. use App\Model\Module\Faulty;
  23. use App\Model\Module\Compound;
  24. use App\Model\Module\CompoundInvestigation;
  25. use App\Model\Module\ConfidentialFile;
  26. use App\Model\Module\Investigation;
  27. use App\Model\Module\ItemInventory;
  28. use App\Model\Module\History;
  29. use App\Model\Module\SubHistory;
  30. use App\Model\Module\Memo;
  31. use App\Model\Module\Attachment;
  32. use App\Jobs\UpdateCompoundPrice;
  33. class PaymentController extends Controller
  34. {
  35. /**
  36. * Create payment controller.
  37. *
  38. * @return json
  39. */
  40. public function requestCompoundPaymentPdf($kpd) {
  41. $ready_view_pdf = false;
  42. $availablePDF = array();
  43. $now = Carbon::now()->format('d/m/Y h:i:s A');
  44. $compound = Compound::with('ConfidentialFile','Attachment','CompoundInvestigation')->where('kpd', $kpd)->first();
  45. $file = ConfidentialFile::with(['Memo' => function($q){
  46. $q->orderBy('updated_at','ASC');
  47. }],['Investigation' => function($q){
  48. $q->orderBy('updated_at','ASC');
  49. }],'ItemInventory')->where('_id',$compound->ConfidentialFile->_id)->first();
  50. $destinationPath = 'document/'.$compound->ConfidentialFile->no_siri.'/pdf';
  51. if(!File::exists(public_path().'/'.$destinationPath)) {
  52. File::makeDirectory(public_path().'/'.$destinationPath, $mode = 0777, true, true);
  53. }
  54. /**
  55. ** Compound
  56. **/
  57. $tawaran = '';
  58. if($compound->jumlah_kemaskini_kompaun == ''){
  59. $tawaran = $compound->jumlah_asal_kompaun;
  60. }else{
  61. $tawaran = $compound->jumlah_kemaskini_kompaun;
  62. }
  63. $staff = Staff::with('StaffDetail')->where('_id', $compound->dikeluarkan)->first();
  64. $department = Department::where('_id', $compound->jbkod)->first();
  65. $akta = DeedLaw::where('_id', $compound->akta)->first();
  66. $faulty = Faulty::with('DeedLaw')->where('_id',$compound->seksyen_kesalahan)->first();
  67. $site = SiteSetting::first();
  68. $tarikh = date('d/m/Y', strtotime($compound['created_at']));
  69. $masa = date('h:i:s a', strtotime($compound['created_at']));
  70. return view('pdf.compound_payment', compact('compound','staff','department','akta','faulty','picArray','tawaran','site','tarikh','masa'));
  71. }
  72. public function makeWebPayment(Request $request){
  73. $crypt = new \Illuminate\Encryption\Encrypter('F1339A1149AB6FFA9BDDDC6AE677EA90', Config::get( 'app.cipher' ));
  74. $encry = $crypt->encrypt('mpkb:0c79ba6d11631e9619d5ff46711867dc:'.$request->orderid.':'.$request->amount);
  75. $client = new \GuzzleHttp\Client();
  76. $result = $client->request('POST', 'https://staging.kelantanpay.com.my/api/payment/mobile/request', [
  77. 'verify' => false,
  78. 'form_params' => [
  79. 'amount' => $request->amount,
  80. 'orderid' => $request->orderid,
  81. 'userid' => $request->userid,
  82. 'name' => $request->name,
  83. 'email' => $request->email,
  84. 'mobile' => $request->mobile,
  85. 'description' => $request->orderid,
  86. 'merchantid' => 'mpkb',
  87. 'country' => 'MY',
  88. 'key'=> $encry,
  89. 'returnurl' => 'https://mdch1.sipadu.my/compound/'.$request->orderid.'/view/details',
  90. 'update_payment' => 'https://mdch1.sipadu.my/api/update/payment/compound',
  91. ]
  92. ]);
  93. $response = json_decode($result->getBody()->getContents());
  94. if($response->status == true){
  95. return redirect($response->url);
  96. }else if($response->status == false){
  97. return redirect('https://mdch1.sipadu.my/compound/'.$request->orderid.'/view/details');
  98. }
  99. }
  100. public function makeMobilePayment(Request $request){
  101. $crypt = new \Illuminate\Encryption\Encrypter('F1339A1149AB6FFA9BDDDC6AE677EA90', Config::get( 'app.cipher' ));
  102. $encry = $crypt->encrypt('mpkb:0c79ba6d11631e9619d5ff46711867dc:'.$request->orderid.':'.$request->amount);
  103. $client = new \GuzzleHttp\Client();
  104. $result = $client->request('POST', 'https://staging.kelantanpay.com.my/api/payment/mobile/request', [
  105. 'verify' => false,
  106. 'form_params' => [
  107. 'amount' => $request->amount,
  108. 'orderid' => $request->orderid,
  109. 'userid' => $request->userid,
  110. 'name' => $request->name,
  111. 'email' => $request->email,
  112. 'mobile' => $request->mobile,
  113. 'description' => $request->orderid,
  114. 'merchantid' => 'mpkb',
  115. 'country' => 'MY',
  116. 'key'=> $encry,
  117. 'returnurl' => 'https://demo.sipadu.my/compound/'.$request->orderid.'/view/details',
  118. 'update_payment' => 'https://demo.sipadu.my/api/update/payment/compound',
  119. ]
  120. ]);
  121. $response = $result->getBody()->getContents();
  122. return $response;
  123. }
  124. }