Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. // Redirect billplz
  2. public function billplzHandleRedirect(Request $request)
  3. {
  4. $billplz = Client::make(config('billplz.billplz_key'), config('billplz.billplz_signature'));
  5. if (config('billplz.billplz_sandbox')) {
  6. $billplz->useSandbox();
  7. }
  8. $bill = $billplz->bill();
  9. try {
  10. $bill = $bill->redirect($request->all());
  11. } catch (\Exception $e) {
  12. dd($e->getMessage());
  13. }
  14.  
  15. $bill['data'] = $billplz->bill()->get($bill['id'])->toArray();
  16. $status = $bill['paid'];
  17. $amount = $bill['data']['amount']->amount();
  18. $paid_date = $bill['data']['paid_at'];
  19. $email = $bill['data']['email'];
  20. $bill_id = $bill['id'];
  21.  
  22. if ($status == 'true') {
  23. $status = 'Paid';
  24. } elseif ($status == 'false') {
  25. $status = 'Failed';
  26. } else {
  27. $status = 'Pending';
  28. }
  29.  
  30. $transaction = new PaymentTransaction();
  31. $transaction->b_id = $bill_id;
  32. $transaction->pt_date = $paid_date;
  33. $transaction->pt_status = $status;
  34. $transaction->pt_payment_method = 'FPX';
  35. $transaction->save();
  36.  
  37. $campaigns = DB::table('bill')
  38. ->select('bill.b_id', 'c_code', 'c_name', 'b_fee')
  39. ->join('campaign', 'campaign.c_id', '=', 'bill.c_id')
  40. ->where('bill.b_id', $bill_id)
  41. ->get();
  42.  
  43. // print_r($bill);
  44. return view('campaign.handleBill', compact('bill','campaigns'));
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement