提交 5b49a063 编写于 作者: R root

支付部分

上级 752b9f50
<?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'=> [
],
],
];
......@@ -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;
}
......
......@@ -28,6 +28,9 @@ class OnepageController extends AppfrontController
if(!$status){
var_dump(Yii::$service->helper->errors->get());
exit;
}else{
$startUrl = Yii::$service->payment->getStandardStartUrl();
}
}
......
<?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();
}
}
<?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(){
}
}
<?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(){
}
}
<?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(){
}
}
......@@ -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'] ?>
......
......@@ -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
......@@ -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.
先完成此消息的编辑!
想要评论请 注册