1. 维护代码健壮

2. 更新项目结构文档
This commit is contained in:
技术老胡
2026-04-27 16:20:41 +08:00
parent 9a16a88640
commit 0e5de50337
198 changed files with 21038 additions and 702 deletions

View File

@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>正在为您跳转到支付页面,请稍候...</title>
<style type="text/css">
body{margin:0;padding:0}
p{position:absolute;left:50%;top:50%;height:35px;margin:-35px 0 0 -160px;padding:20px;font:bold 16px/30px "宋体",Arial;text-indent:40px;border:1px solid #c5d0dc}
#waiting{font-family:Arial}
</style>
</head>
<body>
<?php
require_once("lib/epay.config.php");
require_once("lib/EpayCore.class.php");
/**************************请求参数**************************/
$notify_url = "http://127.0.0.1/SDK/notify_url.php";
//需http://格式的完整路径,不能加?id=123这类自定义参数
//页面跳转同步通知页面路径
$return_url = "http://127.0.0.1/SDK/return_url.php";
//需http://格式的完整路径,不能加?id=123这类自定义参数
//商户订单号
$out_trade_no = $_POST['WIDout_trade_no'];
//商户网站订单系统中唯一订单号,必填
//支付方式可传入alipay,wxpay,qqpay,bank,jdpay
$type = $_POST['type'];
//商品名称
$name = $_POST['WIDsubject'];
//付款金额
$money = $_POST['WIDtotal_fee'];
/************************************************************/
//构造要请求的参数数组,无需改动
$parameter = array(
"pid" => $epay_config['pid'],
"type" => $type,
"notify_url" => $notify_url,
"return_url" => $return_url,
"out_trade_no" => $out_trade_no,
"name" => $name,
"money" => $money,
);
//建立请求
$epay = new EpayCore($epay_config);
$html_text = $epay->pagePay($parameter);
echo $html_text;
?>
<p>正在为您跳转到支付页面,请稍候...</p>
</body>
</html>

View File

@@ -0,0 +1,205 @@
<?php
/* *
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>彩虹易支付接口测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
*{
margin:0;
padding:0;
}
ul,ol{
list-style:none;
}
.title{
color: #ADADAD;
font-size: 14px;
font-weight: bold;
padding: 8px 16px 5px 10px;
}
.hidden{
display:none;
}
.new-btn-login-sp{
border:1px solid #D74C00;
padding:1px;
display:inline-block;
}
.new-btn-login{
background-color: #ff8c00;
color: #FFFFFF;
font-weight: bold;
border: medium none;
width:82px;
height:28px;
}
.new-btn-login:hover{
background-color: #ffa300;
width: 82px;
color: #FFFFFF;
font-weight: bold;
height: 28px;
}
.bank-list{
overflow:hidden;
margin-top:5px;
}
.bank-list li{
float:left;
width:153px;
margin-bottom:5px;
}
#main{
width:750px;
margin:0 auto;
font-size:14px;
font-family:'宋体';
}
#logo{
background-color: transparent;
background-image: url("images/new-btn-fixed.png");
border: medium none;
background-position:0 0;
width:166px;
height:35px;
float:left;
}
.red-star{
color:#f00;
width:10px;
display:inline-block;
}
.null-star{
color:#fff;
}
.content{
margin-top:5px;
}
.content dt{
width:160px;
display:inline-block;
text-align:right;
float:left;
}
.content dd{
margin-left:100px;
margin-bottom:5px;
}
#foot{
margin-top:10px;
}
.foot-ul li {
text-align:center;
}
.note-help {
color: #999999;
font-size: 12px;
line-height: 130%;
padding-left: 3px;
}
.cashier-nav {
font-size: 14px;
margin: 15px 0 10px;
text-align: left;
height:30px;
border-bottom:solid 2px #CFD2D7;
}
.cashier-nav ol li {
float: left;
}
.cashier-nav li.current {
color: #AB4400;
font-weight: bold;
}
.cashier-nav li.last {
clear:right;
}
.alipay_link {
text-align:right;
}
.alipay_link a:link{
text-decoration:none;
color:#8D8D8D;
}
.alipay_link a:visited{
text-decoration:none;
color:#8D8D8D;
}
</style>
</head>
<body text=#000000 bgColor=#ffffff leftMargin=0 topMargin=4>
<div id="main">
<div id="head">
<dl class="alipay_link">
</dl>
<span class="title">彩虹易支付接口测试</span>
</div>
<div class="cashier-nav">
<ol>
<li class="current">1、确认信息 →</li>
<li>2、点击确认 →</li>
<li class="last">3、确认完成</li>
</ol>
</div>
<form name=alipayment action=epayapi.php method=post target="_blank">
<div id="body" style="clear:left">
<dl class="content">
<dt>商户订单号:</dt>
<dd>
<span class="null-star">*</span>
<input size="30" name="WIDout_trade_no" value="<?php echo date("YmdHis").mt_rand(100,999); ?>"/>
<span>商户网站订单系统中唯一订单号,必填
</span>
</dd>
<dt>商品名称:</dt>
<dd>
<span class="null-star">*</span>
<input size="30" name="WIDsubject" value="测试商品"/>
<span>必填
</span>
</dd>
<dt>付款金额:</dt>
<dd>
<span class="null-star">*</span>
<input size="30" name="WIDtotal_fee" value="1"/>
<span>必填
</span>
</dd>
<dt>支付方式:</dt>
<dd>
<label><input type="radio" name="type" value="alipay" checked="">支付宝</label>&nbsp; <label><input type="radio" name="type" value="qqpay">QQ钱包</label>&nbsp;<label><input type="radio" name="type" value="wxpay">微信支付</label>&nbsp;<label><input type="radio" name="type" value="bank">云闪付</label>
</dd>
<dt></dt>
<dd>
<span class="new-btn-login-sp">
<button class="new-btn-login" type="submit" style="text-align:center;">确 认</button>
</span>
</dd>
</dl>
</div>
</form>
<div id="foot">
<ul class="foot-ul">
<li><font class="note-help">如果您点击“确认”按钮,即表示您同意该次的执行操作。 </font></li>
<li>
</li>
</ul>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,154 @@
<?php
/* *
* 彩虹易支付SDK服务类
* 说明:
* 包含发起支付、查询订单、回调验证等功能
*/
class EpayCore
{
private $pid;
private $key;
private $submit_url;
private $mapi_url;
private $api_url;
private $sign_type = 'MD5';
function __construct($config){
$this->pid = $config['pid'];
$this->key = $config['key'];
$this->submit_url = $config['apiurl'].'submit.php';
$this->mapi_url = $config['apiurl'].'mapi.php';
$this->api_url = $config['apiurl'].'api.php';
}
// 发起支付(页面跳转)
public function pagePay($param_tmp, $button='正在跳转'){
$param = $this->buildRequestParam($param_tmp);
$html = '<form id="dopay" action="'.$this->submit_url.'" method="post">';
foreach ($param as $k=>$v) {
$html.= '<input type="hidden" name="'.$k.'" value="'.$v.'"/>';
}
$html .= '<input type="submit" value="'.$button.'"></form><script>document.getElementById("dopay").submit();</script>';
return $html;
}
// 发起支付(获取链接)
public function getPayLink($param_tmp){
$param = $this->buildRequestParam($param_tmp);
$url = $this->submit_url.'?'.http_build_query($param);
return $url;
}
// 发起支付API接口
public function apiPay($param_tmp){
$param = $this->buildRequestParam($param_tmp);
$response = $this->getHttpResponse($this->mapi_url, http_build_query($param));
$arr = json_decode($response, true);
return $arr;
}
// 异步回调验证
public function verifyNotify(){
if(empty($_GET)) return false;
$sign = $this->getSign($_GET);
if($sign === $_GET['sign']){
$signResult = true;
}else{
$signResult = false;
}
return $signResult;
}
// 同步回调验证
public function verifyReturn(){
if(empty($_GET)) return false;
$sign = $this->getSign($_GET);
if($sign === $_GET['sign']){
$signResult = true;
}else{
$signResult = false;
}
return $signResult;
}
// 查询订单支付状态
public function orderStatus($trade_no){
$result = $this->queryOrder($trade_no);
if($result['status']==1){
return true;
}else{
return false;
}
}
// 查询订单
public function queryOrder($trade_no){
$url = $this->api_url.'?act=order&pid=' . $this->pid . '&key=' . $this->key . '&trade_no=' . $trade_no;
$response = $this->getHttpResponse($url);
$arr = json_decode($response, true);
return $arr;
}
// 订单退款
public function refund($trade_no, $money){
$url = $this->api_url.'?act=refund';
$post = 'pid=' . $this->pid . '&key=' . $this->key . '&trade_no=' . $trade_no . '&money=' . $money;
$response = $this->getHttpResponse($url, $post);
$arr = json_decode($response, true);
return $arr;
}
private function buildRequestParam($param){
$mysign = $this->getSign($param);
$param['sign'] = $mysign;
$param['sign_type'] = $this->sign_type;
return $param;
}
// 计算签名
private function getSign($param){
ksort($param);
reset($param);
$signstr = '';
foreach($param as $k => $v){
if($k != "sign" && $k != "sign_type" && $v!=''){
$signstr .= $k.'='.$v.'&';
}
}
$signstr = substr($signstr,0,-1);
$signstr .= $this->key;
$sign = md5($signstr);
return $sign;
}
// 请求外部资源
private function getHttpResponse($url, $post = false, $timeout = 10){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept: */*";
$httpheader[] = "Accept-Language: zh-CN,zh;q=0.8";
$httpheader[] = "Connection: close";
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if($post){
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
}

View File

@@ -0,0 +1,13 @@
<?php
/* *
* 配置文件
*/
//支付接口地址
$epay_config['apiurl'] = 'http://pay.www.com/';
//商户ID
$epay_config['pid'] = '1000';
//商户密钥
$epay_config['key'] = 'WWc3Z2jkK7jhNGPALcGKjHLPK47wRK85';

View File

@@ -0,0 +1,45 @@
<?php
/* *
* 功能:彩虹易支付异步通知页面
* 说明:
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
*/
require_once("lib/epay.config.php");
require_once("lib/EpayCore.class.php");
//计算得出通知验证结果
$epay = new EpayCore($epay_config);
$verify_result = $epay->verifyNotify();
if($verify_result) {//验证成功
//商户订单号
$out_trade_no = $_GET['out_trade_no'];
//彩虹易支付交易号
$trade_no = $_GET['trade_no'];
//交易状态
$trade_status = $_GET['trade_status'];
//支付方式
$type = $_GET['type'];
//支付金额
$money = $_GET['money'];
if ($_GET['trade_status'] == 'TRADE_SUCCESS') {
//判断该笔订单是否在商户网站中已经做过处理
//如果没有做过处理根据订单号out_trade_no在商户网站的订单系统中查到该笔订单的详细并执行商户的业务程序
//如果有做过处理,不执行商户的业务程序
}
//验证成功返回
echo "success";
}
else {
//验证失败
echo "fail";
}
?>

View File

@@ -0,0 +1,55 @@
<?php
/* *
* 功能:彩虹易支付页面跳转同步通知页面
* 说明:
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
*/
require_once("lib/epay.config.php");
require_once("lib/EpayCore.class.php");
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>支付返回页面</title>
</head>
<body>
<?php
//计算得出通知验证结果
$epay = new EpayCore($epay_config);
$verify_result = $epay->verifyReturn();
if($verify_result) {//验证成功
//商户订单号
$out_trade_no = $_GET['out_trade_no'];
//支付宝交易号
$trade_no = $_GET['trade_no'];
//交易状态
$trade_status = $_GET['trade_status'];
//支付方式
$type = $_GET['type'];
if($_GET['trade_status'] == 'TRADE_SUCCESS') {
//判断该笔订单是否在商户网站中已经做过处理
//如果没有做过处理根据订单号out_trade_no在商户网站的订单系统中查到该笔订单的详细并执行商户的业务程序
//如果有做过处理,不执行商户的业务程序
}
else {
echo "trade_status=".$_GET['trade_status'];
}
echo "<h3>验证成功</h3><br />";
}
else {
//验证失败
echo "<h3>验证失败</h3>";
}
?>
</body>
</html>

View File

@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>正在为您跳转到支付页面,请稍候...</title>
<style type="text/css">
body{margin:0;padding:0}
p{position:absolute;left:50%;top:50%;height:35px;margin:-35px 0 0 -160px;padding:20px;font:bold 16px/30px "宋体",Arial;text-indent:40px;border:1px solid #c5d0dc}
#waiting{font-family:Arial}
</style>
</head>
<body>
<?php
require_once("lib/epay.config.php");
require_once("lib/EpayCore.class.php");
/**************************请求参数**************************/
$notify_url = "http://127.0.0.1/SDK/notify_url.php";
//需http://格式的完整路径,不能加?id=123这类自定义参数
//页面跳转同步通知页面路径
$return_url = "http://127.0.0.1/SDK/return_url.php";
//需http://格式的完整路径,不能加?id=123这类自定义参数
//商户订单号
$out_trade_no = $_POST['out_trade_no'];
//商户网站订单系统中唯一订单号,必填
//支付方式可传入alipay,wxpay,qqpay,bank,jdpay
$type = $_POST['type'];
//商品名称
$name = $_POST['name'];
//付款金额
$money = $_POST['money'];
/************************************************************/
//构造要请求的参数数组,无需改动
$parameter = array(
"type" => $type,
"notify_url" => $notify_url,
"return_url" => $return_url,
"out_trade_no" => $out_trade_no,
"name" => $name,
"money" => $money,
);
//建立请求
$epay = new EpayCore($epay_config);
$html_text = $epay->pagePay($parameter);
echo $html_text;
?>
<p>正在为您跳转到支付页面,请稍候...</p>
</body>
</html>

View File

@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html lang="zh-CN">
<body>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title>彩虹易支付接口测试</title>
<link href="//lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="./assets/css/captcha.css" type="text/css" />
<style>.form-group{margin-bottom:18px} #captcha{margin: auto;margin-bottom:16px}</style>
</head>
<div class="container">
<div class="col-xs-12 col-sm-10 col-lg-8 center-block" style="float: none;">
<div class="page-header">
<h4>彩虹易支付接口测试</h4>
</div>
<div class="panel panel-primary">
<div class="panel-body">
<form name="alipayment" method="POST" action="epayapi.php" class="form-horizontal">
<div class="form-group">
<label class="col-sm-3 control-label">商户订单号</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="out_trade_no" value="<?php echo date("YmdHis").mt_rand(100,999); ?>" autocomplete="off">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">商品名称</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="name" value="支付测试" autocomplete="off">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">支付金额</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="money" value="1" autocomplete="off">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">支付方式</label>
<div class="col-sm-8">
<div class="radio">
<label class="i-checks"><input type="radio" name="type" value="alipay" checked="checked"><i></i>支付宝</label>&nbsp;
<label class="i-checks"><input type="radio" name="type" value="wxpay"><i></i>微信支付</label>&nbsp;
<label class="i-checks"><input type="radio" name="type" value="qqpay"><i></i>QQ钱包</label>&nbsp;
<label class="i-checks"><input type="radio" name="type" value="bank"><i></i>云闪付</label>&nbsp;
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-8"><input type="submit" value="确 认" class="btn btn-primary form-control"><br>
</div>
</div>
</form>
</div>
<div class="panel-footer text-center">
<span class="text-muted">此页面只是为了方便商户测试而提供的样例页面,商户可以根据自己网站的需要,按照技术文档编写</span>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,184 @@
<?php
/* *
* 彩虹易支付SDK服务类
* 说明:
* 包含发起支付、查询订单、回调验证等功能
*/
class EpayCore
{
private $apiurl;
private $pid;
private $platform_public_key;
private $merchant_private_key;
private $sign_type = 'RSA';
function __construct($config){
$this->apiurl = $config['apiurl'];
$this->pid = $config['pid'];
$this->platform_public_key = $config['platform_public_key'];
$this->merchant_private_key = $config['merchant_private_key'];
}
// 发起支付(页面跳转)
public function pagePay($param_tmp, $button='正在跳转'){
$requrl = $this->apiurl.'api/pay/submit';
$param = $this->buildRequestParam($param_tmp);
$html = '<form id="dopay" action="'.$requrl.'" method="post">';
foreach ($param as $k=>$v) {
$html.= '<input type="hidden" name="'.$k.'" value="'.$v.'"/>';
}
$html .= '<input type="submit" value="'.$button.'"></form><script>document.getElementById("dopay").submit();</script>';
return $html;
}
// 发起支付(获取链接)
public function getPayLink($param_tmp){
$requrl = $this->apiurl.'api/pay/submit';
$param = $this->buildRequestParam($param_tmp);
$url = $requrl.'?'.http_build_query($param);
return $url;
}
// 发起支付API接口
public function apiPay($params){
return $this->execute('api/pay/create', $params);
}
// 发起API请求
public function execute($path, $params){
$path = ltrim($path, '/');
$requrl = $this->apiurl.$path;
$param = $this->buildRequestParam($params);
$response = $this->getHttpResponse($requrl, http_build_query($param));
$arr = json_decode($response, true);
if($arr && $arr['code'] == 0){
if(!$this->verify($arr)){
throw new \Exception('返回数据验签失败');
}
return $arr;
}else{
throw new \Exception($arr ? $arr['msg'] : '请求失败');
}
}
// 回调验证
public function verify($arr){
if(empty($arr) || empty($arr['sign'])) return false;
if(empty($arr['timestamp']) || abs(time() - $arr['timestamp']) > 300) return false;
$sign = $arr['sign'];
return $this->rsaPublicVerify($this->getSignContent($arr), $sign);
}
// 查询订单支付状态
public function orderStatus($trade_no){
$result = $this->queryOrder($trade_no);
if($result && $result['status']==1){
return true;
}else{
return false;
}
}
// 查询订单
public function queryOrder($trade_no){
$params = [
'trade_no' => $trade_no,
];
return $this->execute('api/pay/query', $params);
}
// 订单退款
public function refund($out_refund_no, $trade_no, $money){
$params = [
'trade_no' => $trade_no,
'money' => $money,
'out_refund_no' => $out_refund_no,
];
return $this->execute('api/pay/refund', $params);
}
private function buildRequestParam($params){
$params['pid'] = $this->pid;
$params['timestamp'] = time().'';
$mysign = $this->getSign($params);
$params['sign'] = $mysign;
$params['sign_type'] = $this->sign_type;
return $params;
}
// 生成签名
private function getSign($params){
return $this->rsaPrivateSign($this->getSignContent($params));
}
// 获取待签名字符串
private function getSignContent($params){
ksort($params);
$signstr = '';
foreach ($params as $k => $v) {
if(is_array($v) || $this->isEmpty($v) || $k == 'sign' || $k == 'sign_type') continue;
$signstr .= '&' . $k . '=' . $v;
}
$signstr = substr($signstr, 1);
return $signstr;
}
private function isEmpty($value)
{
return $value === null || trim($value) === '';
}
// 商户私钥签名
private function rsaPrivateSign($data){
$key = "-----BEGIN PRIVATE KEY-----\n" .
wordwrap($this->merchant_private_key, 64, "\n", true) .
"\n-----END PRIVATE KEY-----";
$privatekey = openssl_get_privatekey($key);
if(!$privatekey){
throw new \Exception('签名失败,商户私钥错误');
}
openssl_sign($data, $sign, $privatekey, OPENSSL_ALGO_SHA256);
return base64_encode($sign);
}
// 平台公钥验签
private function rsaPublicVerify($data, $sign){
$key = "-----BEGIN PUBLIC KEY-----\n" .
wordwrap($this->platform_public_key, 64, "\n", true) .
"\n-----END PUBLIC KEY-----";
$publickey = openssl_get_publickey($key);
if (!$publickey) {
throw new \Exception("验签失败,平台公钥错误");
}
$result = openssl_verify($data, base64_decode($sign), $publickey, OPENSSL_ALGO_SHA256);
return $result === 1;
}
// 请求外部资源
private function getHttpResponse($url, $post = false, $timeout = 10){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept: */*";
$httpheader[] = "Accept-Language: zh-CN,zh;q=0.8";
$httpheader[] = "Connection: close";
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if($post){
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
}

View File

@@ -0,0 +1,19 @@
<?php
/* *
* 配置文件
*/
$epay_config = [
//支付接口地址
'apiurl' => 'http://pay.www.com/',
//商户ID
'pid' => '1000',
//平台公钥
'platform_public_key' => 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApHG7SIN16fd9uZfjZunZuAReemVQe5YNxBhbkogsRkZ86xuDVDCmhRXEzw7Ta3tXPnMIFRJFdjOCfFVarqcOLICtBiiZZ7Y4D6aIMhmOSliIJ3qWUnU75Wr2WMTIJ1o2pnPmczQ2YjAAy1DtQCc/qs35j24zuNYZw2WluSdiMckPFgge93RK6cq/Feqfuzq7y+m87x02gxbbTGVf24YH2f7H9qZSKCxRXHQoVIWTlyHULcY3OY+1CVdU2SKlIWHJ31eoPznXBLUo0UB0rNZnYrHG2mIlD2S119UTwZwx9WTG/v7Cb2lHVybjfL5/KLitddfqcLjJsYXh6KhEtsO6CwIDAQAB',
//商户私钥
'merchant_private_key' => 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCBIB1e5lAYtFyXq5I8UIQ6KidYZcWkn0SwVS8Rk0SNZVrvL/UJk6Q1zkJs4pUCykTBS/tTrP2rNPOsK1VO/AQHIzhvAujsv7UK2LptcsuNRPCF5GYxndQnOawAGKNQKsMuNcDzyuyTMbZIBEYSRWIoU3dMz4wWEFso/VdVS4uKTZWZnBOeCDdzDAJ7TwbmaOkT919DfZbXAoMH9n3sG4BMpqQExTDoFY6dq6EPXCWVZgoUfecAgNKSfX5TagSUaAxq4eF5vsUfvj+LFpYIrIssmSVErtZuRXLHWVSEbsNxdDPNuS3BtxWEY7GRPF9RJevtoC5L5LN7Gn+RYCqZNZv7AgMBAAECggEAEA6ZTb11hQzwsrUAM1s5MNkgbsABIDk6BnTMAfMpRC1awyxYhqoDHTnFTYWuTVwvyUW/PtGKnelbdTPSS5x6jRSr0N+GGDgNYF2Wbpkm3Ni6Jubsb7ZrtRED5Y3Vc9j4JTKZXaJaDEJ9+LNSBLWiFi0C7zH5U/O8ElB8CrxL4ZUaZv0JgV9NcDpS5jAtpPSyBLrdhbEheertJiHQU0V+FaaXq8taNcYIA/Xim6+vqcFFtUA3PBBTXHn/NE5uasXi+N+De4IT+dBmirzVSZjviDPr9RSBUi6KPUSXx6eDa26SKeEqJZvBtlASDM+ZC0yhDz0eyV49tMjk7eF5fnCIwQKBgQC2nEiR2t5Q02tHaKesZMRGOwxEyMFQj6viDW+Yffg59Tu6QYuqdR558/zmzWcJFMH3DVQzTXpzPNU9TA3/yT/Q42iKBP70K8O9tJO+gd/jLHLqgw90Wyh2b4FJXXQqVQMkxGBQKRfNi6krWigJNBs8Z8IhczorQHYNbBIUI05poQKBgQC1BRI8zKf+85GuJXTxJ93RXbkOQMUIhT/6eyFTZvCLC9Qqba1/1ouNbtmxNsFFIC+n+rHRN9btKt90m9YFvXD90m3y34M88QjvaQcA1Kng9Q6Xia8DizpVIYGAR/Pfn36BZQeHHVz9te6QJ9hVOgZO3GG62Echd9M/rwOzuU14GwKBgFGtS2Q5khByz9wLuluIYqXLCWzGoninGkksm0qIpXs+7e0cHh0q72u6rtaI7toH983Jn2ym7esXPYWCPAy5dhq3bG23WFXcMVvrpd2i94IDwo6T+lif4VRAAYLQEwJQLezHDREtoCDmo87pL1kWfkwhWJpfkJgB6AuO1/M763mhAoGBAIPEGj9plcwOzndeSp6UL3IMb/1BBmuqWyTgZiTIpMYCKUFtLsMEj/a2vv2xZsQDpsz2vmMV63weHiRKn2L0QABzIZeOPYCpz6A96lwfcT0QBLwn+95vhVmclyCiv5GDDtnviag/poYD3ZDPgDihkR/sabNRZY2mJH6RzfcQJqULAoGALkSkqr0bplhfyAA6bO42l64th4YUqwouTEgp7rE36wQ28THj0a88HLU4CeiCR6LQAEGpKk04Vst97C1Q5ZeD5rc4xKINl8K5HUH8SsdMDq3r22xur2qr4kanW4hf2P/ehOeEKGuhSL+ZWeApvt1c0rqH4MQT1/7qR/dO2MikkMg=',
];

View File

@@ -0,0 +1,45 @@
<?php
/* *
* 功能:彩虹易支付异步通知页面
* 说明:
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
*/
require_once("lib/epay.config.php");
require_once("lib/EpayCore.class.php");
//计算得出通知验证结果
$epay = new EpayCore($epay_config);
$verify_result = $epay->verify($_GET);
if($verify_result) {//验证成功
//商户订单号
$out_trade_no = $_GET['out_trade_no'];
//彩虹易支付交易号
$trade_no = $_GET['trade_no'];
//交易状态
$trade_status = $_GET['trade_status'];
//支付方式
$type = $_GET['type'];
//支付金额
$money = $_GET['money'];
if ($_GET['trade_status'] == 'TRADE_SUCCESS') {
//判断该笔订单是否在商户网站中已经做过处理
//如果没有做过处理根据订单号out_trade_no在商户网站的订单系统中查到该笔订单的详细并执行商户的业务程序
//如果有做过处理,不执行商户的业务程序
}
//验证成功返回
echo "success";
}
else {
//验证失败
echo "fail";
}
?>

View File

@@ -0,0 +1,17 @@
<?php
/**
* 查询订单
*/
require_once("lib/epay.config.php");
require_once("lib/EpayCore.class.php");
$trade_no = '2024071519404366151';
$epay = new EpayCore($epay_config);
try{
$result = $epay->queryOrder($trade_no);
}catch(Exception $e){
echo $e->getMessage();
exit;
}
print_r($result);

View File

@@ -0,0 +1,19 @@
<?php
/**
* 退款
*/
require_once("lib/epay.config.php");
require_once("lib/EpayCore.class.php");
$out_refund_no = date("YmdHis").rand(111,999);
$trade_no = '2024071519404366151';
$money = '1.00';
$epay = new EpayCore($epay_config);
try{
$result = $epay->refund($out_refund_no, $trade_no, $money);
}catch(Exception $e){
echo $e->getMessage();
exit;
}
print_r($result);

View File

@@ -0,0 +1,55 @@
<?php
/* *
* 功能:彩虹易支付页面跳转同步通知页面
* 说明:
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
*/
require_once("lib/epay.config.php");
require_once("lib/EpayCore.class.php");
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>支付返回页面</title>
</head>
<body>
<?php
//计算得出通知验证结果
$epay = new EpayCore($epay_config);
$verify_result = $epay->verify($_GET);
if($verify_result) {//验证成功
//商户订单号
$out_trade_no = $_GET['out_trade_no'];
//支付宝交易号
$trade_no = $_GET['trade_no'];
//交易状态
$trade_status = $_GET['trade_status'];
//支付方式
$type = $_GET['type'];
if($_GET['trade_status'] == 'TRADE_SUCCESS') {
//判断该笔订单是否在商户网站中已经做过处理
//如果没有做过处理根据订单号out_trade_no在商户网站的订单系统中查到该笔订单的详细并执行商户的业务程序
//如果有做过处理,不执行商户的业务程序
}
else {
echo "trade_status=".$_GET['trade_status'];
}
echo "<h3>验证成功</h3><br />";
}
else {
//验证失败
echo "<h3>验证失败</h3>";
}
?>
</body>
</html>