commposer下载yansongda
支付
fastadmin后台下载epay插件
$param = $this->request->param();
$uid = $this->auth->id;
// $openId = \db("third")->where(["user_id" => $uid])->value("openid");
$row = db('api_order')->where('id',$param['id'])->find();
if ($param['type'] == 'alipay'){
$amount = [
'amount' => $row['pay_price'],
'orderid' => $row['order_no'],
'type' => $param['type'],
'title' => '网页支付',
'notifyurl' => $this->request->domain() . '/addons/epay/index/notifyx/paytype/' .$param['type'] ,
'returnurl' => $this->request->domain() . "/pages/order/myOrder",
'method' => 'web',
'openid' => "",
];
$response = Service::submitOrder($amount);
echo $response;
}
支付回调
需要验签
退款
$config = [
'app_id' => '2021004101620262',
'notify_url' => '',
'return_url' => '',
'ali_public_key' => '支付宝公钥',
'private_key' => '应用私钥',
'log' => [ // optional
'file' => './logs/alipay.log',
'level' => 'info', // 建议生产环境等级调整为 info,开发环境为 debug
'type' => 'single', // optional, 可选 daily.
'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
],
'http' => [ // optional
'timeout' => 5.0,
'connect_timeout' => 5.0,
// 更多配置项请参考 [Guzzle](https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html)
],
// 'mode' => 'dev', // optional,设置此参数,将进入沙箱模式
];
$order = [
'out_trade_no' => $find['order_no'],
'refund_amount' => $params['refund_price'],
];
$result = Pay::alipay($config)->refund($order);
// 验证服务器数据
// 是的,验签就这么简单!
if ($result['code'] == '10000' && $result['msg'] == 'Success'){
$this->model->where(["order_no" => $find["order_no"]])->update(["status" => "refunded", 'refund_no' => $refundNo, "refund_time" => time()]);
db("api_order_refund")->insert([
"user_id" => $this->auth->id,
"refund_no" => $refundNo,
"order_no" => $find["order_no"],
"refund_time" => time(),
"status" => 1
]);
$this->success("支付宝退款成功!");
}else{
$this->error($result['err_code_des']);
}