From 9db3744f478a139243f5639416d2edded8acaa15 Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 13 Nov 2018 18:00:47 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=AE=9D=E6=94=AF=E4=BB=98=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ _test/alipay.php | 2 +- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a808709..8b8ac08 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,82 @@ try { } ``` +支付宝支付 +---- +* 支付参数配置(可用沙箱模式) +```php +$config = [ + // 沙箱模式 + 'debug' => true, + // 应用ID + 'appid' => '2016090900468879', + // 支付宝公钥(1行填写) + 'public_key' => 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtU71NY53UDGY7JNvLYAhsNa+taTF6KthIHJmGgdio9bkqeJGhHk6ttkTKkLqFgwIfgAkHpdKiOv1uZw6gVGZ7TCu5LfHTqKrCd6Uz+N7hxhY+4IwicLgprcV1flXQLmbkJYzFMZqkXGkSgOsR2yXh4LyQZczgk9N456uuzGtRy7MoB4zQy34PLUkkxR6W1B2ftNbLRGXv6tc7p/cmDcrY6K1bSxnGmfRxFSb8lRfhe0V0UM6pKq2SGGSeovrKHN0OLp+Nn5wcULVnFgATXGCENshRlp96piPEBFwneXs19n+sX1jx60FTR7/rME3sW3AHug0fhZ9mSqW4x401WjdnwIDAQAB', + // 支付宝私钥(1行填写) + 'private_key' => 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC3pbN7esinxgjE8uxXAsccgGNKIq+PR1LteNTFOy0fsete43ObQCrzd9DO0zaUeBUzpIOnxrKxez7QoZROZMYrinttFZ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SEN0Qb9BrUJFeRz0VP6U3dzDPGHo7V4yyqRLgIN6EIcy1QKBgAqdh6mHPaTAHspDMyjJiYEc5cJIj/8rPkmIQft0FkhMUB0IRyAALNlyAUyeK61hW8sKvz+vPR8VEEk5xpSQp41YpuU6pDZc5YILZLfca8F+8yfQbZ/jll6Foi694efezl4yE/rUQG9cbOAJfEJt4o4TEOaEK5XoMbRBKc8pl22lAoGARTq0qOr9SStihRAy9a+8wi2WEwL4QHcmOjH7iAuJxy5b5TRDSjlk6h+0dnTItiFlTXdfpO8KhWA8EoSJVBZ1kcACQDFgMIA+VM+yXydtzMotOn21W4stfZ4I6dHFiujMsnKpNYVpQh3oCrJf4SeXiQDdiSCodqb1HlKkEc6naHQ=', + // 支付成功通知地址 + 'notify_url' => '', // 可以应用的时候配置哦 + // 网页支付回跳地址 + 'return_url' => '', // 可以应用的时候配置哦 +]; +``` +* 支付宝发起PC网站支付 +```php + +// 参考公共参数 https://docs.open.alipay.com/203/107090/ +$config['notify_url'] = 'http://pay.thinkadmin.top/test/alipay-notify.php'; +$config['return_url'] = 'http://pay.thinkadmin.top/test/alipay-success.php'; + +try { + + // 实例支付对象 + $pay = We::AliPayWeb($config); + // $pay = new \AliPay\Web($config); + + // 参考链接:https://docs.open.alipay.com/api_1/alipay.trade.page.pay + $result = $pay->apply([ + 'out_trade_no' => time(), // 商户订单号 + 'total_amount' => '1', // 支付金额 + 'subject' => '支付订单描述', // 支付订单描述 + ]); + + echo $result; // 直接输出HTML(提交表单跳转) + +} catch (Exception $e) { + + // 异常处理 + echo $e->getMessage(); + +} +``` +* 支付宝发起手机网站支付 +```php + +// 参考公共参数 https://docs.open.alipay.com/203/107090/ +$config['notify_url'] = 'http://pay.thinkadmin.top/test/alipay-notify.php'; +$config['return_url'] = 'http://pay.thinkadmin.top/test/alipay-success.php'; + +try { + // 实例支付对象 + $pay = We::AliPayWap($config); + // $pay = new \AliPay\Wap($config); + + // 参考链接:https://docs.open.alipay.com/api_1/alipay.trade.wap.pay + $result = $pay->apply([ + 'out_trade_no' => time(), // 商户订单号 + 'total_amount' => '1', // 支付金额 + 'subject' => '支付订单描述', // 支付订单描述 + ]); + echo $result; // 直接输出HTML(提交表单跳转) +} catch (Exception $e) { + + // 异常处理 + echo $e->getMessage(); + +} +``` +* 更新功能请阅读测试代码或SDK封装源码 + 开源协议 ---- * WeChatDeveloper 基于`MIT`协议发布,任何人可以用在任何地方,不受约束 diff --git a/_test/alipay.php b/_test/alipay.php index f4fe48a..b803253 100644 --- a/_test/alipay.php +++ b/_test/alipay.php @@ -1,6 +1,6 @@ true, // 应用ID 'appid' => '2016090900468879',