Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Redirect billplz
- public function billplzHandleRedirect(Request $request)
- {
- $billplz = Client::make(config('billplz.billplz_key'), config('billplz.billplz_signature'));
- if (config('billplz.billplz_sandbox')) {
- $billplz->useSandbox();
- }
- $bill = $billplz->bill();
- try {
- $bill = $bill->redirect($request->all());
- } catch (\Exception $e) {
- dd($e->getMessage());
- }
- $bill['data'] = $billplz->bill()->get($bill['id'])->toArray();
- $status = $bill['paid'];
- $amount = $bill['data']['amount']->amount();
- $paid_date = $bill['data']['paid_at'];
- $email = $bill['data']['email'];
- $bill_id = $bill['id'];
- if ($status == 'true') {
- $status = 'Paid';
- } elseif ($status == 'false') {
- $status = 'Failed';
- } else {
- $status = 'Pending';
- }
- $transaction = new PaymentTransaction();
- $transaction->b_id = $bill_id;
- $transaction->pt_date = $paid_date;
- $transaction->pt_status = $status;
- $transaction->pt_payment_method = 'FPX';
- $transaction->save();
- $campaigns = DB::table('bill')
- ->select('bill.b_id', 'c_code', 'c_name', 'b_fee')
- ->join('campaign', 'campaign.c_id', '=', 'bill.c_id')
- ->where('bill.b_id', $bill_id)
- ->get();
- // print_r($bill);
- return view('campaign.handleBill', compact('bill','campaigns'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement