vue支付原理

vue

 新建支付宝应用

           第一步:创建应用

·      

 生成秘钥生

2.2 按照官方要求生成秘钥

 把生成的app公钥粘贴到沙箱环境的app中

 2.4 查看沙箱环境账号和密码

 3.测试支付宝获取支付宝扫码链接

3.1 支付宝开发地址

支付宝开放平台: https://open.alipay.com/platform/home.htm

支付宝沙箱环境: https://openhome.alipay.com/platform/appDaily.htm?tab=info

支付宝开发者文档:https://openhome.alipay.com/developmentDocument.htm

电脑网站支付流程:https://docs.open.alipay.com/270

生成签名:https://docs.open.alipay.com/291/106103/

python-alipay-adk : https://github.com/fzlee/alipay/blob/master/README.zh-hans.md

  3.2 说明

阿里官方没有提供python对接支付的sdk,但是python库中有非官方的sdk包可以使用

python-alipay-adk : https://github.com/fzlee/alipay/blob/master/README.zh-hans.md

使用起来非常简单,只要传入几个必要的参数就可以完成

由于支付对安全要求很高,所以要理解对接支付宝安全的流程: 公钥加密、私钥解密 这八个字

 

3.3 app_private_key.pem app私钥

 

-----BEGIN RSA PRIVATE KEY-----

MIIEpAIBAAKCAQEAxXRdL+ALzW4AW6ndW5/ZD44ppPsfm9If/oc3pc1gmqjT7z73swlUhotEPZnLsk8hq

dEoR9fg/+0XijuJQqnU+CU3pptdXgkIcyq/fyvpRgkX2OA9G7CHEveZ97leaOG2RI1i2JvgUiM+O2LiDA

AbTWtk8Chx+j2Z+R5s22zgI/y+45bcMht/YDxAbmgDFkBq32PyHlu3gTjoB7SqBZ8ecU8AKBxSjUPB3t5

ls4T2P3Xy/ER2/PFcnh0vZGQsZRbHQ6wS1Jsql/3Wu1+tvHvIiKKXPGUcZe7czfqfwcIwVPrntEdPYC2J

USzC94vFwcMNAlai/aiWDCc4jDt1W7oetwIDAQABAoIBAQDBNBESjUk/I0laZ6Vex9PeMp5w/f95umrv5

GMA6yqBanyldplsJ877Lz4AgIId4Ovxe+TMF2HjSZxk98hg4Eiw3cnMTe1X28LW3Zcu2kqQ6sjYvuFMPL

iOSJPxHwJP4bs07Jsxk6Q0+qMj/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RIVATE KEY-----

 

3.4 alipay_public_key.pem 支付宝公钥

-----BEGIN PUBLIC KEY-----

MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIgHnOn7LLILlKETd6BFRJ0GqgS2Y3mn1wMQmyh9zEy

Wlz5p1zrahRahbXAfCfSqshSNfqOmAQzSHRVjCqjsAw1jyqrXaPdKBmr90DIpIxmIyKXv4GGAkPyJ/6FT

FY99uhpiq0qadD/uSzQsefWo0aTvP/65zi3eof7TcZ32oWpwIDAQAB

-----END PUBLIC KEY-----

测试生成支付链接

from alipay import AliPay # 沙箱环境中 app 私钥 app_private_key_string = open(\'app_private_key.pem\').read() # 支付宝公钥 alipay_public_key_string = open( \'alipay_public_key.pem\').read() def get_alipay_url(): alipay = AliPay( appid="2016101800716047", # 沙箱appid app_notify_url=None, # 默认回调url app_private_key_string=app_private_key_string, # 支付宝的公钥,验证支付宝回传消息使用,不是你自己的公钥, alipay_public_key_string=alipay_public_key_string, sign_type="RSA", # RSA 或者 RSA2 debug=True, # 默认False,我们是沙箱,所以改成True(让访问沙箱环境支付宝地址) )# 调用支付接口 # 电脑网站支付,需要跳转到https://openapi.alipay.com/gateway.do? + order_string order_string = alipay.api_alipay_trade_page_pay( out_trade_no="201612226", # 订单id,应该从前端获取

total_amount=str(0.01), # 订单总金额 subject="测试阿里云付款", # 付款标题信息 return_url=None, # 付款成功回调地址(可以为空) notify_url=None # 付款成功后异步通知地址(可以为空) )pay_url = "https://openapi.alipaydev.com/gateway.do?" + order_string print(pay_url) # 将这个url复制到浏览器,就会打开支付宝支付页面 def query_pay(): alipay = AliPay( appid="2016101800716047", # 沙箱appid app_notify_url=None, # 默认回调url app_private_key_string=app_private_key_string, # 支付宝的公钥,验证支付宝回传消息使用,不是你自己的公钥 alipay_public_key_string=alipay_public_key_string, sign_type="RSA", # RSA 或者 RSA2 debug=True, # 默认False,我们是沙箱,所以改成True(让访问沙箱环境支付宝地址) )trade_query = alipay.api_alipay_trade_query( out_trade_no=20161112, # 上面生成支付码页面时传入的商品订单号 trade_no=None )print(trade_query) if __name__ == \'__main__\': get_alipay_url() query_pay() \'\'\' trade_query 查询用户付款信息 返回信息详情请看官方:https://docs.open.alipay.com/api_1/alipay.trade.query { "code": "10000", # code=10000代表支付成功 "msg": "Success", "buyer_logon_id": "foq***@sandbox.com", "buyer_pay_amount": "0.00", "buyer_user_id": "2088102180228981", "buyer_user_type": "PRIVATE", "invoice_amount": "0.00", "out_trade_no": "20161112", "point_amount": "0.00", "receipt_amount": "0.00", "send_pay_date": "2020-02-20 21:20:48", "total_amount": "0.01", "trade_no": "2020022022001428981000087565", "trade_status": "TRADE_SUCCESS" }\'\'\'

生成链接如下

https://excashier.alipaydev.com/standard/auth.htm?

payOrderId=79d3a024f4904f58af434843b945132f.00

 

 

以上是 vue支付原理 的全部内容, 来源链接: utcz.com/z/375515.html

回到顶部