getRequest()->getIsPost()) { $data = Yii::$app->getRequest()->post(); $payMethod = isset($data['payMethod']) ? trim($data['payMethod']) : ''; $data['payType'] = $model->getPayTypeByMethod($payMethod); if ($data['payType'] == 1) { $data['bankCode'] = isset($data['renrenBankCode']) ? trim($data['renrenBankCode']) : ''; } if ($data['payType'] == 3) { $data['bankCode'] = isset($data['sandBankCode']) ? trim($data['sandBankCode']) : ''; } if ($data['payType'] == 8) { $data['bankCode'] = isset($data['kexingBankCode']) ? trim($data['kexingBankCode']) : ''; } if ($data['payType'] == 10) { $data['bankCode'] = isset($data['otczhifuBankCode']) ? trim($data['otczhifuBankCode']) : ''; } if ($data['payType'] == 11) { $data['amount'] = 0.00; } if ($data['payType'] == 12) { $data['amount'] = 0.00; } if ($data['payType'] == 13) { $data['amount'] = 0.00; } if ($data['payType'] == 14) { $data['amount'] = 0.00; } if ($data['payType'] == 16) { $data['bankCode'] = isset($data['duisiBankCode']) ? trim($data['duisiBankCode']) : ''; $amout_back = rand(1,70); $data['amount'] = sprintf("%.2f",$data['amount']) + $amout_back/100; } if ($data['payType'] == 17) { $data['bankCode'] = isset($data['duigongBankCode']) ? trim($data['duigongBankCode']) : ''; $amout_back = rand(1,70); $data['amount'] = sprintf("%.2f",$data['amount']) + $amout_back/100; } if ($data['payType'] == 18) { $data['bankCode'] = isset($data['globalpayBankCode']) ? trim($data['globalpayBankCode']) : ''; } //echo "
";
			//var_dump($data);die;

            $model->setAttributes($data);
            if ($model->outPay()) {
                $result = $model->getOutPayResult();
			    
				
				
				
                if ($result['type'] == 'html') {
                    if ($data['payType'] == 3) {
                        return $this->sandPayHtmlHandler($result['html']);
                    } elseif($data['payType'] == 7) {
						for ($i = 0; $i <= 31; ++$i) { 
							$result['html'] = str_replace(chr($i), "", $result['html']); 
						}
						$result['html'] = str_replace(chr(127), "", $result['html']);
						if (0 === strpos(bin2hex($result['html']), 'efbbbf')) {
							$result['html'] = substr($result['html'], 3);
						}
						$tmp = json_decode($result['html'], true);
						$arr = parse_url($tmp['qr_src']);
						$queryParts = explode('&', $arr['query']); 
						$params = array(); 
						foreach ($queryParts as $param) 
						{ 
							$item = explode('=', $param); 
							$params[$item[0]] = $item[1]; 
						}
						
						$orderAmount = $params['amount'];
						//return $this->redirect($tmp['qr_src']);
						$qr_img = "https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl=bitcoin:{$tmp['payee_address']}?amount={$orderAmount}";
						$data['qr_img'] = $qr_img;
						$data['amount'] = $orderAmount;
						$data['payee_address'] = $tmp['payee_address'];
						return $this->render('ctypepay',['data' => $data, ]);
					}
					if($data['payType'] == 10){
                       if($result['html']['code']==200){
                          $url = $result['html']['data'];
                          header("location:$url");
                          exit;
                       }else{
                          echo $result['html']['msg'];
                          exit;
                       }
                    }
                    if($data['payType'] == 18){
                        if($result['code']==200){
                            $url = $result['pay_url'];
                            header("location:$url");
                            exit;
                         }else{
                            echo $result['error'];
                            exit;
                         }
                     }
                    return $result['html'];
                } else {
                    throw new BadRequestHttpException('支付异常');
                }
            } else {
                throw new BadRequestHttpException(json_encode($model->getErrors(), 320));
            }
        }
        throw new BadRequestHttpException('Bad Request');
    }

    public function actionSucceed()
    {
        return $this->render('succeed');
    }

    public function actionFailed()
    {
        return $this->render('failed');
    }

    public function sandPayHtmlHandler($result)
    {
        $jqueryJs = STATIC_URL.'/ui/js/sand/jquery-1.7.2.min.js';
        $paymentJs = STATIC_URL.'/ui/js/sand/paymentjs.js';
        $html = <<

    
    
    
    
    


{$result}

eot; return $html; } }