1查看自己生成的公钥
[root@web01 ~]#cat app_public_key.pem -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgabcdefghigklmnopqrstuvwxyz zMVr75BQrlP+iVQroxldceHKnaXqIO5ZQlktnwfSFabcdefghigklmnopqrstuvwxyz 8szg/WCQym4lJJp3Q/zCu6IGiiSpMSgjxKNv6xe+abcdefghigklmnopqrstuvwxyz feoNtltQvtevOdP0p2cUkfFY901EbCpE7lvjdSzi7yMabcdefghigklmnopqrstuvwxyz K4JKbGeDmnBUuaVOFEZUZMrj5ajlWPEU3gHe7vgabcdefghigklmnopqrstuvwxyz FyoMtAAS4E4QYlAu/xNO32DeA6npHMu1i4Sw6V56abcdefghigklmnopqrstuvwxyz 12345678 -----END PUBLIC KEY----- [root@web01 ~]#
2把我们的公钥传给支付宝:
URL:https://open.alipay.com/platform/appDaily.htm
支付宝管理后台--沙箱--沙箱应用--自定义密钥-RSA2密钥(推荐)--设置并启用--公钥--粘贴上面自己生成的公钥--保存设置(此时支付宝会自动为我们展示我们的应用公钥和支付宝公钥)
注意两点:
1)只粘贴-----BEGIN PUBLIC KEY-----和-----END PUBLIC KEY-----中间的部分
2)比对一下支付宝自动为我们展示的页面中的应用公钥是不是和我们提交时的公钥一至(也就是第一步提交的公钥),一般情况下不会出错,但还是小心为好!
应用公钥:
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgabcdefghigklmnopqrstuvwxyz zMVr75BQrlP+iVQroxldceHKnaXqIO5ZQlktnwfSFabcdefghigklmnopqrstuvwxyz 8szg/WCQym4lJJp3Q/zCu6IGiiSpMSgjxKNv6xe+abcdefghigklmnopqrstuvwxyz feoNtltQvtevOdP0p2cUkfFY901EbCpE7lvjdSzi7yMabcdefghigklmnopqrstuvwxyz K4JKbGeDmnBUuaVOFEZUZMrj5ajlWPEU3gHe7vgabcdefghigklmnopqrstuvwxyz FyoMtAAS4E4QYlAu/xNO32DeA6npHMu1i4Sw6V56abcdefghigklmnopqrstuvwxyz 12345678
支付宝公钥:
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmn4B7HN6Mrj5ajlWPEU3gHe7vgabcdefghigklmnopqrstuvwxyzbYoUJKWndys3yyCOS4GVQu/n3rbS5ymbU5nR/5Y9lN8UzmtKLAxCsY/8DNi6l/4/2wZyqo4uw1234567890abcderghihklmnopqrstuvwxyz8uJU8vBZqZIhNIFl5NdctpxHgTifAFH9EonQlLozqwjEE4YLUbRQXVQZKGsS4RjCW3g53S/3rduDynZfayxa86EggO4l7L+UsAh3J3dB0shAwsrrhTmjaz6njZOWC5awIDAQAB
3在我们的终端创建支付宝公钥文件:
-----BEGIN PUBLIC KEY-----和-----END PUBLIC KEY-----需要我们自己添加
[root@web01 ~]#vim alipay_public_key.pem [root@web01 ~]#cat alipay_public_key.pem -----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmn4B7HN6Mrj5ajlWPEU3gHe7vgabcdefghigklmnopqrstuvwxyzbYoUJKWndys3yyCOS4GVQu/n3rbS5ymbU5nR/5Y9lN8UzmtKLAxCsY/8DNi6l/4/2wZyqo4uw1234567890abcderghihklmnopqrstuvwxyz8uJU8vBZqZIhNIFl5NdctpxHgTifAFH9EonQlLozqwjEE4YLUbRQXVQZKGsS4RjCW3g53S/3rduDynZfayxa86EggO4l7L+UsAh3J3dB0shAwsrrhTmjaz6njZOWC5awIDAQAB
-----END PUBLIC KEY-----
[root@web01 ~]#
[root@web01 ~]#ls
alipay_public_key.pem app_private_key.pem app_public_key.pem
4安装支付宝第三方SDK
D:\PycharmProjects\linuxTangblog>pip install python-alipay-sdk 备注: linux系统可使用如下命令检查是否已安装python-alipay-sdk: pip freeze|grep -i 'ali'