Commit 4be5dfae authored by xiabin's avatar xiabin

添加移动端支付宝支付

parent 7e786f11
<?php
/**
* Created by PhpStorm.
* User: xiabin
* Date: 2016/10/19
* Time: 下午3:52
*/
namespace common\components;
use yii\base\Object;
/**
* 移动设备检测功能
* @link http://mobiledetect.net/
*
* @example
* //注册一个检测移动设备组件
* Yii::$app->set('deviceDetect', [
* 'class' => 'common\service\DeviceDetect',
* ]);
* //使用
* Yii::$app->deviceDetect->isMobile();
*
* Class MyMobileDetect
*/
class MobileDetect extends Object
{
/**
* @var
*/
private $detector;
/**
*init
*/
public function init()
{
parent::init();
$this->detector = new \Detection\MobileDetect();
}
/**
* @param string $name
* @param array $params
* @return mixed
*/
public function __call($name, $params)
{
return call_user_func_array(
array($this->detector, $name),
$params
);
}
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ namespace common\libs\alipay;
use DOMDocument;
use yii\helpers\ArrayHelper;
require_once (dirname(__FILE__) . "/libs/alipay_core.function.php");
require_once(dirname(__FILE__) . "/libs/alipay_core.function.php");
require_once(dirname(__FILE__) . "/libs/alipay_md5.function.php");
class AliPay
......
......@@ -17,7 +17,8 @@
"guzzlehttp/guzzle": "^6.2",
"qiniu/php-sdk": "^7.0",
"light/yii2-xmlparser": "*",
"2amigos/yii2-qrcode-helper": "*"
"2amigos/yii2-qrcode-helper": "*",
"mobiledetect/mobiledetectlib": "^2.8"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
......
......@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "553e6afb2f94832a2b21ea5d6301d656",
"content-hash": "b2a9e1b6aa19ba113948022d2525b40b",
"hash": "4454b16ac08c05c643766291ce0b6335",
"content-hash": "7cd14e3280f6fcccf735c7641fab4a28",
"packages": [
{
"name": "2amigos/yii2-qrcode-helper",
......@@ -572,6 +572,60 @@
],
"time": "2015-08-15 16:07:34"
},
{
"name": "mobiledetect/mobiledetectlib",
"version": "2.8.22",
"source": {
"type": "git",
"url": "https://github.com/serbanghita/Mobile-Detect.git",
"reference": "53cddae0c272a478b24a4b5fb60d0f838caf70b6"
},
"dist": {
"type": "zip",
"url": "https://packagist.phpcomposer.com/files/serbanghita/Mobile-Detect/53cddae0c272a478b24a4b5fb60d0f838caf70b6.zip",
"reference": "53cddae0c272a478b24a4b5fb60d0f838caf70b6",
"shasum": ""
},
"require": {
"php": ">=5.0.0"
},
"require-dev": {
"codeclimate/php-test-reporter": "dev-master",
"johnkary/phpunit-speedtrap": "~1.0@dev",
"phpunit/phpunit": "*"
},
"type": "library",
"autoload": {
"classmap": [
"Mobile_Detect.php"
],
"psr-0": {
"Detection": "namespaced/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Serban Ghita",
"email": "serbanghita@gmail.com",
"homepage": "http://mobiledetect.net",
"role": "Developer"
}
],
"description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.",
"homepage": "https://github.com/serbanghita/Mobile-Detect",
"keywords": [
"detect mobile devices",
"mobile",
"mobile detect",
"mobile detector",
"php mobile detect"
],
"time": "2016-04-24 09:47:16"
},
{
"name": "psr/http-message",
"version": "1.0.1",
......
......@@ -22,6 +22,7 @@ return [
'transport' => 'http',
'payment_type' => '1',
'service' => 'create_direct_pay_by_user',
'wap_service' => 'alipay.wap.create.direct.pay.by.user',
],
// 'weixinpay'=>[
// 'appid'=>'wx180521eb22e9d7af',
......
......@@ -22,6 +22,7 @@ return [
'transport' => 'http',
'payment_type' => '1',
'service' => 'create_direct_pay_by_user',
'wap_service' => 'alipay.wap.create.direct.pay.by.user',
],
// 'weixinpay'=>[
// 'appid'=>'wx180521eb22e9d7af',
......
......@@ -13,6 +13,9 @@ return [
'controllerNamespace' => 'frontend\controllers',
'defaultRoute' => 'user-center',
'components' => [
'deviceDetect' => [
'class' => 'common\components\MobileDetect',
],
'request' => [
'csrfParam' => '_csrf-frontend',
],
......@@ -20,7 +23,7 @@ return [
'appendTimestamp' => TRUE,
//'baseUrl' => 'http://www.baidu.com/',
'bundles' => [
'yii\web\JqueryAsset' => false,
'yii\web\JqueryAsset' => FALSE,
]
],
'user' => [
......
......@@ -401,6 +401,9 @@ class HomeController extends \yii\web\Controller
"total_fee" => $price,//付款金额
"body" => '云崖购买',//商品描述
);
if (Yii::$app->deviceDetect->isMobile() or TRUE) {
$parameter['service'] = \Yii::$app->params['alipay']['wap_service'];
}
$html_text = $alipay->buildRequestForm($parameter, "get", "确认");
echo $html_text;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment