207 行
5.5 KiB
PHP
可执行文件
207 行
5.5 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace Pay\Library\Cloud;
|
|
|
|
use Pay\Library\Cloud\Cloud as CloudObj;
|
|
|
|
//[1.7.14]
|
|
|
|
/** 云闪付支付
|
|
* Class StarWxPay
|
|
* @package app\common\library\wechat
|
|
*/
|
|
class CloudAliPay
|
|
{
|
|
/**
|
|
* 构造方法
|
|
* WxPay constructor.
|
|
* @param $config
|
|
*/
|
|
static private $errmsg = "CloudAliPay";
|
|
static private $merinfo = [];
|
|
|
|
/** 构造函数,获取该商户所有的相关配置信息
|
|
* StarWxPay constructor.
|
|
* @param $config
|
|
* @throws \think\Exception
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public function __construct($config)
|
|
{
|
|
$merinfo['merid'] = $config['cloud_mer_id'];
|
|
$merinfo['serprovid'] = $config['serprovid'];
|
|
$merinfo['acqcode'] = $config['acqcode'];
|
|
$merinfo['prodkey'] = $config['prodkey'];
|
|
$merinfo['prvkey'] = $config['prvkey'];
|
|
$merinfo['pubkey'] = $config['pubkey'];
|
|
$merinfo['backUrl'] = isset($config['backUrl']) ? $config['backUrl'] : '';
|
|
self::$merinfo = $merinfo;
|
|
}
|
|
|
|
public function setBackUrl($backUrl)
|
|
{
|
|
self::$merinfo['backUrl'] = $backUrl;
|
|
return $this;
|
|
}
|
|
|
|
/** 生成支付二维码
|
|
* @param $order_no
|
|
* @param $code
|
|
* @param $total_fee
|
|
* @param $body
|
|
* @return bool
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public function native($order_no, $total_fee, $body = '购买商品')
|
|
{
|
|
$merinfo = self::$merinfo;
|
|
$obj = new CloudObj($merinfo);
|
|
$data["orderNo"] = $order_no;
|
|
$data["pay_price"] = $total_fee;
|
|
$data["orderType"] = "alipay";
|
|
$data["body"] = $body;
|
|
$cache = $obj->barCodeAll($data);
|
|
if ($cache) {
|
|
return $cache;
|
|
} else {
|
|
self::$errmsg = $obj->getMsg();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/** 云闪付统一刷卡接口
|
|
* @param $order_no
|
|
* @param $code
|
|
* @param $total_fee
|
|
* @param $body
|
|
* @return bool
|
|
*/
|
|
public function slotCard($order_no, $code, $total_fee, $body)
|
|
{
|
|
$merinfo = self::$merinfo;
|
|
$obj = new CloudObj($merinfo);
|
|
$cache = $obj->slotCard($order_no, $code, $total_fee, $body, "alipay");
|
|
if ($cache) {
|
|
return true;
|
|
} else {
|
|
self::$errmsg = $obj->getMsg();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/** 云闪付统一刷卡接口
|
|
* @param $order_no
|
|
* @param $code
|
|
* @param $total_fee
|
|
* @param $body
|
|
* @return bool 2020-12-23
|
|
*/
|
|
public function slotCard_v1($order_no, $code, $total_fee, $body)
|
|
{
|
|
$merinfo = self::$merinfo;
|
|
$obj = new CloudObj($merinfo);
|
|
$cache = $obj->slotCard_v1($order_no, $code, $total_fee, $body, "alipay");
|
|
if ($cache) {
|
|
return true;
|
|
} else {
|
|
self::$errmsg = $obj->getMsg();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/** 查询支付宝订单信息
|
|
* @param $out_trade_no
|
|
* @return bool|mixed|string
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public function queryOrder($out_trade_no)
|
|
{
|
|
$merinfo = self::$merinfo;
|
|
$obj = new CloudObj($merinfo);
|
|
$re = $obj->queryOrder($out_trade_no, 'alipay');
|
|
if ($re) {
|
|
return $re;
|
|
} else {
|
|
self::$errmsg = $obj->getMsg();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/** 统一支付宝退款事件
|
|
* @param $order_no
|
|
* @param string $refund_id
|
|
* @param $total_fee
|
|
* @param $refund_fee
|
|
* @return mixed|string
|
|
*/
|
|
public function refund($order_no, $total_fee, $refund_fee, $refund_id = '')
|
|
{
|
|
$merinfo = self::$merinfo;
|
|
$obj = new CloudObj($merinfo);
|
|
$cache = $obj->Refund($order_no, $total_fee, 'alipay', $refund_fee, $refund_id);
|
|
if ($cache) {
|
|
return true;
|
|
} else {
|
|
self::$errmsg = $obj->getMsg();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/** 查询支付宝退款订单信息
|
|
* @param $out_trade_no
|
|
* @return bool|mixed|string
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public function refundQuery($out_trade_no)
|
|
{
|
|
$merinfo = self::$merinfo;
|
|
$obj = new CloudObj($merinfo);
|
|
$re = $obj->refundQuery($out_trade_no);
|
|
if ($re) {
|
|
return $re;
|
|
} else {
|
|
self::$errmsg = $obj->getMsg();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/** 下单操作
|
|
* @param $order_no
|
|
* @param $open_id
|
|
* @param $payPrice
|
|
* @return bool
|
|
*/
|
|
public function unifiedorder($order_no, $payPrice, $storetag)
|
|
{
|
|
$merinfo = self::$merinfo;
|
|
$data['total_amount'] = $payPrice;
|
|
$data['trandeno'] = $order_no;
|
|
$data['orderType'] = 'alipay';
|
|
$data['storetag'] = $storetag;
|
|
$obj = new CloudObj($merinfo);
|
|
$cache = $obj->barCode($data);
|
|
if ($cache) {
|
|
return $cache;
|
|
} else {
|
|
self::$errmsg = $obj->getMsg();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/** 返回错误报告数据
|
|
* @return string
|
|
*/
|
|
public function getMsg()
|
|
{
|
|
return self::$errmsg;
|
|
}
|
|
} |