Example #1
0
 public function Queryorder($transaction_id)
 {
     $input = new WxPayOrderQuery();
     $input->SetTransaction_id($transaction_id);
     $result = WxPayApi::orderQuery($input);
     \Log::info("query:" . json_encode($result));
     if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
         // 处理订单
         $pay = \App\Pay::find($result['out_trade_no']);
         $pay->pay($result['transaction_id']);
         if ($pay->state < 2) {
             $pay->state = '2';
             $pay->bak_id = '0';
             $pay->other_id = $result['transaction_id'];
             $pay->save();
         } else {
             if ($pay->state == 2) {
                 $pay->bak_id++;
                 $pay->save();
             }
         }
         return true;
     }
     return false;
 }
 public function index(Request $request)
 {
     //get info for this payment
     $payTypeInfo = Pay::find(Pay::PAY_TYPE_MOBIO);
     //calc promo period
     $promoUntilDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + $payTypeInfo->pay_promo_period, date('Y')));
     //get incoming params
     $message = isset($request->message) ? $request->message : null;
     $item = isset($request->item) ? $request->item : null;
     $fromnum = isset($request->fromnum) ? $request->fromnum : null;
     $extid = isset($request->extid) ? $request->extid : null;
     $servID = isset($request->servID) ? $request->servID : null;
     //check if ping is comming from allowed ips
     $mobio_remote_address = explode(',', $payTypeInfo->pay_allowed_ip);
     if (in_array($request->ip(), $mobio_remote_address)) {
         $sms_reply = trans('payment_mobio.There is error, please contact us.');
         $item = trim($item);
         if (!empty($item)) {
             try {
                 $pay_type = mb_strtolower(mb_substr($item, 0, 1));
                 //make ad vip
                 if ($pay_type == 'a') {
                     $ad_id = mb_substr($item, 1);
                     $adInfo = Ad::find($ad_id);
                     if (!empty($adInfo)) {
                         //update ad
                         $adInfo->ad_promo = 1;
                         $adInfo->ad_promo_until = $promoUntilDate;
                         $adInfo->save();
                         //add money to wallet
                         $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_mobio.Payment via Mobio SMS')];
                         Wallet::create($wallet_data);
                         //subtract money from wallet
                         $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => -$payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate])];
                         Wallet::create($wallet_data);
                         $sms_reply = trans('payment_mobio.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate]);
                         Cache::flush();
                     }
                 }
                 //add money to wallet
                 if ($pay_type == 'w') {
                     $user_id = mb_substr($item, 1);
                     $userInfo = User::find($user_id);
                     if (!empty($userInfo)) {
                         //save money to wallet
                         $wallet_data = ['user_id' => $userInfo->user_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_mobio.Add Money to Wallet via Mobio SMS')];
                         Wallet::create($wallet_data);
                         $sms_reply = trans('payment_mobio.You have added :money to your wallet.', ['money' => number_format($payTypeInfo->pay_sum, 2) . config('dc.site_price_sign')]);
                         Cache::flush();
                     }
                 }
             } catch (\Exception $e) {
             }
         }
         file_get_contents("http://mobio.bg/paynotify/pnsendsms.php?servID={$servID}&tonum={$fromnum}&extid={$extid}&message=" . urlencode($sms_reply));
     }
 }
 public function index(Request $request)
 {
     $sms_reply = trans('payment_fortumo.There is error, please contact us.');
     //get info for this payment
     $payTypeInfo = Pay::find(Pay::PAY_TYPE_FORTUMO);
     //calc promo period
     $promoUntilDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + $payTypeInfo->pay_promo_period, date('Y')));
     //get incoming params
     $message = isset($request->message) ? $request->message : null;
     $status = isset($request->status) ? $request->status : null;
     $billing_type = isset($request->billing_type) ? $request->billing_type : null;
     //check if ping is comming from allowed ips
     $fortumo_remote_address = explode(',', $payTypeInfo->pay_allowed_ip);
     if (in_array($request->ip(), $fortumo_remote_address) && $this->check_signature($request->all(), $payTypeInfo->pay_secret)) {
         $message = trim($message);
         if (!empty($message) && (preg_match("/OK/i", $status) || preg_match("/MO/i", $billing_type) && preg_match("/pending/i", $status))) {
             try {
                 $pay_type = mb_strtolower(mb_substr($message, 0, 1));
                 //make ad vip
                 if ($pay_type == 'a') {
                     $ad_id = mb_substr($message, 1);
                     $adInfo = Ad::find($ad_id);
                     if (!empty($adInfo)) {
                         //update ad
                         $adInfo->ad_promo = 1;
                         $adInfo->ad_promo_until = $promoUntilDate;
                         $adInfo->save();
                         //add money to wallet
                         $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Payment via Fortumo SMS')];
                         Wallet::create($wallet_data);
                         //subtract money from wallet
                         $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => -$payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate])];
                         Wallet::create($wallet_data);
                         $sms_reply = trans('payment_fortumo.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate]);
                         Cache::flush();
                     }
                 }
                 //add money to wallet
                 if ($pay_type == 'w') {
                     $user_id = mb_substr($message, 1);
                     $userInfo = User::find($user_id);
                     if (!empty($userInfo)) {
                         //save money to wallet
                         $wallet_data = ['user_id' => $userInfo->user_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Add Money to Wallet via Fortumo SMS')];
                         Wallet::create($wallet_data);
                         $sms_reply = trans('payment_fortumo.You have added :money to your wallet.', ['money' => number_format($payTypeInfo->pay_sum, 2) . config('dc.site_price_sign')]);
                         Cache::flush();
                     }
                 }
             } catch (\Exception $e) {
             }
         }
     }
     echo $sms_reply;
 }
 public function edit(Request $request)
 {
     $id = 0;
     if (isset($request->id)) {
         $id = $request->id;
     }
     try {
         $modelData = Pay::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         session()->flash('message', trans('admin_common.Invalid Payment Option'));
         return redirect(url('admin/pay'));
     }
     /**
      * form is submitted check values and save if needed
      */
     if ($request->isMethod('post')) {
         /**
          * validate data
          */
         $rules = ['pay_name' => 'required|max:255', 'pay_sum' => 'required|numeric|not_in:0', 'pay_promo_period' => 'required|numeric|not_in:0', 'pay_info_url' => 'required|max:255', 'pay_sms_prefix' => 'max:255', 'pay_description' => 'required', 'pay_ord' => 'required|numeric', 'pay_allowed_ip' => 'max:255', 'pay_number' => 'max:255', 'pay_secret' => 'max:255'];
         $validator = Validator::make($request->all(), $rules);
         if ($validator->fails()) {
             $this->throwValidationException($request, $validator);
         }
         /**
          * get data from form
          */
         $data = $request->all();
         if (isset($data['pay_active'])) {
             $data['pay_active'] = 1;
         } else {
             $data['pay_active'] = 0;
         }
         /**
          * save or update
          */
         $modelData->update($data);
         /**
          * clear cache, set message, redirect to list
          */
         Cache::flush();
         session()->flash('message', trans('admin_common.Payment Option saved'));
         return redirect(url('admin/pay'));
     }
     return view('admin.pay.pay_edit', ['modelData' => $modelData]);
 }
 public function thanks(Request $request)
 {
     $secret_key = env('CITRUSGATEWAY_SECRETKEY');
     $data = '';
     $flag = true;
     $fields = ['TxId', 'TxStatus', 'amount', 'pgTxnNo', 'issuerRefNo', 'authIdCode', 'firstName', 'lastName', 'pgRespCode', 'addressZip'];
     $fill_data = [];
     foreach ($fields as $field) {
         if ($request->has($field)) {
             $data .= $request->get($field);
         }
         $fill_data[$field] = $request->get($field, '');
     }
     Pay::create($fill_data);
     $signature = $request->get('signature', '');
     $txnID = $request->get('TxId', '');
     $txnStatus = $request->get('TxStatus', '');
     $response_signature = hash_hmac('sha1', $data, $secret_key);
     if ($signature != '' && strcmp($signature, $response_signature) != 0) {
         $flag = false;
     }
     return view('thanks', compact('flag', 'txnID', 'txnStatus'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $pay = Pay::find($id);
     $pay->delete($id);
     return redirect()->route('pay.index');
 }
Example #7
0
 public function postAddofferbalance(OrderCSP $request)
 {
     $user = $request->user();
     $res = ['response' => 'YES', 'status' => 0];
     $offer_id = $request->input('offer_id');
     $product_amount = $request->input('product_amount');
     $item = Order::item($offer_id, $product_amount);
     $shop_id = $request->input('shop_id');
     $coupon_id = $request->input('coupon_id');
     $mobile = $request->input('mobile');
     $touch = $request->input('touch');
     $sex = $request->input('sex');
     $response = Offer::apiCheck($item, $shop_id, $coupon_id);
     if ($response) {
         $params = ['item_id' => $shop_id, 'item' => $item, 'mobile' => $mobile, 'touch' => $touch, 'sex' => $sex];
         if ($coupon_id) {
             $params['coupon_id'] = $coupon_id;
         }
         $order = Order::apiCreateZd($params);
         if ($order) {
             $odrno = $order->odrno;
             $pay = Pay::apiBalance($odrno);
             if ($pay) {
                 $res['status'] = 1;
                 $res['msgSuccess'] = '支付成功!';
             } else {
                 $res['msgError'] = '支付失败!';
             }
         } else {
             $res['msgError'] = '网络延迟,稍后重试';
         }
     } else {
         $res['msgError'] = '订单信息错误';
     }
     return response()->json($res);
 }
 /**
  * Store a newly created resource in storage.
  * Check, before buy
  * @return Response
  */
 public function postCheckcart(Request $request)
 {
     if (\Auth::check()) {
         //MENU
         $mainMenu = Category::getParentMenu();
         $allMenu = Category::getAllMenu($mainMenu);
         //HOT PRODUCTS.
         $hotProduct = Product::hotProduct();
         //DISCOUNT PRODUCTS.
         $discountProduct = Product::discountProduct();
         //PAY
         $pay = Pay::find($request->get('pay'));
         if ($request->get('pay') == 2) {
             $account_number = true;
         } else {
             $account_number = false;
         }
         //SHIP
         $ship = Ship::find($request->get('ship'));
         if (\Session::has('giohang')) {
             \Session::put('pay', $pay->id);
             \Session::put('ship', $ship->id);
             return view('fornindex.shopping_cart_detail', compact('account_number', 'ship', 'pay', 'data', 'allMenu', 'hotProduct', 'discountProduct'));
         } else {
             echo 'vui long chon san pham!!!';
         }
     } else {
         return redirect('auth/login');
     }
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $transaction = Transaction::find($id);
     $customer = Customer::lists('name', 'id');
     $ship = Ship::lists('name', 'id');
     $pay = Pay::lists('name', 'id');
     return view('transactions.edit', compact('transaction', 'customer', 'ship', 'pay'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 10; ++$i) {
         Pay::create(['name' => $faker->name]);
     }
 }