Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
5b49a063
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
18
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5b49a063
编写于
1月 14, 2017
作者:
R
root
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
支付部分
上级
752b9f50
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
309 addition
and
14 deletion
+309
-14
app/appfront/config/modules/Payment.php
app/appfront/config/modules/Payment.php
+20
-0
app/appfront/modules/Checkout/block/onepage/Placeorder.php
app/appfront/modules/Checkout/block/onepage/Placeorder.php
+1
-0
app/appfront/modules/Checkout/controllers/OnepageController.php
...pfront/modules/Checkout/controllers/OnepageController.php
+3
-0
app/appfront/modules/Payment/Module.php
app/appfront/modules/Payment/Module.php
+41
-0
app/appfront/modules/Payment/controllers/CheckmoneyController.php
...ront/modules/Payment/controllers/CheckmoneyController.php
+52
-0
app/appfront/modules/Payment/controllers/paypal/ExpressController.php
.../modules/Payment/controllers/paypal/ExpressController.php
+52
-0
app/appfront/modules/Payment/controllers/paypal/StandardController.php
...modules/Payment/controllers/paypal/StandardController.php
+52
-0
app/appfront/theme/base/front/checkout/onepage/index/payment.php
...front/theme/base/front/checkout/onepage/index/payment.php
+4
-0
config/services/Payment.php
config/services/Payment.php
+18
-11
services/Payment.php
services/Payment.php
+66
-3
未找到文件。
app/appfront/config/modules/Payment.php
0 → 100644
浏览文件 @
5b49a063
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
return
[
'payment'
=>
[
'class'
=>
'\fecshop\app\appfront\modules\Payment\Module'
,
'params'
=>
[
],
],
];
app/appfront/modules/Checkout/block/onepage/Placeorder.php
浏览文件 @
5b49a063
...
...
@@ -208,6 +208,7 @@ class Placeorder{
}
}
$this
->
_shipping_method
=
$shipping_method
;
Yii
::
$service
->
payment
->
setPaymentMethod
(
$this
->
_shipping_method
);
$this
->
_payment_method
=
$payment_method
;
return
true
;
}
...
...
app/appfront/modules/Checkout/controllers/OnepageController.php
浏览文件 @
5b49a063
...
...
@@ -28,6 +28,9 @@ class OnepageController extends AppfrontController
if
(
!
$status
){
var_dump
(
Yii
::
$service
->
helper
->
errors
->
get
());
exit
;
}
else
{
$startUrl
=
Yii
::
$service
->
payment
->
getStandardStartUrl
();
}
}
...
...
app/appfront/modules/Payment/Module.php
0 → 100644
浏览文件 @
5b49a063
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace
fecshop\app\appfront\modules\Payment
;
use
Yii
;
use
fecshop\app\appfront\modules\AppfrontModule
;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class
Module
extends
AppfrontModule
{
public
$blockNamespace
;
public
function
init
()
{
# 以下代码必须指定
$nameSpace
=
__NAMESPACE__
;
# web controller
if
(
Yii
::
$app
instanceof
\
yii\web\Application
)
{
$this
->
controllerNamespace
=
$nameSpace
.
'\\controllers'
;
$this
->
blockNamespace
=
$nameSpace
.
'\\block'
;
# console controller
//} elseif (Yii::$app instanceof \yii\console\Application) {
// $this->controllerNamespace = $nameSpace . '\\console\\controllers';
// $this->blockNamespace = $nameSpace . '\\console\\block';
}
//$this->_currentDir = __DIR__ ;
//$this->_currentNameSpace = __NAMESPACE__;
# 指定默认的man文件
//$this->layout = "home.php";
Yii
::
$service
->
page
->
theme
->
layoutFile
=
'main.php'
;
parent
::
init
();
}
}
app/appfront/modules/Payment/controllers/CheckmoneyController.php
0 → 100644
浏览文件 @
5b49a063
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace
fecshop\app\appfront\modules\Payment\controllers
;
use
Yii
;
use
fec\helpers\CModule
;
use
fec\helpers\CRequest
;
use
fecshop\app\appfront\modules\AppfrontController
;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class
CheckmoneyController
extends
AppfrontController
{
public
$enableCsrfValidation
=
true
;
public
function
actionStart
(){
$data
=
$this
->
getBlock
()
->
getLastData
();
return
$this
->
render
(
$this
->
action
->
id
,
$data
);
}
public
function
actionSuccess
(){
}
public
function
actionIpn
(){
}
}
app/appfront/modules/Payment/controllers/paypal/ExpressController.php
0 → 100644
浏览文件 @
5b49a063
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace
fecshop\app\appfront\modules\Payment\controllers\paypal
;
use
Yii
;
use
fec\helpers\CModule
;
use
fec\helpers\CRequest
;
use
fecshop\app\appfront\modules\AppfrontController
;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class
ExpressController
extends
AppfrontController
{
public
$enableCsrfValidation
=
true
;
public
function
actionStart
(){
$data
=
$this
->
getBlock
()
->
getLastData
();
return
$this
->
render
(
$this
->
action
->
id
,
$data
);
}
public
function
actionSuccess
(){
}
public
function
actionIpn
(){
}
}
app/appfront/modules/Payment/controllers/paypal/StandardController.php
0 → 100644
浏览文件 @
5b49a063
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace
fecshop\app\appfront\modules\Payment\controllers\paypal
;
use
Yii
;
use
fec\helpers\CModule
;
use
fec\helpers\CRequest
;
use
fecshop\app\appfront\modules\AppfrontController
;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class
StandardController
extends
AppfrontController
{
public
$enableCsrfValidation
=
true
;
public
function
actionStart
(){
$data
=
$this
->
getBlock
()
->
getLastData
();
return
$this
->
render
(
$this
->
action
->
id
,
$data
);
}
public
function
actionSuccess
(){
}
public
function
actionIpn
(){
}
}
app/appfront/theme/base/front/checkout/onepage/index/payment.php
浏览文件 @
5b49a063
...
...
@@ -15,7 +15,11 @@
<dd
id=
"container_payment_method_
<?=
$payment
?>
"
class=
"payment-method"
style=
""
>
<ul
class=
"form-list"
id=
"payment_form_
<?=
$payment
?>
"
style=
""
>
<li>
<?php
if
(
isset
(
$info
[
'imageUrl'
])
&&
!
empty
(
$info
[
'imageUrl'
])){
?>
<img
style=
"margin:10px 0 8px 0"
src=
"
<?=
$info
[
'imageUrl'
]
?>
"
>
<?php
}
?>
</li>
<li
class=
"form-alt"
>
<?=
$info
[
'supplement'
]
?>
...
...
config/services/Payment.php
浏览文件 @
5b49a063
...
...
@@ -10,21 +10,28 @@ return [
'class'
=>
'fecshop\services\Payment'
,
'paymentConfig'
=>
[
'standard'
=>
[
'paypal_standard'
=>
[
'label'
=>
'PayPal Website Payments Standard'
,
'image'
=>
[
'images/paypal_standard.png'
,
'common'
],
# 支付页面显示的图片。
'supplement'
=>
'You will be redirected to the PayPal website when you place an order. '
,
# 补充
'check_money'
=>
[
'label'
=>
'Check / Money Order'
,
//'image' => ['images/mastercard.png','common'] ,# 支付页面显示的图片。
'supplement'
=>
'Off-line Money Payments'
,
# 补充
'style'
=>
'<style></style>'
,
# 补充css
'start_url'
=>
'@homeUrl/payment/checkmoney/start'
,
'success_redirect_url'
=>
'@homeUrl/payment/checkmoney/success'
,
],
'credit_card'
=>
[
'label'
=>
'Credit Card'
,
'image'
=>
[
'images/mastercard.png'
,
'common'
]
,
# 支付页面显示的图片。
'supplement'
=>
''
,
# 补充
'style'
=>
'<style></style>'
,
# 补充css
'paypal_standard'
=>
[
'label'
=>
'PayPal Website Payments Standard'
,
'image'
=>
[
'images/paypal_standard.png'
,
'common'
],
# 支付页面显示的图片。
'supplement'
=>
'You will be redirected to the PayPal website when you place an order. '
,
# 补充
'start_url'
=>
'@homeUrl/payment/paypal/standard/start'
,
'IPN_url'
=>
'@homeUrl/payment/paypal/standard/ipn'
,
'success_redirect_url'
=>
'@homeUrl/payment/paypal/standard/success'
,
],
],
'express'
=>
[
],
]
]
];
\ No newline at end of file
services/Payment.php
浏览文件 @
5b49a063
...
...
@@ -21,13 +21,76 @@ class Payment extends Service
{
public
$paymentConfig
;
protected
$_currentPaymentMethod
;
public
function
setPaymentMethod
(
$payment_method
){
$this
->
_currentPaymentMethod
=
$payment_method
;
}
public
function
getPaymentMethod
(){
return
$this
->
_currentPaymentMethod
;
}
/**
* @property $payment_method | String 支付方式。
* @return 返回提交订单信息跳转到的第三方支付url,也就是第三方支付的url。
*/
public
function
getStandardStartUrl
(
$payment_method
=
''
){
if
(
!
$payment_method
){
$payment_method
=
$this
->
getPaymentMethod
();
}
if
(
$payment_method
){
$paymentConfig
=
$this
->
paymentConfig
;
if
(
isset
(
$paymentConfig
[
'standard'
][
$payment_method
][
'start_url'
])){
if
(
!
empty
(
$paymentConfig
[
'standard'
][
$payment_method
][
'start_url'
])){
return
$this
->
getUrl
(
$paymentConfig
[
'standard'
][
$payment_method
][
'start_url'
]);
}
}
}
}
/**
* @property $payment_method | String 支付方式。
* @return 第三方支付成功后,返回到网站的url
*/
public
function
getStandardSuccessRedirectUrl
(
$payment_method
=
''
){
if
(
!
$payment_method
){
$payment_method
=
$this
->
getPaymentMethod
();
}
if
(
$payment_method
){
$paymentConfig
=
$this
->
paymentConfig
;
if
(
isset
(
$paymentConfig
[
'standard'
][
$payment_method
][
'success_redirect_url'
])){
if
(
!
empty
(
$paymentConfig
[
'standard'
][
$payment_method
][
'success_redirect_url'
])){
return
$this
->
getUrl
(
$paymentConfig
[
'standard'
][
$payment_method
][
'success_redirect_url'
]);
}
}
}
}
/**
* @property $payment_method | String 支付方式。
* @return 第三方网站发送ipn消息,告诉网站支付成功的url。
*/
public
function
getStandardIpnUrl
(
$payment_method
=
''
){
if
(
!
$payment_method
){
$payment_method
=
$this
->
getPaymentMethod
();
}
if
(
$payment_method
){
$paymentConfig
=
$this
->
paymentConfig
;
if
(
isset
(
$paymentConfig
[
'standard'
][
$payment_method
][
'IPN_url'
])){
if
(
!
empty
(
$paymentConfig
[
'standard'
][
$payment_method
][
'IPN_url'
])){
return
$this
->
getUrl
(
$paymentConfig
[
'standard'
][
$payment_method
][
'IPN_url'
]);
}
}
}
}
protected
function
getUrl
(
$url
){
$homeUrl
=
Yii
::
$service
->
url
->
homeUrl
();
$url
=
str_replace
(
'@homeUrl'
,
$homeUrl
,
$url
);
return
trim
(
$url
);
}
/**
* @return Array
得到所有支付的数组。
* @return Array
得到所有支付的数组。
*/
public
function
getStandardPaymentArr
(){
$arr
=
[];
if
(
isset
(
$this
->
paymentConfig
[
'standard'
])
&&
is_array
(
$this
->
paymentConfig
[
'standard'
])
...
...
@@ -54,7 +117,7 @@ class Payment extends Service
/**
* @property $shipping_method | String
* @return boolean
发货方式
* @return boolean
发货方式
*/
protected
function
actionIfIsCorrectStandard
(
$payment_method
){
$paymentConfig
=
$this
->
paymentConfig
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录