Code Monkey home page Code Monkey logo

Comments (8)

lifeiteng avatar lifeiteng commented on August 18, 2024

是不是应该转码一遍 UTF-8 到 ASCII?
https://www.w3school.com.cn/tags/html_ref_urlencode.asp

from alipay.

lifeiteng avatar lifeiteng commented on August 18, 2024

根据 https://github.com/alipay/alipay-sdk-python-all/blob/master/alipay/aop/api/util/WebUtils.py#L109

try:
    from urllib.parse import unquote_plus
except ImportError:
    from urllib import unquote_plus

message = {
    item[0]: unquote_plus(item[1])
    for item in [
        field.split("=") for field in raw_body.decode("utf-8").split("&")
    ]
}

from alipay.

fzlee avatar fzlee commented on August 18, 2024

这个问题看表象应该是你证书短了一些导致的

from alipay.

lifeiteng avatar lifeiteng commented on August 18, 2024

这个问题看表象应该是你证书短了一些导致的

不是的,我上面的代码片段修复了;是字符编码的问题 'gmt_create': '2023-09-10+22%3A46%3A18', -> 'gmt_create': unquote_plus('2023-09-10+22%3A46%3A18'),

from alipay.

lifeiteng avatar lifeiteng commented on August 18, 2024

我没找到把消息 body 转成字典的接口,自己写了转换逻辑

message = {
    item[0]: unquote_plus(item[1])
    for item in [
        field.split("=") for field in raw_body.decode("utf-8").split("&")
    ]
}

from alipay.

fzlee avatar fzlee commented on August 18, 2024

@lifeiteng 你好, 为了方便其他人不会遇到这个问题,我确认一下。

  1. 你用的是什么后端框架?
  2. 你调用verify的时候, 传入的参数是这样的吗
success = self.alipay_gateway.verify(message, signature)

这是你的message
message =  {{'gmt_create': '2023-09-10+22%3A46%3A18', 'charset': 'utf-8', 'gmt_payment': '2023-09-10+22%3A46%3A24' ...}
而实际上你认为正确的应该是这样的message =  {{'gmt_create': '2023-09-10+22:46:18', 'charset': 'utf-8', 'gmt_payment': '2023-09-10+22:46:24' ...}

from alipay.

lifeiteng avatar lifeiteng commented on August 18, 2024

@fzlee fastapi

from alipay.

fzlee avatar fzlee commented on August 18, 2024

你看一下这个链接

https://stackoverflow.com/questions/67393319/getting-query-parameters-as-dictionary-in-fastapi

将query里面的参数转化成dict是你这边应该做的。

你说的对,传入verify函数的参数应该是被unquote的, 但是我这边不会做这个转换。

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.