Giter Club home page Giter Club logo

Comments (11)

zzm88 avatar zzm88 commented on August 19, 2024 1

@fzlee 按您说的试改过来了,还是不行~

from alipay.

zzm88 avatar zzm88 commented on August 19, 2024

这是我的配置

# -*- 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

from alipay.

zzm88 avatar zzm88 commented on August 19, 2024

搜了下&amp好像就是&

私钥公钥都是按教程生产的,公钥也放到支付宝后台了,后台上验证私钥公钥是配对的。appid也是对应的。不知道为什么一直说签名错

from alipay.

fzlee avatar fzlee commented on August 19, 2024
app_notify_url=" http://www.getsms.club/",  # 默认回调url

你看看是不是多了个空格

from alipay.

fzlee avatar fzlee commented on August 19, 2024

有两个地方尝试一下, 第一个是url里面的空格,第二个是设置return_url="http:example.com/", 不要设置为空字符串

from alipay.

zzm88 avatar zzm88 commented on August 19, 2024
# -*- 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

输出

https://openapi.alipay.com/gateway.do?app_id=2018062460380864&biz_content=%7B%22out_trade_no%22%3A%2220161112%22%2C%22product_code%22%3A%22QUICK_WAP_PAY%22%2C%22total_amount%22%3A0.01%2C%22subject%22%3A%22aaa%22%7D&charset=utf-8&method=alipay.trade.wap.pay&notify_url=http%3A%2F%2Fwww.getsms.club%2F&return_url=http%3A%2F%2Fexample.com&sign_type=RSA2&timestamp=2018-06-27+21%3A11%3A44&version=1.0&sign=Iu%2Fq%2BkQwJQ%2BsH%2FtTEXAck54OOSnoF1DsgPELgxRgxa670yORDNIRdastkSmbtyAfZlqd2%2FGyyjyJThJ7WmKqgAooqb%2BHoBSnxCusCf0d1D3nPFf2MCidnacB6ZPTcbBxI7CUzC4PKhvZ15b6svUu7rGzIU8pwPRxffwYPOhC%2F6uTl3PBSWuhjXKLHwj%2BQBaikpMREBg7aRHLjby1mtTbEHVQfp6%2BlIAuz4C4SHg84osein8TDEidiToPaH7F%2F01LZChkYc%2BjO3vo%2B4CZalivpSEfnOpJw3TM0znVL0e6DJhkYHboWPfwqypYeobFbS9MloCmgH9TVvMr9T6%2F3KIheg%3D%3D

支付宝返回的信息

调试错误,请回到请求来源地,重新发起请求。
错误代码 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&notify_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==

from alipay.

fzlee avatar fzlee commented on August 19, 2024

这个事情有些奇怪,因为我点击你最后一次生成的链接, 直接在电脑浏览器或者手机浏览器里面是可以代开的。

from alipay.

zzm88 avatar zzm88 commented on August 19, 2024

神奇了,我也能打开了T_T
昨晚发帖的时候还是失败的

from alipay.

zzm88 avatar zzm88 commented on August 19, 2024

很奇怪,难道有延迟?因为我改了一些参数又不行了

from alipay.

fzlee avatar fzlee commented on August 19, 2024

from alipay.

zzm88 avatar zzm88 commented on August 19, 2024

@fzlee 原因找到了:vscode
最后print出来那个url,如果直接ctrl点击打开,链接里的ascii码的符号就会被decode,然后链接就不对了~谢谢po主:)

错误链接示范 ,可以看到里面包含了{ 等符号,在ascii里面是%7B%22

https://openapi.alipay.com/gateway.do?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-28+20:10:54&version=1.0&sign=cupJhme+lXVkTj9Yqd1ioNKEWAXPGveeJwTBDMXJH+o+KyiHImjo1BA+63XotpkAwqvdBo7pb9kEaR6P8363f+nao4GKIqQOP5is5uiqdsXxEoLAgAJ2pS9DmbhfEfFVXX41yCyKHwfUkXq6VY8+3tJbFYzFcC3NW3Ojd4aY0QTh8OyPdX6LDtYNW++zBusBeFgDWjx6QsYnGwvV9cxeEAXIgppOxl2l6QDMPZA1x0bGdhzEaHLQurwoIS2mndy03TTHSgEZ48yBz0w/yRY2LfnOjm8apg594GyY1tAUY9/yPBqUxATfUWkIP5QwXXeEeLM2xaJzAbFUoRJwawhWgQ==

from alipay.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.