支付宝最新SDK整合(包含APP,PC,WAP) PHP

时间:2021-09-24 07:31:18
【文件属性】:

文件名称:支付宝最新SDK整合(包含APP,PC,WAP) PHP

文件大小:1008KB

文件格式:RAR

更新时间:2021-09-24 07:31:18

支付宝SDK demo

/** *SDK调用说明 */ public function index() { //调用测试 import('AlipaySDK.Alipay'); $pay = new \Alipay(); /** * $trade_type 交易类型 app wap web */ $data = $pay->alipay('215360251411626', '0.01', '测试', '测试', 'web', 'http://www.test.com/callback'); //wap 结果string(880) "https://openapi.alipay.com/gateway.do?alipay_sdk=alipay-sdk-php-20180705&app_id=2018072660781410&biz;_content={"body":"测试","subject":"测试","out_trade_no":"215360251411626","timeout_express":"90m","total_amount":"0.01","product_code":"QUICK_WAP_PAY"}&charset=UTF-8&format=json&method=alipay.trade.wap.pay¬ify_url=http://www.test.com/callback&sign=RKPyAKAPv28GKfhWIdsCCOualcg2DMCbhpny6yw/tTvJ3Och+yIfS1au7zbGBnm5sFoX2enfgfZekTqBCyzK0/Irw01zDSAOJM4mPYxs96OUkOglWS5Zuq64JwQBAzesFvzKBGgsH2ecL8EUCclDbBIIrAT/DWr6KenyvQvXOxVQNwn540NoS754oBU0w9vLdrGj0Jljvn8D6cbDgnHiE8qLOgpaXv1ROLwtol0yj2H7cM/G7A9RM5Y8jV1aVNYWND8M4XAK5Wr8zwoa9RocbqDpYfw66NXSvrsuFpHf7MpWtSybH5TnxOP5kwzr7pJRDi0XRAyD9u1geei9thUsqA==&sign_type=RSA2×tamp=2018-09-04+11:50:49&version=1.0" //app 结果直接返回客户端无需处理 alipay_sdk=alipay-sdk-php-20180705&app_id=2018072660781410&biz;_content={"body":"测试","subject":"测试","out_trade_no":"215360251411626","timeout_express":"90m","total_amount":"0.01","product_code":"QUICK_MSECURITY_PAY"}&charset=UTF-8&format=json&method=alipay.trade.app.pay¬ify_url=http://www.test.com/callback&sign_type=RSA2×tamp=2018-09-04+11:54:53&version=1.0&sign=Ab6a0lDxaNcWLL7XcETM85DbBrJI8Sj6czPGKBNK17MZ85FBeStKL+nA/Z4tMORC7H39ooVCDz9ILpbRUfU0eaE7Oe2MOz+Jsj7oUEqwvbvt7eebyPgy2PmPlfAwcZypKla0nUJwHOF5F0cL+mvMGk/K7f2PYMtWL/dIfPOQGC1hBoKFiS+ZF7jIJ98R0AaITAjvQ1drAmJqXpMzUCa1XsTCuQXMXYKu8DNGb/hooJu0xUH/qUU+4fKD0TmBYANQHIrKIBNFl6J2Gw504Mlcfh929ce+YdzF8DXQjacsBSp7f08UJ/FfRvhVXqAfX8lAFETGjc7FXGgU6simNgv1UQ== //web 结果 https://openapi.alipay.com/gateway.do?alipay_sdk=alipay-sdk-php-20180705&app_id=2018072660781410&biz;_content={"body":"测试","subject":"测试","out_trade_no":"215360251411626","timeout_express":"90m","total_amount":"0.01","product_code":"FAST_INSTANT_TRADE_PAY"}&charset=UTF-8&format=json&method=alipay.trade.page.pay¬ify_url=http://www.test.com/callback&sign=l9+A5ZByhwLjQwzRes9+ymKkFVu7uMND4j6cIWmXIXHjrBnGaHkcr+hVkwocaU3d/hB2hdPnxDruhyYFgchnsIA/XWumosG9uEnKyD/T52+VZ8FxLh5wpwH0ucvKzbMjgIWk9dPVjUAU5Zz7QjqKsJ+AsItFpttd0tEVZD4je2PFp5mizeCWT0id0H+y44IGexN705rNe6TGpfJDG0RSDsbD/ZoCzd8FRzC9cv5uwf00J1E9Yc0bUH/l37WFDBTv/LZnqdfeWpaiu8ro7CJ3R+z/xGQTHToo2zLtEc4Cwop096X8WqwSdGbyI9FCemcFzigRB+6yzD9nS4PsWEG3Ug==&sign_type=RSA2×tamp=2018-09-04+11:56:06&version=1.0 echo $data; exit; } /** * 回调地址 */ public function callback() { import('AlipaySDK.Alipay'); $pay = new \Alipay(); $data = $_POST; $verify_result = $pay->check($data); if ($verify_result) { // 验证成功 $out_trade_no = $data['out_trade_no']; // 支付宝交易号 $trade_no = $data['trade_no']; // 交易状态 $trade_status = $data['trade_status']; if ($trade_status == 'TRADE_FINISHED') { //成功之后的操作 } else if ($trade_status == 'TRADE_SUCCESS') { //成功之后的操作 } echo "success"; // 请不要修改或删除 } else { // 验证失败 echo "fail"; } } 声明:是文档根据Alipay文档二次整合,完全开源。如果觉得还可以请点击收藏


网友评论