官方接口文档:退款接口: https://opendocs.alipay.com/apis/api_1/alipay.trade.refund支付订单查询接口:https://opendocs.alipay.com/apis/api_1/alipay.trade.query
文章插图
示例代码如下:<?php/** * 扫码支付 * 提醒:提交支付请求后微信会同步返回支付结果(没有异步回调通知) 。当返回结果为“系统错误”时 , 商户系统等待5秒后调用【查询订单API】 , 查询支付实际交易结果;当返回结果为“USERPAYING”时 , 商户系统可设置间隔时间(建议10秒)重新查询支付结果 , 直到支付成功或超时(建议30秒); */namespace Appapicontroller;use thinkController;use thinkDb;use thinkInput;use thinkfacadeRequest;use appapicontrollerCommon;header("Access-Control-Allow-Origin:*");header("Content-type: text/html; charset=utf-8");require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/Alipaydangmianfu_demo/f2fpay/model/builder/AlipayTradePayContentBuilder.php';require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/Alipaydangmianfu_demo/f2fpay/service/AlipayTradeService.php';require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/Alipaydangmianfu_demo/aop/AopClient.php';require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/Alipaydangmianfu_demo/aop/request/AlipayTradeRefundRequest.php';/** * 支付宝当面付 * @package appapicontroller */class Alipay{/*** Notes:* User: 小海* Time:下午 1:51* DATE:2020/12/10 0010*/public function alipay($authCode, $totalAmount, $outTradeNo){$common = new Common();$config = array(//签名方式'sign_type' => "RSA2",//支付宝公钥//'alipay_public_key' => "/fEsraprwCtzvzQETrNRwVxLO5jVmRGi60j8Ue1efIlzPXV9je9mkjzOmdssymZkh2QhUrCmZYI/FCEa3/cNMW0QIDAQAB",'alipay_public_key' => '+rHrXw7L+/HlesZSXoMsYRed7Ray6oFu/YjRTJ2e3zxkhcHjcy5pZIauuT5dz1vM6XA3q38VILGQZbK3RusYlcpNopbR5f6j8HOoIgSk3+qdmRgga2hgwhgd1JOj7R/aTmPGzTJ81E6FXCGN83PLnHYr0URgtnpjLVOg+xV5fiAeWGe9SOUasW3sfqFk54WRwB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IiZZFNynOBVdwDzmt1dAdwKBgDlj9caxFTTB9h2lVAAC6rql4Cr7u6o9BhaPmMPaBfKwE309dXOq/FESuUEMOcdYVhLvBV/0+I9BqfDCZ7TdWeGs5EciTYkBCfZGBRWjULjcWC+46EKXtzpk/7SBGMfO/X74ogvAP13U7td7vvaYHsWrRIpJ6MPVLWlLhCfnhv6rAoGAPMhd6NmnnAyjXRZBDIHmqYzFS5FwTdO4gqWv/KtHRWS+oVt7YJ3wgMOPbZVaOvqJacovICv7niba+ZhQfBsECm1Za6Ft8I5U3okCsIyBUv5V80wDVExPe32qD4aTWJQgDbZ+tCSzDqbdUL94LrhxDGkifJn0S7xAjqNPY7PPBf0CgYAMG7Buyxb1ZLQq7X/0ippM1kQIBOYcmxyK5r7CHcgRmBFmNf9BzWEClunDOCrY5USD6LK+Z+XnXX2q4XkKCxug8iVWBPh4lsqd+Tsn0orDE7JRcoDwl8QwkjdlsalPq8tOv/A91YM2GRI3oWHiC9TyBLds3BgwmO0vaivhtJNVyA==",//编码格式'charset' => "UTF-8",//支付宝网关'gatewayUrl' => "https://openapi.alipay.com/gateway.do",//应用ID'app_id' => "123423",//异步通知地址,只有扫码支付预下单可用'notify_url' => "",//最大查询重试次数'MaxQueryRetry' => "10",//查询间隔'QueryDuration' => "3");// (必填) 商户网站订单系统中唯一订单号 , 64个字符以内 , 只能包含字母、数字、下划线 , // 需保证商户系统端不能重复 , 建议通过数据库sequence生成 , //$outTradeNo = "Dsx" . date('Ymdhis') . mt_rand(100, 1000);$subject = "第三巷条形码支付";//$totalAmount = $_POST['payAmount'];// (必填) 订单总金额 , 单位为元 , 不能超过1亿元// (必填) 付款条码 , 用户支付宝钱包手机app点击“付款”产生的付款条码//$authCode = $_POST['auth_code']; //28开头18位数字// 支付超时 , 线下扫码交易定义为5分钟$timeExpress = "5m";// 创建请求builder , 设置请求参数$barPayRequestBuilder = new AlipayTradePayContentBuilder();$barPayRequestBuilder->setOutTradeNo($outTradeNo);$barPayRequestBuilder->setTotalAmount($totalAmount);$barPayRequestBuilder->setAuthCode($authCode);$barPayRequestBuilder->setTimeExpress($timeExpress);$barPayRequestBuilder->setSubject($subject);// 调用barPay方法获取当面付应答$barPay = new AlipayTradeService($config);$barPayResult = $barPay->barPay($barPayRequestBuilder);switch ($barPayResult->getTradeStatus()) {case "SUCCESS"://echo "支付宝支付成功:" . "<br>--------------------------<br>";$data = https://www.isolves.com/it/cxkf/bk/2020-12-25/$barPayResult->getResponse();$result = $common->returnway(2000, "支付宝支付成功!", $data);return json_encode($result);break;case "FAILED"://echo "支付宝支付失败!!!" . "
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 宝鸡在历史上称为什么 宝鸡历史上叫什么地名
- 八宝茶的做法,八宝茶饮的做法
- 格力1.5匹空调价格清单
- 2012年宝和祥牌,宝和祥2017年金刚山韵开汤品鉴
- 八宝茶的功效和禁忌,八宝茶材料做法及功效介绍
- 龙神茶是什么茶,八宝茶是什么
- 宝塔红茶的功效与作用,黄芪红茶的功效与作用怎么样
- 宝宝睡着头上出很多汗
- 宝宝睡着了怎么排气
- 宝宝作呕是怎么回事