123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- date_default_timezone_set('Asia/Shanghai');
- header('Content-type:text/html;charset=utf-8');
- require './class/common.php';
- require './class/AliLife.php';
- class Test
- {
- // 统一下单接口
- public function orderPay()
- {
- $client = new AliLife;
- // 参数
- $client->body = array(
- 'orderCode' => 'Y20181204170925675836',
- 'totalAmount' => '000000000101', //代表1.01元
- 'subject' => '1.01商品',
- 'body' => '1.01商品',
- 'payMode' => 'sand_alipay',
- 'payExtra' => array(
- 'subAppid' => 'wx86466ERH8461',
- 'userId' => 'oEl4G1XFFERHIHSXS63P-_09y',
- ),
- 'clientIp' => '127.0.0.1',
- 'notifyUrl' => 'http://192.168.22.171/sandpay-qr-phpdemo.bak',
- 'frontUrl' => 'http://192.168.22.171/sandpay-qr-phpdemo.bak',
- );
- // 返回结果
- $ret = $client->request('orderPay');
- echo '<pre>';
- print_r($ret);
- echo '</pre>';
- }
- // 订单查询
- public function orderQuery()
- {
- $client = new AliLife;
- // 参数, 每次需要重新赋值
- $client->body = array(
- 'orderCode' => '2017091551423473', //订单号
- 'extend' => ''
- );
- // 返回结果
- $ret = $client->request('orderQuery');
- echo '<pre>';
- print_r($ret);
- echo '</pre>';
- }
- // 退款申请
- public function orderRefund()
- {
- $client = new AliLife;
- // 参数
- $client->body = array(
- 'orderCode' => 'Y20181204170925675836', //新的订单号
- 'oriOrderCode' => '2017091551421977', //原订单号
- 'refundAmount' => '000000000012', //退款金额
- 'refundMarketAmount' => '000000000012', //退营销金额
- 'notifyUrl' => 'http://192.168.22.171/sandpay-qr-phpdemo.bak/test/dist/notifyUrl.php',
- 'refundReason' => 'test',
- 'extend' => ''
- );
- // 返回结果
- $ret = $client->request('orderRefund');
- echo '<pre>';
- print_r($ret);
- echo '</pre>';
- }
- // 异步通知通用接口
- public function notify()
- {
- // 实例化客户端
- $client = new AliLife;
- $sign = $_POST['sign']; //签名
- $data = stripslashes($_POST['data']); //支付数据
- // 验签
- try {
- $verifyFlag = $client->verify($data, $sign);
- if (!$verifyFlag) throw new Exception('签名失败');
- } catch (\Exception $e) {
- exit('签名失败');
- }
- // 回调数据
- echo '<pre>';
- print_r($data);
- echo '</pre>';
- }
- // 对账单申请接口
- public function clearfileDownload()
- {
- // 实例化客户端
- $client = new AliLife;
- // 参数
- $client->body = array(
- 'clearDate' => '20200611', // 结算日期
- 'fileType' => '1', // 文件返回类型
- 'extend' => ''
- );
- // 返回值
- $ret = $client->request('clearfileDownload');
- echo '<pre>';
- print_r($ret);
- echo '</pre>';
- }
- }
- $test = new Test();
- // $test->orderPay();
- // $test->orderQuery();
- // $test->orderRefund();
- // $test->clearfileDownload();
|