123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- /**
- * 支付宝插件Demo
- * @author Jack_YanTC <627495692@qq.com>
- */
- class Demo {
- function __construct(){
- $config['appId']='135';
- $config['rsaPrivateKey']='135';
- $config['signType']='135';
- $config['alipayrsaPublicKey']='135';
- $this -> config = $config;
- }
- public function index() {
- $data['body']='订单详情';
- $data['subject']='订单';
- $data['out_trade_no']='201705201314';
- $data['total_amount']='0.01';
- require_once("./Plugins/AliPay/AliPay.php");
- //可传入$options自己的appid
- //$alipay =new \AliPay($this -> config);
- //配置到config的话,不许传递参数
- $alipay =new \AliPay();
- $result['app'] =$alipay->AliPayApp($data);
- $result['web'] =$alipay->AliPayWeb($data);
- $result['check']=$alipay->AliPayNotifyCheck();
- p($result['web']);
- //jsonReturn(0, 1, $result);
- }
- //app支付 示例
- public function appPay() {
- $data['body']='订单详情';
- $data['subject']='订单';
- $data['out_trade_no']='201705201314';
- $data['total_amount']='0.01';
- require_once("Plugins/AliPay/AliPay.php");
- $alipay =new \AliPay();
- $result =$alipay->AliPayApp($data);
- return $result;
- }
- //web支付 示例
- public function webPay() {
- $data['body']='订单详情';
- $data['subject']='订单';
- $data['out_trade_no']='201705201314';
- $data['total_amount']='0.01';
- require_once("Plugins/AliPay/AliPay.php");
- $alipay =new \AliPay();
- $result =$alipay->AliPayWeb($data);
- return $result;
- }
- //移动web支付 示例
- public function mobileWebPay() {
- $data['body']='订单详情';
- $data['subject']='订单';
- $data['out_trade_no']='201705201314';
- $data['total_amount']='0.01';
- require_once("Plugins/AliPay/AliPay.php");
- $alipay =new \AliPay();
- $result =$alipay->AliPayMobileWeb($data);
- return $result;
- }
-
- //支付回调地址 示例
- public function alipayNotify() {
- require_once("Plugins/AliPay/AliPay.php");
- $alipay =new \AliPay();
- //验证是否是支付宝发送
- $flag=$alipay->AliPayNotifyCheck();
- if ($flag) {
- if ($_POST['trade_status'] == 'TRADE_FINISHED' || $_POST['trade_status'] == 'TRADE_SUCCESS') {
- $out_trade_no = trim($_POST['out_trade_no']); //商户订单号
- //成功后的业务逻辑处理
- $result = D('Common/Order')->notify($out_trade_no);
- if ($result) {
- echo "success"; //告诉支付宝支付成功
- die;
- }
- }
- }
- echo "fail"; //验证失败
- die;
- }
- //提现转账 示例
- public function withdraw() {
- $data['out_biz_no']='201705201314';//订单号
- $data['payee_account'] ='627495692@qq.com';//收款支付宝账号
- $data['payee_real_name'] ='颜廷超';//收款支付宝账号真实姓名
- $data['amount'] ='0.01';//金额
- $data['payer_show_name']='科技转账';
- $data['remark'] = '备注';
- require_once("Plugins/AliPay/AliPay.php");
- $alipay =new \AliPay();
- $result =$alipay->AliPayWithdraw($data);
- return $result;
- }
- }
|