Beispiel #1
0
 /**
  * Process the PaymentWall payment
  *
  * @param Request $request
  */
 public function getPaymentWall(Request $request)
 {
     $pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
     if ($pingback->validate()) {
         $virtualCurrency = $pingback->getVirtualCurrencyAmount();
         $user = User::find($request->uid);
         if (settings('paymentwall_double')) {
             $n_credits = $virtualCurrency * 2;
         } else {
             $n_credits = $virtualCurrency;
         }
         if ($pingback->isDeliverable()) {
             // Give credits to user
             $user->money = $user->money + $n_credits;
             $user->save();
             Payment::create(['user_id' => $user->ID, 'transaction_id' => $request->ref, 'amount' => $n_credits]);
         } elseif ($pingback->isCancelable()) {
             // Remove credits from user
             $user->money = $user->money + $n_credits;
             $user->save();
             $payment = Payment::find($request->ref);
             $payment->delete();
         }
         echo 'OK';
         // Paymentwall expects response to be OK, otherwise the pingback will be resent
     } else {
         echo $pingback->getErrorSummary();
     }
 }
 public function detail($id)
 {
     $data = $this->load_common_data();
     $payment = Payment::find($id);
     $data['payment'] = $payment;
     return $this->back_view('payments.detail', $data);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     try {
         $payment = Payment::find($id);
         if (!$payment) {
             return response()->json(['code' => 404, 'messages' => 'Payment not found.'], 404);
         }
         return response()->json(['code' => 200, 'data' => $payment], 200);
     } catch (Exception $e) {
         return response()->json(['code' => 500, 'messages' => 'Internal Server Error'], 500);
     }
 }
 public function settlePayment()
 {
     //find the hidden id
     $payment = Payment::find(Request::input('id'));
     //assign the form input to db field respectively
     $payment->code = Request::input('payment_code');
     $payment->payment_date = Request::input('date');
     $payment->method = Request::input('payment_method');
     $payment->is_paid = 'Waiting for Verification';
     if ($payment->method == 'Credit Card') {
         $payment->credit_card_no = Request::input('credit_card_no');
     } else {
         if ($payment->method == 'Debit Card') {
             $payment->debit_card_no = Request::input('debit_card_no');
         }
     }
     $payment->save();
     return Redirect::action('PaymentController@index')->with('message', 'You have successfully conduct the payment');
 }
Beispiel #5
0
 public function paymentDetail($paymentId)
 {
     $payment = Payment::find($paymentId);
     $data['payment'] = $payment;
     return $this->front_view('profile.payment-detail', $data);
 }
Beispiel #6
0
 public static function reject($id)
 {
     $payment = Payment::find($id);
     $payment->status = "REJECTED";
     $payment->save();
 }
Beispiel #7
0
 public function response(Request $request)
 {
     $url = "https://epp.khanbank.com/payment/rest/getOrderStatus.do";
     $data = array('language' => 'en', 'orderId' => $request->get('orderId'), 'userName' => env('KhanBankUname'), 'password' => env('KhanBankUpass'));
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_FAILONERROR, 0);
     curl_setopt($curl, CURLOPT_HEADER, 0);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_POST, 1);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
     curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
     curl_setopt($curl, CURLOPT_ENCODING, "UTF-8");
     curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
     $response = curl_exec($curl);
     curl_close($curl);
     $response = json_decode($response);
     $payment = Payment::find($request->get('orderId'));
     $payment->status = $response->orderStatus;
     $payment->save();
     /*
             Төлөвийн код тайлбар /Order Status/
             0	Order registered, but not paid off.
             1	Pre-authorisation of order amount was held (for two-stage payment)
             2	Order amount is fully authorized.
             3	Authorization canceled.
             4	Transaction was refunded.
             5	Initiated authorization using ACS of the issuer bank.
             6	Authorization declined.
     */
     if ($response->ErrorCode == 0) {
         if ($response->ErrorMessage == 'Success' && $response->orderStatus == 2) {
             //төлбөр амжилттай төлөгдлөө
             $return_content = 'Таны төлбөр амжилттай төлөгдлөө';
             //мэйл илгээх гэх мэт үйлдэл
         } else {
             // энийг note рүү хийхиймүү яахын
             $return_content = $response->ErrorMessage;
         }
     } else {
         $return_content = 'Таны төлбөр хийгдсэнгүй! ' . $response->ErrorMessage;
         $payment = Payment::find($request->get('orderId'));
         $payment->status = $response->ErrorCode;
         $payment->save();
         /*
         Алдааны код тайлбар /Error code/
         0	No system error.
         2	The order is declined because of an error in the payment credentials.
         5	Erroneous value of a request parameter.
         6	Unregistered OrderId.
         */
     }
     //харгалзах view дуудах
     //$return_content;
 }
 public function postPaymentwall(Request $request)
 {
     /**
      *  Pingback Listener Script
      *  For Virtual Currency API
      *  Copyright (c) 2010-2013 Paymentwall Team
      */
     /**
      *  Define your application-specific options
      */
     define('SECRET', settings('paymentwall_key'));
     define('IP_WHITELIST_CHECK_ACTIVE', true);
     define('CREDIT_TYPE_CHARGEBACK', 2);
     /**
      *  The IP addresses below are Paymentwall's
      *  servers. Make sure your pingback script
      *  accepts requests from these addresses ONLY.
      *
      */
     $ipsWhitelist = array('174.36.92.186', '174.36.96.66', '174.36.92.187', '174.36.92.192', '174.37.14.28');
     /**
      *  Collect the GET parameters from the request URL
      */
     $userId = isset($request->uid) ? $request->uid : null;
     $credits = isset($request->currency) ? $request->currency : null;
     $type = isset($request->type) ? $request->type : null;
     $refId = isset($request->ref) ? $request->ref : null;
     $signature = isset($request->sig) ? $request->sig : null;
     $sign_version = isset($request->sign_version) ? $request->sign_version : null;
     $result = false;
     /**
      *  If there are any errors encountered, the script will list them
      *  in an array.
      */
     $errors = array();
     if (!empty($userId) && !empty($credits) && isset($type) && !empty($refId) && !empty($signature)) {
         $signatureParams = array();
         if (empty($sign_version) || $sign_version <= 1) {
             $signatureParams = array('uid' => $userId, 'currency' => $credits, 'type' => $type, 'ref' => $refId);
         } else {
             $signatureParams = array();
             foreach ($_GET as $param => $value) {
                 $signatureParams[$param] = $value;
             }
             unset($signatureParams['sig']);
         }
         /**
          *  check if IP is in whitelist and if signature matches
          */
         $signatureCalculated = $this->calculatePingbackSignature($signatureParams, SECRET, $sign_version);
         /**
          *  Run the security check -- if the request's origin is one
          *  of Paymentwall's servers, and if the signature matches
          *  the parameters.
          */
         if (!IP_WHITELIST_CHECK_ACTIVE || in_array($_SERVER['REMOTE_ADDR'], $ipsWhitelist)) {
             if ($signature == $signatureCalculated) {
                 $result = true;
                 $user = User::find($userId);
                 if (settings('paymentwall_double')) {
                     $n_credits = $credits * 2;
                 } else {
                     $n_credits = $credits;
                 }
                 if ($type == CREDIT_TYPE_CHARGEBACK) {
                     /**
                      *  Deduct credits from user. Note that currency amount
                      *  sent for chargeback is negative, e.g. -5, so be
                      *  careful about the sign Don't deduct negative
                      *  number, otherwise user will gain credits instead
                      *  of losing them
                      *
                      */
                     // Remove credits from user
                     $user->money = $user->money + $n_credits;
                     $user->save();
                     $payment = Payment::find($refId);
                     $payment->delete();
                 } else {
                     // Give credits to user
                     $user->money = $user->money + $n_credits;
                     $user->save();
                     Payment::create(['user_id' => $user->ID, 'transaction_id' => $refId, 'amount' => $n_credits]);
                 }
             } else {
                 $errors['signature'] = 'Signature is not valid!';
             }
         } else {
             $errors['whitelist'] = 'IP not in whitelist!';
         }
     } else {
         $errors['params'] = 'Missing parameters!';
     }
     /**
      *  Always make sure to echo OK so Paymentwall
      *  will know that the transaction is successful.
      */
     if ($result) {
         echo 'OK';
     } else {
         echo implode(' ', $errors);
     }
 }
Beispiel #9
0
 public function runner(Request $request, $prefix)
 {
     if ($race_id = foundInRequest($request, 'race_id')) {
         $race = Race::find($race_id);
     } else {
         return redirect($prefix . '/error');
     }
     $doc_type = foundInRequest($request, 'doc_type');
     $doc_num = foundInRequest($request, 'doc_num');
     $gender = foundInRequest($request, 'gender');
     $dob = Carbon::parse(foundInRequest($request, 'dob'));
     $event = Event::find(foundInRequest($request, 'event_id'));
     $payment = Payment::find(foundInRequest($request, 'payment_id'));
     $ticket = foundInRequest($request, 'ticket');
     if (!($gateway = Gateway::find(foundInRequest($request, 'gateway_id')))) {
         $gateway = Gateway::makeDummy();
     }
     if ($payment->id == 1) {
         $transaction = Transaction::find(foundInRequest($request, 'ticket'));
         $code = Code::makeDummy();
     } else {
         $code = Code::where('code', foundInRequest($request, 'ticket'))->first();
         $transaction = Transaction::makeDummy();
     }
     if ($gender == 'M') {
         $gender_verbose = 'Masculino';
         $sizes = $event->maleSizes($race->size_threshold)->lists('name_long', 'id')->all();
     } else {
         $gender_verbose = 'Femenino';
         $sizes = $event->femaleSizes($race->size_threshold)->lists('name_long', 'id')->all();
     }
     $type = $request->session()->get('type');
     return view('enroll.runner')->with(['doc_type' => $doc_type, 'doc_num' => $doc_num, 'gender' => $gender, 'dob' => $dob, 'race' => $race, 'event' => $event, 'payment' => $payment, 'ticket' => $ticket, 'gateway' => $gateway, 'transaction' => $transaction, 'code' => $code, 'gender_verbose' => $gender_verbose, 'sizes' => $sizes, 'type' => $type]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $payment = Payment::find($id);
     $payment->delete();
     return redirect('payments');
 }
Beispiel #11
0
 public function confirmPayment(Request $request, $id)
 {
     $payment = Payment::find($id);
     $payment->does_supplier_confirm = 1;
     $payment->update();
     $checkouts = CheckOut::where(['supplier_id' => Auth::user()->id, 'payment_id' => $id])->get();
     foreach ($checkouts as $checkout) {
         $checkout->confirmed_by_supplier = 1;
         $checkout->update();
     }
     return redirect()->action('Dashboard\\SupplierController@showWaitingPayments')->with(['success' => ['Müşteri ödemesi onaylandı.']]);
 }