Closed zzm88 closed 6 years ago
这是我的配置
# -*- coding: utf-8 -*-
from alipay import AliPay
from alipay import ISVAlipay
app_private_key_string = open("key/app_private_key.pem").read()
alipay_public_key_string = open("key/alipay_public_key.pem").read()
alipay = AliPay(
appid="2018062460380864",
app_notify_url=" http://www.getsms.club/", # 默认回调url
app_private_key_string=app_private_key_string,
alipay_public_key_string=alipay_public_key_string, # 支付宝的公钥,验证支付宝回传消息使用,不是你自己的公钥,
sign_type="RSA2", # RSA 或者 RSA2
debug=False # 默认False
)
# If you don't know what ISV is, then forget about what I mentioned below
# either app_auth_code or app_auth_token should not be None
# 手机网站支付,需要跳转到https://openapi.alipay.com/gateway.do? + order_string
order_string = alipay.api_alipay_trade_wap_pay(
out_trade_no="20161112",
total_amount=0.01,
subject="subject",
return_url="",
notify_url="" # 可选, 不填则使用默认notify url
)
url = 'https://openapi.alipay.com/gateway.do?' + order_string
print url
搜了下&好像就是&
私钥公钥都是按教程生产的,公钥也放到支付宝后台了,后台上验证私钥公钥是配对的。appid也是对应的。不知道为什么一直说签名错
app_notify_url=" http://www.getsms.club/", # 默认回调url
你看看是不是多了个空格
有两个地方尝试一下, 第一个是url里面的空格,第二个是设置return_url="http:example.com/", 不要设置为空字符串
# -*- coding: utf-8 -*-
from alipay import AliPay
# from alipay import ISVAlipay
app_private_key_string = open("key/app_private_key.pem").read()
alipay_public_key_string = open("key/alipay_public_key.pem").read()
alipay = AliPay(
appid="2018062460380864",
app_notify_url="http://www.getsms.club/", # 默认回调url
app_private_key_string=app_private_key_string,
alipay_public_key_string=alipay_public_key_string, # 支付宝的公钥,验证支付宝回传消息使用,不是你自己的公钥,
sign_type="RSA2", # RSA 或者 RSA2
debug=False # 默认False
)
# If you don't know what ISV is, then forget about what I mentioned below
# either app_auth_code or app_auth_token should not be None
# isv_alipay = ISVAliPay(
# appid="",
# app_notify_url=None, # 默认回调url
# app_private_key_srting="",
# alipay_public_key_string="", # alipay public key, do not use your public key!
# sign_type="RSA", # RSA or RSA2
# debug=False, # False by default,
# app_auth_code=None,
# app_auth_token=None
# )
# 如果你是Python 2用户(考虑考虑升级到Python 3吧),请确保非ascii的字符串为utf8编码:
subject = u"aaa".encode("utf8")
# 手机网站支付,需要跳转到https://openapi.alipay.com/gateway.do? + order_string
order_string = alipay.api_alipay_trade_wap_pay(
out_trade_no="20161112",
total_amount=0.01,
subject=subject,
return_url="http://example.com",
notify_url="" # 可选, 不填则使用默认notify url
)
# url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
url = 'https://openapi.alipay.com/gateway.do?' + order_string
print url
输出
支付宝返回的信息
调试错误,请回到请求来源地,重新发起请求。 错误代码 invalid-signature 错误原因: 验签出错,建议检查签名字符串或签名私钥与应用公钥是否匹配,网关生成的验签字符串为:app_id=2018062460380864&biz_content={out_trade_no:20161112,product_code:QUICK_WAP_PAY,total_amount:0.01,subject:aaa}&charset=utf-8&method=alipay.trade.wap.pay¬ify_url=http://www.getsms.club/&return_url=http://example.com&sign_type=RSA2&timestamp=2018-06-27 21:11:44&version=1.0
query参数
app_id: 2018062460380864 biz_content: {out_trade_no:20161112,product_code:QUICK_WAP_PAY,total_amount:0.01,subject:aaa} charset: utf-8 method: alipay.trade.wap.pay notify_url: http://www.getsms.club/ return_url: http://example.com sign_type: RSA2 timestamp: 2018-06-27+21:11:44 version: 1.0 sign: Iu/q+kQwJQ+sH/tTEXAck54OOSnoF1DsgPELgxRgxa670yORDNIRdastkSmbtyAfZlqd2/GyyjyJThJ7WmKqgAooqb+HoBSnxCusCf0d1D3nPFf2MCidnacB6ZPTcbBxI7CUzC4PKhvZ15b6svUu7rGzIU8pwPRxffwYPOhC/6uTl3PBSWuhjXKLHwj+QBaikpMREBg7aRHLjby1mtTbEHVQfp6+lIAuz4C4SHg84osein8TDEidiToPaH7F/01LZChkYc+jO3vo+4CZalivpSEfnOpJw3TM0znVL0e6DJhkYHboWPfwqypYeobFbS9MloCmgH9TVvMr9T6/3KIheg==
@fzlee 按您说的试改过来了,还是不行~
这个事情有些奇怪,因为我点击你最后一次生成的链接, 直接在电脑浏览器或者手机浏览器里面是可以代开的。
神奇了,我也能打开了T_T 昨晚发帖的时候还是失败的
很奇怪,难道有延迟?因为我改了一些参数又不行了
改了些什么参数?理论上应该是立即生效的
On Thu, 28 Jun 2018 at 12:03, zzm88 notifications@github.com wrote:
很奇怪,难道有延迟?因为我改了一些参数又不行了
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fzlee/alipay/issues/54#issuecomment-400904164, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2FtS9thNY9JYcQuuGxlGl8QhxCldCeks5uBFWrgaJpZM4U38py .
@fzlee 原因找到了:vscode 最后print出来那个url,如果直接ctrl点击打开,链接里的ascii码的符号就会被decode,然后链接就不对了~谢谢po主:)
错误链接示范 ,可以看到里面包含了{ 等符号,在ascii里面是%7B%22
这是alipay返回的错误
这是sdk生成的链接
前者乱入了一些奇怪的amp;