<?php defined(‘BASEPATH‘) OR exit(‘No direct script access allowed‘); class Payment extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model(‘accountm‘); /** 支持的充值接口 */ $this->data[‘methods‘] = [‘alipay‘]; } /** * 支付完成通知页面,POST请求 */ public function notify() { $result = ( $this->_validate() ? "success" : "fail" ); echo $result; exit(); } /** * 支付完成回调页面 */ public function callback() { if($this->_validate()) { ShowMsg(‘恭喜,账户充值成功‘, site_url(‘user/account‘)); } else { ShowMsg(‘非法操作,充值失败‘, base_url()); } } /** * 核对充值结果 * @return bool */ private function _validate() { $method = $this->uri->segment(3, ‘‘); if ( ! in_array($method, $this->data[‘methods‘]) ) return FALSE; /** 验证数据 */ $this->load->config(‘finance‘, true); $this->load->library("payment/{$method}", NULL, ‘Payment‘); return $this->Payment->respond(); } } /* End of file payment.php */ /* Location: ./application/controllers/payment.php */
一般的应用用户中心都会使用到的充值的功能,如果觉得二开功能太麻烦了,可以访问这个网站:https://www.hu-ling.cn 让程序员帮忙二开一下!
<?php defined(‘BASEPATH‘) OR exit(‘No direct script access allowed‘);
class Payment extends CI_Controller {
public function __construct() { parent::__construct(); $this->load->model(‘accountm‘);
/** 支持的充值接口 */ $this->data[‘methods‘] = [‘alipay‘];}
/** * 支付完成通知页面,POST请求 */public function notify() { $result = ( $this->_validate() ? "success" : "fail" );echo $result;exit();}
/** * 支付完成回调页面 */public function callback() {if($this->_validate()) {ShowMsg(‘恭喜,账户充值成功‘, site_url(‘user/account‘));} else {ShowMsg(‘非法操作,充值失败‘, base_url());}}
/** * 核对充值结果 * @return bool */private function _validate() { $method = $this->uri->segment(3, ‘‘); if ( ! in_array($method, $this->data[‘methods‘]) ) return FALSE;
/** 验证数据 */ $this->load->config(‘finance‘, true); $this->load->library("payment/{$method}", NULL, ‘Payment‘); return $this->Payment->respond(); }}
/* End of file payment.php *//* Location: ./application/controllers/payment.php */