Giter Club home page Giter Club logo

Comments (9)

fzlee avatar fzlee commented on August 19, 2024

有示例代码么?
python是什么版本
用的这个库又是什么版本

from alipay.

qulc avatar qulc commented on August 19, 2024
  • Python 3.7
  • python-alipay-sdk==1.8.0
  • pycryptodomex==3.7.0
alipay = AliPay(
    appid="xxxxx",
    app_notify_url=None, 
    app_private_key_path="xxx",
    alipay_public_key_path="xxx",
    sign_type="RSA2"
)

result = alipay.api_alipay_fund_trans_toaccount_transfer(
    datetime.now().strftime("%Y%m%d%H%M%S%f"),
    payee_type="ALIPAY_LOGONID",
    payee_account="xxxxxxxxxx",
    amount=3.12
)

from alipay.

fzlee avatar fzlee commented on August 19, 2024

from alipay.

fzlee avatar fzlee commented on August 19, 2024

你看看是不是公钥传错了,要用支付宝的公钥

from alipay.

qulc avatar qulc commented on August 19, 2024

接口已经返回成功了,转账也到账了

之前没时间看具体原因,就重写了 _verify 方法始终返回 True,我再看看

from alipay.

fzlee avatar fzlee commented on August 19, 2024

from alipay.

qulc avatar qulc commented on August 19, 2024

是同一个值来的,支付宝的公钥不是自己设置的嘛?

from alipay.

fzlee avatar fzlee commented on August 19, 2024

支付宝的公钥是从支付宝官网下载的,你是从那里获取的吗。

from alipay.

qulc avatar qulc commented on August 19, 2024

然后在 _verify 函数里面 183 行

signer.verify 是只会返回 None 的,错误的签名会抛出 ValueError
https://www.pycryptodome.org/en/latest/src/signature/signature.html#verifying-a-signature

所以会导致签名正确情况下,这个 if 条件会永远返回 False

    def _verify(self, raw_content, signature):
        # 开始计算签名
        key = self.alipay_public_key
        signer = PKCS1_v1_5.new(key)
        if self._sign_type == "RSA":
            digest = SHA.new()
        else:
            digest = SHA256.new()
        digest.update(raw_content.encode("utf8"))
        if signer.verify(digest, decodebytes(signature.encode("utf8"))):
            return True
        return False

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.