コード例 #1
0
 public function actionIndex()
 {
     U::W([__METHOD__, $_GET, $_POST]);
     //$this->layout = false;
     $this->layout = 'wapy';
     $alipay_config = Alipay::getAlipayConfig();
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyReturn();
     if (!$verify_result) {
         Alipay::logResult(['Alipaycallback error', __METHOD__, $_GET, $_POST]);
         //return 'Alipaycallback error';
     }
     $result = $_GET['result'];
     if ($result != 'success') {
         Alipay::logResult(['Pay error', __METHOD__, $_GET, $_POST]);
         return 'Pay error';
     }
     $oid = $_GET['out_trade_no'];
     $model = MOrder::findOne($oid);
     if ($model === null) {
         U::W(['Invalid oid', $_GET, $_POST]);
         return "Invalid oid";
     }
     $model->pay_kind = MOrder::PAY_KIND_ALIWAP;
     $model->aliwap_trade_no = $_GET['trade_no'];
     $model->status = MOrder::STATUS_SUCCEEDED;
     if (!$model->save(false)) {
         U::W(['save db error', $_GET, $_POST, $model->getErrors()]);
         return 'system error';
     }
     //return 'Pay OK';
     return $this->render('index', ['gh_id' => $model->gh_id, 'openid' => $model->openid]);
 }
コード例 #2
0
 public function actionIndex()
 {
     U::W([__METHOD__, $_GET, $_POST]);
     $this->layout = false;
     $alipay_config = Alipay::getAlipayConfig();
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyNotify();
     if (!$verify_result) {
         Alipay::logResult(['Alipaynotify sign error', __METHOD__, $_GET, $_POST]);
         return "fail";
     }
     if ($alipay_config['sign_type'] == 'MD5') {
         $respObject = @simplexml_load_string($_POST['notify_data']);
     } else {
         if ($alipay_config['sign_type'] == '0001') {
             $respObject = @simplexml_load_string($alipayNotify->decrypt($_POST['notify_data']));
         } else {
             Alipay::logResult(['Alipaynotify sign_type error', __METHOD__, $_GET, $_POST]);
         }
     }
     $arr = json_decode(json_encode($respObject), true);
     U::W($arr);
     $oid = $arr['out_trade_no'];
     $model = MOrder::findOne($oid);
     if ($model === null) {
         U::W(['Invalid oid', $_GET, $_POST, $arr]);
         return "success";
     }
     $model->pay_kind = MOrder::PAY_KIND_ALIWAP;
     $model->aliwap_trade_no = $arr['trade_no'];
     $model->aliwap_total_fee = $arr['total_fee'];
     $model->aliwap_trade_status = $arr['trade_status'];
     $model->aliwap_buyer_email = $arr['buyer_email'];
     $model->aliwap_quantity = $arr['quantity'];
     $model->aliwap_gmt_payment = $arr['gmt_payment'];
     if ($arr['trade_status'] == 'TRADE_FINISHED' || $arr['trade_status'] == 'TRADE_SUCCESS') {
         $model->status = MOrder::STATUS_SUCCEEDED;
     } else {
         U::W(['trade_status is not TRADE_FINISHED', $_GET, $_POST, $arr]);
     }
     if (!$model->save(false)) {
         U::W(['save db error', $_GET, $_POST, $arr, $model->getErrors()]);
     }
     return "success";
 }
コード例 #3
0
ファイル: AlipaySubmit.php プロジェクト: noikiy/wowewe
 function parseResponse($str_text)
 {
     $para_split = explode('&', $str_text);
     foreach ($para_split as $item) {
         $nPos = strpos($item, '=');
         $nLen = strlen($item);
         $key = substr($item, 0, $nPos);
         $value = substr($item, $nPos + 1, $nLen - $nPos - 1);
         $para_text[$key] = $value;
     }
     if (!empty($para_text['res_data'])) {
         if ($this->alipay_config['sign_type'] == '0001') {
             $para_text['res_data'] = Alipay::rsaDecrypt($para_text['res_data'], $this->alipay_config['private_key_path']);
         }
         $doc = new DOMDocument();
         $doc->loadXML($para_text['res_data']);
         $para_text['request_token'] = $doc->getElementsByTagName("request_token")->item(0)->nodeValue;
     }
     if (!empty($para_text['res_error'])) {
         $respObject = @simplexml_load_string($para_text['res_error']);
         $para_text['res_error_arr'] = json_decode(json_encode($respObject), true);
         Alipay::logResult($para_text['res_error_arr']);
     }
     return $para_text;
 }
コード例 #4
0
ファイル: AlipayNotify.php プロジェクト: noikiy/wowewe
 function getResponse($notify_id)
 {
     $transport = strtolower(trim($this->alipay_config['transport']));
     $partner = trim($this->alipay_config['partner']);
     $veryfy_url = '';
     if ($transport == 'https') {
         $veryfy_url = $this->https_verify_url;
     } else {
         $veryfy_url = $this->http_verify_url;
     }
     $veryfy_url = $veryfy_url . "partner=" . $partner . "&notify_id=" . $notify_id;
     $responseTxt = Alipay::getHttpResponseGET($veryfy_url, $this->alipay_config['cacert']);
     return $responseTxt;
 }
コード例 #5
0
ファイル: WapController.php プロジェクト: noikiy/wowewe
 public function actionOrderinfo($oid)
 {
     $this->layout = 'wapy';
     $gh_id = U::getSessionParam('gh_id');
     $openid = U::getSessionParam('openid');
     $model = MOrder::findOne($oid);
     if (\Yii::$app->request->isPost) {
         if (isset($_POST['paykind'])) {
             $_POST['MOrder']['pay_kind'] = $_POST['paykind'];
         }
         $model->setAttributes($_POST['MOrder'], false);
         $model->save(false);
         if ($model->pay_kind == MOrder::PAY_KIND_CASH) {
             $model->status = MOrder::STATUS_SUBMITTED;
             $model->save(false);
             //return $this->redirect(['wap/order']);
             //去新的订单页面
             return $this->redirect(['wap/myorder']);
         }
         if ($model->pay_kind == MOrder::PAY_KIND_ALIWAP) {
             $this->layout = false;
             //U::W($model->getAttributes());
             $alipay_config = Alipay::getAlipayConfig();
             $format = "xml";
             $v = "2.0";
             $req_id = uniqid();
             $notify_url = "http://wosotech.com/wx/web/alipaynotify.php";
             $call_back_url = "http://wosotech.com/wx/web/alipaycallback.php";
             $merchant_url = "http://wosotech.com/wx/web/alipaymerchant.php";
             $seller_email = '*****@*****.**';
             $out_trade_no = $model->oid;
             $subject = $model->detail;
             $total_fee = $model->feesum;
             $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>';
             $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset'])));
             //U::W($para_token);
             $alipaySubmit = new AlipaySubmit($alipay_config);
             $html_text = $alipaySubmit->buildRequestHttp($para_token);
             //U::W($html_text);
             $html_text = urldecode($html_text);
             $arr = $alipaySubmit->parseResponse($html_text);
             if (!empty($arr['res_error'])) {
                 U::W($arr);
                 $msg = print_r($arr['res_error_arr'], true);
                 return $this->render('alipay_msg', ['msg' => $msg]);
             }
             //U::W($arr);
             $request_token = $arr['request_token'];
             $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>';
             $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset'])));
             $alipaySubmit = new AlipaySubmit($alipay_config);
             $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', 'OK');
             return $this->render('alipay_submit', ['msg' => $html_text]);
         }
     }
     //$office = MOffice::findOne($model->office_id);
     $item = MItem::findOne(['gh_id' => $gh_id, 'cid' => $model->cid]);
     //$item = MItem::findOne($model->cid);
     /*
     $input = new WxPayUnifiedOrder();
     $input->SetBody("test");
     $input->SetAttach("test");
     $input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis"));
     $input->SetTotal_fee("1");
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag("test");
     $input->SetNotify_url("http://wosotech.com/wx/web/wxpaynotify.php");
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openid);
     $unifiedOrder = WxPayApi::unifiedOrder($input);
     U::W($unifiedOrder);
     $jsApiParameters = $this->GetJsApiParameters($unifiedOrder);
     U::W($jsApiParameters);
     */
     //        $jsApiParameters = $order->GetOrderJsApiParameters();
     $jsApiParameters = '';
     return $this->render('orderinfo', ['gh_id' => $gh_id, 'openid' => $openid, 'model' => $model, 'item' => $item, 'jsApiParameters' => $jsApiParameters]);
 }